Skip to content

Commit

Permalink
Merge branch '3.6-dev' into ryan/aliased-client
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 authored Mar 25, 2024
2 parents 6ee0e26 + dd7cb24 commit 088de62
Show file tree
Hide file tree
Showing 50 changed files with 1,105 additions and 242 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ jobs:
with:
java-version: '11'
distribution: 'temurin'
- name: Set up .NET 6.0.x
- name: Set up .NET 8.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '8.0.x'
- name: Get Cached Server Base Image
uses: actions/cache@v4
id: gremlin-server-test-docker-image
Expand Down
12 changes: 8 additions & 4 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
=== TinkerPop 3.6.7 (NOT OFFICIALLY RELEASED YET)
* 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`.
* Improved performance of `PathRetractionStrategy` for traversals that carry many children, but don't hold many labels to propogate.
* 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.
* 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.
* Introduced multi-architecture AMD64/ARM64 docker images for gremlin-console.
* Fixed bug in `JavaTranslator` where `has(String, null)` could call `has(String, Traversal)` to generate an error.
* 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
* 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()`.
* Updated aliased client to pass along options via `with()` when submitting traversals.
* Fixed bug in mid-traversal `mergeE()` where mutations in `sideEffect()` were being applied to the current traverser rather than a `onMatch` edge.
* Prevented mid-traversal `mergeE()` and `mergeV()` from operating on an incoming `Traverser` that contains an `Element`.
* Improved performance of the application of `FilterRankingStrategy` for large traversals with deeply nested traversals by improving the cache operation.
[[release-3-6-6]]
=== TinkerPop 3.6.6 (November 20, 2023)
Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
# specific language governing permissions and limitations
# under the License.

FROM ubuntu:bionic
FROM ubuntu:focal

LABEL maintainer="Daniel Kuppitz <[email protected]>"

RUN apt-get update
RUN apt-get -y install software-properties-common python3-software-properties apt-transport-https curl dpkg netcat net-tools iproute2
RUN add-apt-repository ppa:openjdk-r/ppa
RUN sh -c 'curl -s https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -o packages-microsoft-prod.deb'
RUN sh -c 'curl -s https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -o packages-microsoft-prod.deb'
RUN sh -c 'dpkg -i packages-microsoft-prod.deb'
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
RUN apt-get install apt-transport-https gnupg ca-certificates
RUN sh -c 'echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list'
RUN sh -c 'echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | tee /etc/apt/sources.list.d/mono-official-stable.list'
RUN apt-get update

