Skip to content

Commit 4b26a63

Browse files
committed
Merge branch '3.8-dev'
2 parents a493eb2 + 515eabf commit 4b26a63

File tree

51 files changed

+970
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+970
-636
lines changed

CHANGELOG.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,16 @@ This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.
151151
* Deprecated `ProcessLimitedStandardSuite` and `ProcessLimitedComputerSuite` in favor of `ProcessEmbeddedStandardSuite` and `ProcessEmbeddedComputerSuite` respectively.
152152
* Deprecated `ProcessStandardSuite` and the `ProcessComputerSuite` in favor of Gherkin testing and the `ProcessEmbeddedStandardSuite` and `ProcessEmbeddedComputerSuite` for testing JVM-specific Gremlin behaviors.
153153
* Removed lambda oriented Gremlin testing from Gherkin test suite.
154+
* Removed `P.getOriginalValue()` in favor of `P.getValue()`
154155
* Increase minimum Java version from 1.8 to 11 for building and running.
155156
* Moved all lambda oriented Gremlin tests to `LambdaStepTest` in the Java test suite.
156157
* Removed the `@RemoteOnly` testing tag in Gherkin as lambda tests have all been moved to the Java test suite.
157158
* Updated gremlin-javascript to use GraphBinary as default instead of GraphSONv3
158159
* Renamed many types in the grammar for consistent use of terms "Literal", "Argument", and "Varargs"
159160
* Changed `gremlin-net` so that System.Text.Json is only listed as an explicit dependency when it is not available from the framework.
161+
* Fixed translation of numeric literals for Go losing type definitions
162+
* Added `ParseBigInt()` in `gremlin-go` for parsing string into `big.Int`
163+
* Expanded gherkin syntax to directly configure traversal side effects in feature tests
160164
161165
== TinkerPop 3.7.0 (Gremfir Master of the Pan Flute)
162166

docs/src/dev/developer/for-committers.asciidoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,18 @@ would be "1" and refer to the `Vertex` with that `id`.
436436
* `Predicate` variables should use `pred1`.
437437
* `Comparator` variables should use `c1` and `c2`.
438438
439+
Additionally, traversal side effects can be configured in a similar fashion as parameters. The structure for side effect
440+
definition looks like this:
441+
442+
[source,gherkin]
443+
----
444+
Given the modern graph
445+
And using the side effect x defined as "v[marko].id"
446+
----
447+
448+
The above example is equivalent to configuring a traversal with `g.withSideEffect(x, <marko vertex id>)` and may be
449+
used to add side effect values which could otherwise not be inlined into the traversal script.
450+
439451
Finally, specify the traversal under test with the "Given" option "and the traversal":
440452
441453
[source,gherkin]

docs/src/upgrade/release-3.8.x.asciidoc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ See: link:https://issues.apache.org/jira/browse/TINKERPOP-3083[TINKERPOP-3083]
196196
Starting from this version, `gremlin-javascript` will deserialize `Set` data into a ECMAScript 2015 Set. Previously,
197197
these were deserialized into arrays.
198198
199+
==== Removal of P.getOriginalValue()
200+
201+
`P.getOriginalValue()` has been removed as it was not offering much value and was often confused with `P.getValue()`.
202+
Usage of `P.getOriginalValue()` often leads to unexpected results if called on a predicate which has had its value reset
203+
after construction. All usages of `P.getOriginalValue()` should be replaced with `P.getValue()`.
204+
199205
==== Gremlin Grammar Changes
200206
201207
A number of changes have been introduced to the Gremlin grammar to help make it be more consistent and easier to use.
@@ -546,7 +552,7 @@ The `DiscardStep` is now renamed to `DiscardStep`. Providers who developed strat
546552
`DiscardStep` should switch to `DiscardStep`. Note that `DiscardStep` has been repurposed as `none(P)` for filtering
547553
collections as a complement to `any(P)` and `all(P)`.
548554
549-
==== Set minimum Java version to 11
555+
===== Set minimum Java version to 11
550556
551557
TinkerPop 3.8 requires a minimum of Java 11 for building and running. Support for Java 1.8 has been dropped.
552558
@@ -567,6 +573,18 @@ link:https://tinkerpop.apache.org/docs/3.8.0/dev/provider/#gherkin-tests-suite[P
567573
568574
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3136[TINKERPOP-3136]
569575
576+
===== New Gherkin Syntax for Side Effects
577+
578+
Added new syntax to the gherkin feature tests to directly add side effects to traversals.
579+
580+
[source,gherkin]
581+
----
582+
Given the modern graph
583+
And using the side effect x defined as "v[marko].id"
584+
----
585+
586+
Our complete Gherkin syntax for feature tests can be found in the link:https://tinkerpop.apache.org/docs/3.8.0/dev/developer/#_given[Developer Documentation].
587+
570588
===== Auto-promotion of Numbers
571589
572590
Previously, operations like `sum` or `sack` that involved mathematical calculations did not automatically promote the
@@ -655,6 +673,12 @@ All the following types in the grammar have been renamed to follow consistent ru
655673
Additionally, `genericLiteralListArgument` and `stringLiteralList` have been removed in favor of `genericArgumentVarags`
656674
and `stringNullableLiteralVarargs` respectively.
657675
676+
===== Removal of P.getOriginalValue()
677+
678+
`P.getOriginalValue()` has been removed as it was not offering much value and was often confused with `P.getValue()`.
679+
Usage of `P.getOriginalValue()` often leads to unexpected results if called on a predicate which has had its value reset
680+
after construction. All usages of `P.getOriginalValue()` should be replaced with `P.getValue()`.
681+
658682
==== Graph Driver Providers
659683
660684
===== Prefer OffsetDateTime

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/GoTranslateVisitor.java

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,34 @@ public Void visitIntegerLiteral(final GremlinParser.IntegerLiteralContext ctx) {
8888
int lastCharIndex = integerLiteral.length() - 1;
8989
char lastChar = integerLiteral.charAt(lastCharIndex);
9090

91-
// if the last character is not alphabetic then try to interpret the right type and append the suffix
92-
if (Character.isAlphabetic(lastChar))
91+
// if the last character is alphabetic, then force the exact type
92+
if (Character.isAlphabetic(lastChar)) {
93+
switch(lastChar) {
94+
case 'b':
95+
sb.append("int8(");
96+
break;
97+
case 's':
98+
sb.append("int16(");
99+
break;
100+
case 'i':
101+
sb.append("int32(");
102+
break;
103+
case 'l':
104+
sb.append("int64(");
105+
break;
106+
case 'n':
107+
sb.append("gremlingo.ParseBigInt(\"");
108+
break;
109+
default:
110+
throw new IllegalArgumentException("Unrecognized integer suffix: " + integerLiteral);
111+
}
93112
sb.append(integerLiteral, 0, lastCharIndex);
94-
else
113+
if (lastChar == 'n') sb.append("\"");
114+
sb.append(")");
115+
}
116+
else {
95117
sb.append(integerLiteral);
118+
}
96119
return null;
97120
}
98121

