Skip to content

Commit

Permalink
Merge branch '3.6-dev' into ryan/requestid-serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 authored Feb 20, 2024
2 parents 45b47a3 + acc8fd3 commit 222c12d
Show file tree
Hide file tree
Showing 27 changed files with 160 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build with Maven
run: mvn clean install -pl -:gremlin-javascript,-:gremlin-dotnet-source,-:gremlin-dotnet-tests,-:gremlin-go,-:gremlin-python -Dci --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Dcoverage
- name: Upload to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
directory: ./gremlin-tools/gremlin-coverage/target/site
java-jdk8:
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
mvn clean install -pl -:gremlin-python,-:gremlin-javascript,-:gremlin-dotnet,-:gremlin-dotnet-source,-:gremlin-dotnet-tests -q -DskipTests -Dci
mvn verify -pl :gremlin-go
- name: Upload to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
working-directory: ./gremlin-go
- name: Go-Vet
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed a bug in Gremlin.Net for .NET 8 that led to exceptions: `InvalidOperationException: Enumeration has not started. Call MoveNext.`
* Fixed message requestId serialization in `gremlin-python`.
* Fixed bug in bytecode translation of `g.tx().commit()` and `g.tx().rollback()` in all languages.
* Improved error message from `JavaTranslator` by including exception source.
* Added missing `short` serialization (`gx:Int16`) to GraphSONV2 and GraphSONV3 in `gremlin-python`.
* Added tests for error handling for GLV's if tx.commit() is called remotely for graphs without transactions support.
Expand All @@ -33,6 +34,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed issue where server errors weren't being properly parsed when sending bytecode over HTTP.
* Improved bulkset contains check for elements if all elements in bulkset are of the same type.
* Fixed bug in `EarlyLimitStrategy` which was too aggressive when promoting `limit()` before `map()`.
* Fixed bug in mid-traversal `mergeE()` where mutations in `sideEffect()` were being applied to the current traverser rather than a `onMatch` edge.
[[release-3-6-6]]
=== TinkerPop 3.6.6 (November 20, 2023)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal;

import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Transaction;

/**
* A {@code GraphOp} or "graph operation" is a static {@link Bytecode} form that does not translate to a traversal
* but instead refers to a specific function to perform on a graph instance.
Expand All @@ -27,12 +30,12 @@ public enum GraphOp {
/**
* Commit a transaction.
*/
TX_COMMIT(new Bytecode("tx", "commit")),
TX_COMMIT(new Bytecode(GraphTraversalSource.Symbols.tx, Transaction.Symbols.commit)),

/**
* Rollback a transaction.
*/
TX_ROLLBACK(new Bytecode("tx", "rollback"));
TX_ROLLBACK(new Bytecode(GraphTraversalSource.Symbols.tx, Transaction.Symbols.rollback));