# include both java 8/11 so that we can use the same docker image for future builds on that version of the jdk as we do
# for the older release branches. the java version to use is just controlled by JAVA_HOME hardcoded below
RUN apt-get install -y openjdk-8-jdk openjdk-11-jdk gawk git maven openssh-server subversion zip
RUN apt-get install -y --force-yes dotnet-sdk-6.0 mono-devel
RUN apt-get install -y --force-yes dotnet-sdk-8.0 mono-devel

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y python3 python3.8 python3-dev python3.8-dev python3-pip build-essential checkinstall zlib1g-dev libreadline-gplv2-dev \
Expand Down
4 changes: 2 additions & 2 deletions docs/src/dev/developer/development-environment.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ NOTE: For those using Windows, efforts have been made to keep the build OS indep
that TinkerPop's build system will only allow for a minimum build at best. +
+
Refer to <<building-on-windows>> section for more details.
[[groovy-environment]]
=== Groovy Environment
Expand Down Expand Up @@ -267,7 +267,7 @@ See the <<release-environment,Release Environment>> section for more information
[[dotnet-environment]]
=== DotNet Environment
The build optionally requires link:https://dotnet.microsoft.com/download[.NET SDK] (>=6.0) to work with the
The build optionally requires link:https://dotnet.microsoft.com/download[.NET SDK] (>=8.0) to work with the
`gremlin-dotnet` module. If .NET SDK is not installed, TinkerPop will still build with Maven, but .NET projects
will be skipped.
Expand Down
14 changes: 14 additions & 0 deletions docs/src/reference/the-traversal.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,13 @@ g.E().elementMap()
<1> Create three dogs.
<2> Stream the edge maps into `mergeE()` steps.
WARNING: There is a bit of an inconsistency present when `mergeE()` is used as a start step versus when it is used
mid-traversal. As a start step, `mergeE()` will promote the currently created or matched `Edge` to the child traversal,
allowing you to directly update it like `option(onMatch, property('k', 'v').constant([:]))`. However, when `mergeE()` is
used mid-traversal, the `Edge` is not promoted to the child traversal and the incoming traverser is used instead. Such
behavior is essentially blocked to prevent accidental misuse and will result in an exception at execution time that will
have a message like, "The incoming traverser for MergeEdgeStep cannot be an Element".
The `mergeE` step can be combined with the `mergeV` step (or any other step producing a `Vertex`) using the
`Merge.outV` and `Merge.inV` option modulators. These options can be used to "late-bind" the `OUT` and `IN`
vertices in the main merge argument and in the `onCreate` argument:
Expand Down Expand Up @@ -2732,6 +2739,13 @@ g.V(400).valueMap().with(WithOptions.tokens) <5>
<4> Pixel exists now, so we will take this option.
<5> The `updated` property has now been added.
WARNING: There is a bit of an inconsistency present when `mergeV()` is used as a start step versus when it is used
mid-traversal. As a start step, `mergeV()` will promote the currently created or matched `Vertex` to the child
traversal, allowing you to directly update it like `option(onMatch, property('k', 'v').constant([:]))`. However, when
`mergeV()` is used mid-traversal, the `Vertex` is not promoted to the child traversal and the incoming traverser is used
instead. Such behavior is essentially blocked to prevent accidental misuse and will result in an exception at execution
time that will have a message like, "The incoming traverser for MergeVertexStep cannot be an Element".
*Additional References*
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#mergeV()++[`mergeV()`],
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 @@ -34,6 +34,7 @@
import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.lambda.ConstantTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.Event;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
Expand Down Expand Up @@ -274,8 +275,11 @@ protected Iterator<Edge> flatMap(final Traverser.Admin<S> traverser) {
edges = IteratorUtils.peek(edges, e -> {

// override current traverser with the matched Edge so that the option() traversal can operate
// on it properly
traverser.set((S) e);
// on it properly. this should only work this way for the start step form to retain the original
// behavior for 3.6.0 where you might do g.inject(Map).mergeE() and want that Map to pass through.
// in 4.x this will be rectified such that the edge will always be promoted and you will be forced
// to select() the map if you did want the behavior.
if (isStart) 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 @@ -46,6 +46,7 @@
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
Expand Down Expand Up @@ -142,6 +143,14 @@ public void addChildOption(final Merge token, final Traversal.Admin<S, C> traver
if (token == Merge.onCreate) {
this.onCreateTraversal = this.integrateChild(traversalOption);
} else if (token == Merge.onMatch) {
// add a guard rail to ensure that the incoming object is not an Element. this will prevent
// a possibly inadvertent mutation of the graph if you did something like g.V().mergeE(). for
// 3.x we won't allow this behavior at all but in 4.x we will make it consistent like it will
// be in 4.x
if (!isStart && traversalOption != null && !(traversalOption instanceof ConstantTraversal)) {
traversalOption.addStep(0, new GuardRailStep<>(traversalOption, getClass().getSimpleName()));
}

this.onMatchTraversal = this.integrateChild(traversalOption);
} else {
throw new UnsupportedOperationException(String.format("Option %s for Merge is not supported", token.name()));
Expand Down Expand Up @@ -374,4 +383,30 @@ protected GraphTraversal searchVerticesPropertyConstraints(GraphTraversal t, fin

protected abstract Set getAllowedTokens();

/**
* Guard rail to ensure that the incoming object is not an {@link Element}.
*/
public static class GuardRailStep<S, E> extends ScalarMapStep<S, E> {
private final String stepType;

public GuardRailStep(final Traversal.Admin traversal, final String stepType) {
super(traversal);
this.stepType = stepType;
}

@Override
protected E map(final Traverser.Admin<S> t) {
if (t.get() instanceof Element) {
throw new IllegalArgumentException(
String.format("The incoming traverser for %s cannot be an Element", stepType));
}
return (E) t.get();
}

@Override
public String toString() {
return StringFactory.stepString(this);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ protected Iterator<Vertex> flatMap(final Traverser.Admin<S> traverser) {
// attach the onMatch properties
vertices = IteratorUtils.peek(vertices, v -> {

// if this was a start step the traverser is initialized with Boolean/false, so override that with
// the matched Vertex so that the option() traversal can operate on it properly
// override current traverser with the matched Vertex so that the option() traversal can operate
// on it properly. this should only work this way for the start step form to retain the original
// behavior for 3.6.0 where you might do g.inject(Map).mergeV() and want that Map to pass through.
// in 4.x this will be rectified such that the vertex will always be promoted and you will be forced
// to select() the map if you did want the behavior.
if (isStart) traverser.set((S) v);

// assume good input from GraphTraversal - folks might drop in a T here even though it is immutable
Expand Down
Loading

0 comments on commit 088de62

Please sign in to comment.