@@ -107,11 +130,28 @@ public Void visitFloatLiteral(final GremlinParser.FloatLiteralContext ctx) {
107130
int lastCharIndex = floatLiteral.length() - 1;
108131
char lastChar = floatLiteral.charAt(lastCharIndex);
109132

110-
// if the last character is not alphabetic then try to interpret the right type and append the suffix
111-
if (Character.isAlphabetic(lastChar))
112-
sb.append(floatLiteral, 0, lastCharIndex);
113-
else
133+
// if the last character is alphabetic, then force the exact type
134+
if (Character.isAlphabetic(lastChar)) {
135+
switch(lastChar) {
136+
case 'f':
137+
sb.append("float32(");
138+
sb.append(floatLiteral, 0, lastCharIndex);
139+
sb.append(")");
140+
break;
141+
case 'd': // Default case, no casts necessary
142+
sb.append(floatLiteral, 0, lastCharIndex);
143+
break;
144+
case 'm':
145+
sb.append("gremlingo.ParseBigDecimal(\"");
146+
sb.append(floatLiteral, 0, lastCharIndex);
147+
sb.append("\")");
148+
break;
149+
default:
150+
throw new IllegalArgumentException("Unrecognized float suffix: " + floatLiteral);
151+
}
152+
} else {
114153
sb.append(floatLiteral);
154+
}
115155
return null;
116156
}
117157

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,16 @@ public class P<V> implements Predicate<V>, Serializable, Cloneable {
3939

4040
protected PBiPredicate<V, V> biPredicate;
4141
protected V value;
42-
protected V originalValue;
4342

4443
public P(final PBiPredicate<V, V> biPredicate, final V value) {
4544
this.value = value;
46-
this.originalValue = value;
4745
this.biPredicate = biPredicate;
4846
}
4947

5048
public PBiPredicate<V, V> getBiPredicate() {
5149
return this.biPredicate;
5250
}
5351

54-
/**
55-
* Gets the original value used at time of construction of the {@code P}. This value can change its type
56-
* in some cases.
57-
*/
58-
public V getOriginalValue() {
59-
return originalValue;
60-
}
61-
6252
/*
6353
* Get the name of the predicate
6454
*/
@@ -88,8 +78,8 @@ public boolean test(final V testValue) {
8878
@Override
8979
public int hashCode() {
9080
int result = this.biPredicate.hashCode();
91-
if (null != this.originalValue)
92-
result ^= this.originalValue.hashCode();
81+
if (null != this.value)
82+
result ^= this.value.hashCode();
9383
return result;
9484
}
9585

@@ -98,17 +88,17 @@ public boolean equals(final Object other) {
9888
return other instanceof P &&
9989
((P) other).getClass().equals(this.getClass()) &&
10090
((P) other).getBiPredicate().equals(this.biPredicate) &&
101-
((((P) other).getOriginalValue() == null && this.originalValue == null) || ((P) other).getOriginalValue().equals(this.originalValue));
91+
((((P) other).getValue() == null && this.value == null) || ((P) other).getValue().equals(this.value));
10292
}
10393

10494
@Override
10595
public String toString() {
106-
return null == this.originalValue ? this.biPredicate.toString() : this.biPredicate.toString() + "(" + this.originalValue + ")";
96+
return null == this.value ? this.biPredicate.toString() : this.biPredicate.toString() + "(" + this.value + ")";
10797
}
10898

10999
@Override
110100
public P<V> negate() {
111-
return new P<>(this.biPredicate.negate(), this.originalValue);
101+
return new P<>(this.biPredicate.negate(), this.value);
112102
}
113103

114104
@Override

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TextP.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ public boolean equals(final Object other) {
3636

3737
@Override
3838
public String toString() {
39-
return null == this.originalValue ? this.biPredicate.toString() : this.biPredicate.toString() + "(" + this.originalValue + ")";
39+
return null == this.value ? this.biPredicate.toString() : this.biPredicate.toString() + "(" + this.value + ")";
4040
}
4141

4242
@Override
4343
public TextP negate() {
44-
return new TextP(this.biPredicate.negate(), this.originalValue);
44+
return new TextP(this.biPredicate.negate(), this.value);
4545
}
4646

4747
public TextP clone() {

0 commit comments

Comments
 (0)