private final Bytecode bytecode;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private Symbols() {

public static final String withBulk = "withBulk";
public static final String withPath = "withPath";
public static final String tx = "tx";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ protected Iterator<Edge> flatMap(final Traverser.Admin<S> traverser) {

edges = IteratorUtils.peek(edges, e -> {

// if this was a start step the traverser is initialized with placeholder edge, so override that with
// the matched Edge so that the option() traversal can operate on it properly
if (isStart) traverser.set((S) e);
// override current traverser with the matched Edge so that the option() traversal can operate
// on it properly
traverser.set((S) e);

// assume good input from GraphTraversal - folks might drop in a T here even though it is immutable
final Map<String, ?> onMatchMap = materializeMap(traverser, onMatchTraversal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.TraversalStrategyProxy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
Expand Down Expand Up @@ -385,6 +386,9 @@ protected Script produceScript(final String traversalSource, final Bytecode o) {
convertToScript(instArg);
}
script.append(",");
} else if (methodName.equals(GraphTraversalSource.Symbols.tx)) {
final String command = resolveSymbol(instruction.getArguments()[0].toString());
script.append(").").append(command).append("()");
} else if (methodName.equals(GraphTraversal.Symbols.call)) {
// call()
// call(String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.apache.tinkerpop.gremlin.process.traversal.Pick;
import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
import org.apache.tinkerpop.gremlin.process.traversal.Script;
import org.apache.tinkerpop.gremlin.process.traversal.Text;
import org.apache.tinkerpop.gremlin.process.traversal.TextP;
import org.apache.tinkerpop.gremlin.process.traversal.Translator;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.TraversalStrategyProxy;
import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
Expand Down Expand Up @@ -297,16 +297,21 @@ protected Script produceScript(final String traversalSource, final Bytecode o) {
final String methodName = instruction.getOperator();
final Object[] arguments = instruction.getArguments();

script.append(".").append(resolveSymbol(methodName)).append("(");
if (methodName.equals(GraphTraversalSource.Symbols.tx)) {
final String command = resolveSymbol(arguments[0].toString());
script.append(".").append(resolveSymbol(methodName)).append("().").append(resolveSymbol(command)).append("()");
} else {
script.append(".").append(resolveSymbol(methodName)).append("(");

for (int i = 0; i < arguments.length; i++) {
convertToScript(arguments[i]);
if (i != arguments.length - 1) {
script.append(", ");
for (int i = 0; i < arguments.length; i++) {
convertToScript(arguments[i]);
if (i != arguments.length - 1) {
script.append(", ");
}
}
}

script.append(")");
script.append(")");
}
}
return script;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import org.apache.tinkerpop.gremlin.process.traversal.TextP;
import org.apache.tinkerpop.gremlin.process.traversal.Translator;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.TraversalStrategyProxy;
import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
Expand Down Expand Up @@ -342,6 +342,9 @@ protected Script produceScript(final String traversalSource, final Bytecode byte
convertToScript(o);
if (itty.hasNext()) script.append(",");
}
} else if (methodName.equals(GraphTraversalSource.Symbols.tx)) {
final String command = instruction.getArguments()[0].toString();
script.append(").").append(command).append("(");
} else {
final Iterator<Object> itty = Arrays.stream(instruction.getArguments()).iterator();
while (itty.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.tinkerpop.gremlin.process.traversal.Translator;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.TraversalStrategyProxy;
import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
Expand Down Expand Up @@ -322,6 +323,9 @@ protected Script produceScript(final String traversalSource, final Bytecode o) {
script.append(", (").append(castSecondArgTo).append(") ");
convertToScript(instruction.getArguments()[1]);
script.append(",");
} else if (methodName.equals(GraphTraversalSource.Symbols.tx)) {
final String command = instruction.getArguments()[0].toString();
script.append(").").append(command).append("()");
} else {
for (final Object object : instruction.getArguments()) {
convertToScript(object);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.TraversalStrategyProxy;
import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
import org.apache.tinkerpop.gremlin.process.traversal.util.OrP;
Expand Down Expand Up @@ -308,7 +309,10 @@ else if (methodName.equals("limit") && 1 == arguments.length)
script.append("[0:").append(arguments[0].toString()).append("]");
else if (methodName.equals("values") && 1 == arguments.length && script.getScript().length() > 3 && !STEP_NAMES.contains(arguments[0].toString()))
script.append(".").append(arguments[0].toString());
else {
else if (methodName.equals(GraphTraversalSource.Symbols.tx)) {
final String command = instruction.getArguments()[0].toString();
script.append(".").append(methodName).append("().").append(command).append("()");
} else {
script.append(".").append(resolveSymbol(methodName)).append("(");

// python has trouble with java varargs...wrapping in collection seems to solve the problem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public final class BytecodeHelper {
put(TraversalSource.Symbols.withComputer, Collections.emptyList());
put(GraphTraversalSource.Symbols.withBulk, Collections.emptyList());
put(GraphTraversalSource.Symbols.withPath, Collections.emptyList());
put(GraphTraversalSource.Symbols.tx, Collections.emptyList());
}};
byteCodeSymbolStepMap = Collections.unmodifiableMap(operationStepMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
*/
public interface Transaction extends AutoCloseable {

////////////////

public static final class Symbols {

private Symbols() {
// static fields only
}

public static final String commit = "commit";
public static final String rollback = "rollback";

}

////////////////
/**
* Opens a transaction.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.tinkerpop.gremlin.process.traversal.translator;

import org.apache.tinkerpop.gremlin.process.traversal.GraphOp;
import org.apache.tinkerpop.gremlin.process.traversal.Merge;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.P;
Expand Down Expand Up @@ -273,6 +274,14 @@ public void shouldTranslateVertexAndEdge() {
script4);
}

@Test
public void shouldTranslateTx() {
String script = translator.translate(GraphOp.TX_COMMIT.getBytecode()).getScript();
assertEquals("g.Tx().Commit()", script);
script = translator.translate(GraphOp.TX_ROLLBACK.getBytecode()).getScript();
assertEquals("g.Tx().Rollback()", script);
}

private void assertTranslation(final String expectedTranslation, final Object... objs) {
final String script = translator.translate(g.inject(objs).asAdmin().getBytecode()).getScript();
assertEquals(String.format("g.Inject(%s)", expectedTranslation), script);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.commons.text.StringEscapeUtils;
import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
import org.apache.tinkerpop.gremlin.process.traversal.GraphOp;
import org.apache.tinkerpop.gremlin.process.traversal.Translator;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
Expand Down Expand Up @@ -125,4 +126,12 @@ public void shouldTranslateArrayOfArray() {
assertEquals("g.Inject([]interface{}{[]interface{}{1, 2}, []interface{}{3, 4}})",
translator.translate(g.inject(Arrays.asList(Arrays.asList(1,2),Arrays.asList(3,4))).asAdmin().getBytecode()).getScript());
}

@Test
public void shouldTranslateTx() {
String script = translator.translate(GraphOp.TX_COMMIT.getBytecode()).getScript();
assertEquals("g.Tx().Commit()", script);
script = translator.translate(GraphOp.TX_ROLLBACK.getBytecode()).getScript();
assertEquals("g.Tx().Rollback()", script);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.tinkerpop.gremlin.process.traversal.translator;

import org.apache.tinkerpop.gremlin.process.traversal.GraphOp;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.Pop;
import org.apache.tinkerpop.gremlin.process.traversal.Scope;
Expand Down Expand Up @@ -307,6 +308,14 @@ public void shouldTranslateVertexAndEdge() {
script4);
}

@Test
public void shouldTranslateTx() {
String script = translator.translate(GraphOp.TX_COMMIT.getBytecode()).getScript();
assertEquals("g.tx().commit()", script);
script = translator.translate(GraphOp.TX_ROLLBACK.getBytecode()).getScript();
assertEquals("g.tx().rollback()", script);
}

private void assertTranslation(final String expectedTranslation, final Object... objs) {
final String script = translator.translate(g.inject(objs)).getScript();
assertEquals(String.format("g.inject(%s)", expectedTranslation), script);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.tinkerpop.gremlin.process.traversal.translator;

import org.apache.tinkerpop.gremlin.process.traversal.GraphOp;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.Pop;
import org.apache.tinkerpop.gremlin.process.traversal.Scope;
Expand Down Expand Up @@ -197,6 +198,14 @@ public void shouldTranslateVertexAndEdge() {
script4);
}

@Test
public void shouldTranslateTx() {
String script = translator.translate(GraphOp.TX_COMMIT.getBytecode()).getScript();
assertEquals("g.tx().commit()", script);
script = translator.translate(GraphOp.TX_ROLLBACK.getBytecode()).getScript();
assertEquals("g.tx().rollback()", script);
}

private void assertTranslation(final String expectedTranslation, final Object... objs) {
final String script = translator.translate(g.inject(objs).asAdmin().getBytecode()).getScript();
assertEquals(String.format("g.inject(%s)", expectedTranslation), script);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.tinkerpop.gremlin.process.traversal.translator;

import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
import org.apache.tinkerpop.gremlin.process.traversal.GraphOp;
import org.apache.tinkerpop.gremlin.process.traversal.TextP;
import org.apache.tinkerpop.gremlin.process.traversal.Translator;
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
Expand Down Expand Up @@ -131,6 +132,14 @@ public void shouldTranslateWithoutSyntaxSugar() {
assertEquals("g.V().range_(0,10).has('person','name','marko').limit(2).values('name')", gremlinAsPython);
}

@Test
public void shouldTranslateTx() {
String script = translator.translate(GraphOp.TX_COMMIT.getBytecode()).getScript();
assertEquals("g.tx().commit()", script);
script = translator.translate(GraphOp.TX_ROLLBACK.getBytecode()).getScript();
assertEquals("g.tx().rollback()", script);
}

private void assertTranslation(final String expectedTranslation, final Object... objs) {
final String script = translator.translate(g.inject(objs).asAdmin().getBytecode()).getScript();
assertEquals(String.format("g.inject(%s)", expectedTranslation), script);
Expand Down
2 changes: 1 addition & 1 deletion gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ NOTE that versions suffixed with "-rc" are considered release candidates (i.e. p
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="Polly" Version="8.2.1" />
<PackageReference Include="Polly" Version="8.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
Expand Down
Loading

0 comments on commit 222c12d

Please sign in to comment.