diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 6ee48182312..492266efdf4 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -31,6 +31,10 @@ This release also includes changes from <>. * Fixed a bug in `StarGraph` where `EdgeFilter` did not remove associated Edge Properties. * Added translator to the Go GLV. * Fixed bug with filtering for `group()` when the side-effect label was defined for it. +* Fixed bug in `DotNetTranslator` where `PartitionStrategy` usage was not translating properly when specifying the `readPartitions`. +* Fixed bug in `PythonTranslator` where `Set` syntax was not being generated properly. +* Fixed bug in configuration object given to `PartitionStrategy` for Go that prevented `readPartitions` from behing set properly. +* Fixed bug where the `partitionKey` was not being written when using `PartitionStrategy` with `mergeV()` and `mergeE()` [[release-3-6-5]] === TinkerPop 3.6.5 (Release Date: July 31, 2023) diff --git a/docs/src/dev/developer/for-committers.asciidoc b/docs/src/dev/developer/for-committers.asciidoc index fbaf0e23146..12d2e3ea317 100644 --- a/docs/src/dev/developer/for-committers.asciidoc +++ b/docs/src/dev/developer/for-committers.asciidoc @@ -580,9 +580,11 @@ best example of this sort of test would be one that uses the remote `Lambda` syn * `@UserSuppliedEdgeIds` - The scenario relies on the edge IDs specified in the dataset used by the scenario. * `@UserSuppliedVertexPropertyIds` - The scenario relies on the vertex property IDs specified in the dataset used by the scenario. * `@With*` - The scenario uses some `with()` based configuration like strategies: +** `@WithPartitionStrategy` ** `@WithProductiveByStrategy` ** `@WithReadOnlyStrategy` ** `@WithSeedStrategy` +** `@WithSubgraphStrategy` Tag filters can be applied to Intellij at execution time by adding a system properties of `-Dcucumber.filter.tags=`. diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeStep.java index cfa53ca73c8..c9a1cf1b0d3 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeStep.java @@ -41,7 +41,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.CallbackRegistry; import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.Event; import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.ListCallbackRegistry; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement; +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.Graph; @@ -65,6 +67,10 @@ public abstract class MergeStep extends FlatMapStep protected CallbackRegistry callbackRegistry; + private Parameters parameters = new Parameters(); + + private boolean usesPartitionStrategy; + public MergeStep(final Traversal.Admin traversal, final boolean isStart) { this(traversal, isStart, new IdentityTraversal<>()); } @@ -79,6 +85,13 @@ public MergeStep(final Traversal.Admin traversal, final boolean isStart, super(traversal); this.isStart = isStart; this.mergeTraversal = integrateChild(mergeTraversal); + + // determines if this step uses PartitionStrategy. it's not great that merge needs to know about a particular + // strategy but if it doesn't then it can't determine if Parameters are being used properly or not. to not have + // this check seems to invite problems. in some sense, this is not the first time steps have had to know more + // about strategies than is probably preferred - EventStrategy comes to mind + this.usesPartitionStrategy = TraversalHelper.getRootTraversal(traversal). + getStrategies().getStrategy(PartitionStrategy.class).isPresent(); } /** @@ -144,20 +157,20 @@ public List> getLocalChildren() { return children; } + /** + * This implementation should only be used as a mechanism for supporting {@link PartitionStrategy}. Using this + * with {@link GraphTraversal#with(String,Object)} will have an ill effect of simply acting like a call to + * {@link GraphTraversal#property(Object, Object, Object...)}. No mutating steps currently support use of + * {@link GraphTraversal#with(String,Object)} so perhaps it's best to not start with that now. + */ @Override public void configure(final Object... keyValues) { - // this is a Mutating step but property() should not be folded into this step. The main issue here is that - // this method won't know what step called it - property() or with() or something else so it can't make the - // choice easily to throw an exception, write the keys/values to parameters, etc. It really is up to the - // caller to make sure it is handled properly at this point. this may best be left as a do-nothing method for - // now. + this.parameters.set(this, keyValues); } @Override public Parameters getParameters() { - // merge doesn't take fold ups of property() calls. those need to get treated as regular old PropertyStep - // instances. not sure if this should support with() though.....none of the other Mutating steps do. - return null; + return this.parameters; } @Override @@ -301,7 +314,19 @@ protected void validateNoOverrides(final Map mergeMap, final Map onCre * null Map == empty Map */ protected Map materializeMap(final Traverser.Admin traverser, Traversal.Admin mapTraversal) { - final Map map = (Map) TraversalUtil.apply(traverser, mapTraversal); + Map map = (Map) TraversalUtil.apply(traverser, mapTraversal); + + // PartitionStrategy uses parameters as a mechanism for setting the partition key. trying to be as specific + // as possible here wrt parameters usage to avoid misuse + if (usesPartitionStrategy) { + map = null == map ? new LinkedHashMap() : map; + for (Map.Entry> entry : parameters.getRaw().entrySet()) { + final Object k = entry.getKey(); + final List v = entry.getValue(); + map.put(k, v.get(0)); + } + } + return map == null ? new LinkedHashMap() : map; } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java index 47d03364e70..5be561f11c3 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java @@ -39,6 +39,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.LambdaMapStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeEdgeStep; +import org.apache.tinkerpop.gremlin.process.traversal.step.map.MergeVertexStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep; import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep; @@ -226,6 +228,7 @@ public void apply(final Traversal.Admin traversal) { } final List stepsToInsertPropertyMutations = traversal.getSteps().stream().filter(step -> + step instanceof MergeVertexStep || step instanceof MergeEdgeStep || step instanceof AddEdgeStep || step instanceof AddVertexStep || step instanceof AddEdgeStartStep || step instanceof AddVertexStartStep || (includeMetaProperties && step instanceof AddPropertyStep) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/DotNetTranslator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/DotNetTranslator.java index 20ee8ec65c3..8e70b3000b4 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/DotNetTranslator.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/DotNetTranslator.java @@ -34,6 +34,7 @@ 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.strategy.TraversalStrategyProxy; +import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy; import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP; import org.apache.tinkerpop.gremlin.process.traversal.util.OrP; import org.apache.tinkerpop.gremlin.structure.Direction; @@ -194,8 +195,14 @@ protected String getSyntax(final Number o) { @Override protected Script produceScript(final Set o) { + return produceScriptForHashSet(o, "object"); + } + + private Script produceScriptForHashSet(final Set o, final String generic) { final Iterator iterator = o.iterator(); - script.append("new HashSet {"); + script.append("new HashSet<"); + script.append(generic); + script.append("> {"); while (iterator.hasNext()) { final Object nextItem = iterator.next(); @@ -292,7 +299,13 @@ protected Script produceScript(final TraversalStrategyProxy o) { final String k = keys.next(); script.append(k); script.append(": "); - convertToScript(o.getConfiguration().getProperty(k)); + + // special handle PartitionStrategy since the Set it uses must be of String for readPartitions + if (k.equals("readPartitions") && o.getStrategyClass().equals(PartitionStrategy.class)) + produceScriptForHashSet((Set) o.getConfiguration().getProperty(k), "string"); + else + convertToScript(o.getConfiguration().getProperty(k)); + if (keys.hasNext()) script.append(", "); } diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslator.java index 41f8382643c..58033de7f7e 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslator.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/translator/PythonTranslator.java @@ -205,13 +205,13 @@ protected String getSyntax(final Pick o) { @Override protected Script produceScript(final Set o) { final Iterator iterator = o.iterator(); - script.append("set("); + script.append("set(("); while(iterator.hasNext()) { convertToScript(iterator.next()); if (iterator.hasNext()) script.append(","); } - return script.append(")"); + return script.append("))"); } @Override diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStepTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStepTest.java index 76d95b1b067..f248d7d17ec 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStepTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeEdgeStepTest.java @@ -21,7 +21,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.Merge; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects; +import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep; +import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex; @@ -116,6 +119,8 @@ public void shouldFailToValidateWithoutTokensBecauseOfWeirdKey() { public void shouldWorkWithImmutableMap() { final Traversal.Admin traversal = mock(Traversal.Admin.class); when(traversal.getTraverserSetSupplier()).thenReturn(TraverserSetSupplier.instance()); + when(traversal.getParent()).thenReturn(EmptyStep.instance()); + when(traversal.getStrategies()).thenReturn(new DefaultTraversalStrategies()); final Traverser.Admin traverser = mock(Traverser.Admin.class); when(traverser.split()).thenReturn(mock(Traverser.Admin.class)); final Traversal.Admin onCreateTraversal = mock(Traversal.Admin.class); diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeVertexStepTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeVertexStepTest.java index f5d640613ba..fac6688b066 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeVertexStepTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MergeVertexStepTest.java @@ -22,6 +22,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; +import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep; +import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex; @@ -90,6 +92,8 @@ public void shouldFailToValidateWithoutTokensBecauseOfWeirdKey() { public void shouldWorkWithImmutableMap() { final Traversal.Admin traversal = mock(Traversal.Admin.class); when(traversal.getTraverserSetSupplier()).thenReturn(TraverserSetSupplier.instance()); + when(traversal.getParent()).thenReturn(EmptyStep.instance()); + when(traversal.getStrategies()).thenReturn(new DefaultTraversalStrategies()); final Traverser.Admin traverser = mock(Traverser.Admin.class); when(traverser.split()).thenReturn(mock(Traverser.Admin.class)); final Traversal.Admin onCreateTraversal = mock(Traversal.Admin.class); diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs index 473c2a4908c..24e94363bd8 100644 --- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs +++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs @@ -355,6 +355,30 @@ private static IDictionary, ITraversal>> {(g,p) =>g.V().As("n").Where(__.Or(__.Select("n").HasLabel("software"),__.Select("n").HasLabel("person"))).Select("n").By("name")}}, {"g_V_coworker", new List, ITraversal>> {(g,p) =>g.V().HasLabel("person").Filter(__.OutE("created")).Aggregate("p").As("p1").Values("name").As("p1n").Select("p").Unfold().Where(P.Neq("p1")).As("p2").Values("name").As("p2n").Select("p2").Out("created").Choose(__.In("created").Where(P.Eq("p1")),__.Values("name"),__.Constant(p["xx1"])).Group().By(__.Select("p1n")).By(__.Group().By(__.Select("p2n")).By(__.Unfold().Fold().Project("numCoCreated","coCreated").By(__.Count(Scope.Local)).By())).Unfold()}}, {"g_V_coworker_with_midV", new List, ITraversal>> {(g,p) =>g.V().HasLabel("person").Filter(__.OutE("created")).As("p1").V().HasLabel("person").Where(P.Neq("p1")).Filter(__.OutE("created")).As("p2").Map(__.Out("created").Where(__.In("created").As("p1")).Values("name").Fold()).Group().By(__.Select("p1").By("name")).By(__.Group().By(__.Select("p2").By("name")).By(__.Project("numCoCreated","coCreated").By(__.Count(Scope.Local)).By())).Unfold()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").AddV("person").Property("_partition","b").Property("name","bob"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).V().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").AddV("person").Property("_partition","b").Property("name","bob"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a", "b"}, writePartition: "a")).V().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").AddV("person").Property("_partition","b").Property("name","bob"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"c"}, writePartition: "a")).V().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_bothE_weight", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).V().BothE().Values("weight")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_bothE_weight", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"b"}, writePartition: "a")).V().BothE().Values("weight")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_bothE_dedup_weight", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a", "b"}, writePartition: "a")).V().BothE().Dedup().Values("weight")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_bothE_weight", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"c"}, writePartition: "a")).V().BothE().Values("weight")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_both_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).V().Both().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_both_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"b"}, writePartition: "a")).V().Both().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_both_dedup_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a", "b"}, writePartition: "a")).V().Both().Dedup().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_both_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"c"}, writePartition: "a")).V().Both().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_out_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).V().Out().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_in_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"b"}, writePartition: "a")).V().In().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_out_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a", "b"}, writePartition: "a")).V().Out().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_out_name", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").As("a").AddV("person").Property("_partition","b").Property("name","bob").As("b").AddE("knows").From("a").To("b").Property("_partition","a").Property("weight",1).AddE("knows").From("b").To("a").Property("_partition","b").Property("weight",2), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"c"}, writePartition: "a")).V().Out().Values("name")}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_addVXpersonX_propertyXname_aliceX_addXselfX", new List, ITraversal>> {(g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).AddV("person").Property("name","alice").AddE("self"), (g,p) =>g.V().Has("person","name","alice").Has("_partition","a"), (g,p) =>g.V(), (g,p) =>g.E().Has("_partition","a"), (g,p) =>g.E()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectXzeroX_addVXpersonX_propertyXname_aliceX_addXselfX", new List, ITraversal>> {(g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).Inject(0).AddV("person").Property("name","alice").AddE("self"), (g,p) =>g.V().Has("person","name","alice").Has("_partition","a"), (g,p) =>g.V(), (g,p) =>g.E().Has("_partition","a"), (g,p) =>g.E()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV", new List, ITraversal>> {(g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).MergeV((IDictionary) p["xx1"]), (g,p) =>g.V().Has("person","name","alice").Has("_partition","a"), (g,p) =>g.V()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X_mergeV", new List, ITraversal>> {(g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).Inject(0).MergeV((IDictionary) p["xx1"]), (g,p) =>g.V().Has("person","name","alice").Has("_partition","a"), (g,p) =>g.V()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeE", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").AddV("person").Property("_partition","a").Property("name","bob"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).MergeE((IDictionary) p["xx1"]), (g,p) =>g.E().Has("knows","_partition","a"), (g,p) =>g.E()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0XmergeE", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").AddV("person").Property("_partition","a").Property("name","bob"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).Inject(0).MergeE((IDictionary) p["xx1"]), (g,p) =>g.E().Has("knows","_partition","a"), (g,p) =>g.E()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeVXlabel_person_name_aliceX_optionXonMatch_name_bobX", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","a").Property("name","alice").AddV("person").Property("_partition","b").Property("name","alice"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).MergeV((IDictionary) p["xx1"]).Option(Merge.OnMatch, (IDictionary) p["xx2"]), (g,p) =>g.V().Has("person","name","bob").Has("_partition","a"), (g,p) =>g.V()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV_optionXonCreateX", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","b").Property("name","alice"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).MergeV((IDictionary) p["xx1"]).Option(Merge.OnCreate, (IDictionary) p["xx2"]), (g,p) =>g.V().Has("name","alice").Has("age",35).Has("_partition","a"), (g,p) =>g.V()}}, + {"g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X__mergeV_optionXonCreateX", new List, ITraversal>> {(g,p) =>g.AddV("person").Property("_partition","b").Property("name","alice"), (g,p) =>g.WithStrategies(new PartitionStrategy(includeMetaProperties: false, partitionKey: "_partition", readPartitions: new HashSet {"a"}, writePartition: "a")).Inject(0).MergeV((IDictionary) p["xx1"]).Option(Merge.OnCreate, (IDictionary) p["xx2"]), (g,p) =>g.V().Has("name","alice").Has("age",35).Has("_partition","a"), (g,p) =>g.V()}}, {"g_V_shortestpath", new List, ITraversal>> {(g,p) =>g.V().As("v").Both().As("v").Project("src","tgt","p").By(__.Select(Pop.First,"v")).By(__.Select(Pop.Last,"v")).By(__.Select(Pop.All,"v")).As("triple").Group("x").By(__.Select("src","tgt")).By(__.Select("p").Fold()).Select("tgt").Barrier().Repeat(__.Both().As("v").Project("src","tgt","p").By(__.Select(Pop.First,"v")).By(__.Select(Pop.Last,"v")).By(__.Select(Pop.All,"v")).As("t").Filter(__.Select(Pop.All,"p").Count(Scope.Local).As("l").Select(Pop.Last,"t").Select(Pop.All,"p").Dedup(Scope.Local).Count(Scope.Local).Where(P.Eq("l"))).Select(Pop.Last,"t").Not(__.Select(Pop.All,"p").As("p").Count(Scope.Local).As("l").Select(Pop.All,"x").Unfold().Filter(__.Select(Column.Keys).Where(P.Eq("t")).By(__.Select("src","tgt"))).Filter(__.Select(Column.Values).Unfold().Or(__.Count(Scope.Local).Where(P.Lt("l")),__.Where(P.Eq("p"))))).Barrier().Group("x").By(__.Select("src","tgt")).By(__.Select(Pop.All,"p").Fold()).Select("tgt").Barrier()).Cap("x").Select(Column.Values).Unfold().Unfold().Map(__.Unfold().Values("name").Fold())}}, {"g_withStrategiesXReadOnlyStrategyX_V", new List, ITraversal>> {(g,p) =>g.WithStrategies(new ReadOnlyStrategy()).V()}}, {"g_withStrategiesXReadOnlyStrategyX_V_outXknowsX_name", new List, ITraversal>> {(g,p) =>g.WithStrategies(new ReadOnlyStrategy()).V().Out("knows").Values("name")}}, diff --git a/gremlin-go/driver/cucumber/gremlin.go b/gremlin-go/driver/cucumber/gremlin.go index bfa5ac1c732..35971369d89 100644 --- a/gremlin-go/driver/cucumber/gremlin.go +++ b/gremlin-go/driver/cucumber/gremlin.go @@ -326,6 +326,30 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[ "g_V_asXnX_whereXorXselectXnX_hasLabelXsoftwareX_selectXnX_hasLabelXpersonXXX_selectXnX_byXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("n").Where(gremlingo.T__.Or(gremlingo.T__.Select("n").HasLabel("software"), gremlingo.T__.Select("n").HasLabel("person"))).Select("n").By("name")}}, "g_V_coworker": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().HasLabel("person").Filter(gremlingo.T__.OutE("created")).Aggregate("p").As("p1").Values("name").As("p1n").Select("p").Unfold().Where(gremlingo.P.Neq("p1")).As("p2").Values("name").As("p2n").Select("p2").Out("created").Choose(gremlingo.T__.In("created").Where(gremlingo.P.Eq("p1")), gremlingo.T__.Values("name"), gremlingo.T__.Constant(p["xx1"])).Group().By(gremlingo.T__.Select("p1n")).By(gremlingo.T__.Group().By(gremlingo.T__.Select("p2n")).By(gremlingo.T__.Unfold().Fold().Project("numCoCreated", "coCreated").By(gremlingo.T__.Count(gremlingo.Scope.Local)).By())).Unfold()}}, "g_V_coworker_with_midV": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().HasLabel("person").Filter(gremlingo.T__.OutE("created")).As("p1").V().HasLabel("person").Where(gremlingo.P.Neq("p1")).Filter(gremlingo.T__.OutE("created")).As("p2").Map(gremlingo.T__.Out("created").Where(gremlingo.T__.In("created").As("p1")).Values("name").Fold()).Group().By(gremlingo.T__.Select("p1").By("name")).By(gremlingo.T__.Group().By(gremlingo.T__.Select("p2").By("name")).By(gremlingo.T__.Project("numCoCreated", "coCreated").By(gremlingo.T__.Count(gremlingo.Scope.Local)).By())).Unfold()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").AddV("person").Property("_partition", "b").Property("name", "bob")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).V().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").AddV("person").Property("_partition", "b").Property("name", "bob")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a", "b"), WritePartition: "a"})).V().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").AddV("person").Property("_partition", "b").Property("name", "bob")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("c"), WritePartition: "a"})).V().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_bothE_weight": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).V().BothE().Values("weight")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_bothE_weight": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("b"), WritePartition: "a"})).V().BothE().Values("weight")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_bothE_dedup_weight": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a", "b"), WritePartition: "a"})).V().BothE().Dedup().Values("weight")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_bothE_weight": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("c"), WritePartition: "a"})).V().BothE().Values("weight")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_both_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).V().Both().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_both_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("b"), WritePartition: "a"})).V().Both().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_both_dedup_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a", "b"), WritePartition: "a"})).V().Both().Dedup().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_both_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("c"), WritePartition: "a"})).V().Both().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_out_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).V().Out().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_in_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("b"), WritePartition: "a"})).V().In().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_out_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a", "b"), WritePartition: "a"})).V().Out().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_out_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").As("a").AddV("person").Property("_partition", "b").Property("name", "bob").As("b").AddE("knows").From("a").To("b").Property("_partition", "a").Property("weight", 1).AddE("knows").From("b").To("a").Property("_partition", "b").Property("weight", 2)}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("c"), WritePartition: "a"})).V().Out().Values("name")}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_addVXpersonX_propertyXname_aliceX_addXselfX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).AddV("person").Property("name", "alice").AddE("self")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "alice").Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E().Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectXzeroX_addVXpersonX_propertyXname_aliceX_addXselfX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).Inject(0).AddV("person").Property("name", "alice").AddE("self")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "alice").Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E().Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).MergeV(p["xx1"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "alice").Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X_mergeV": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).Inject(0).MergeV(p["xx1"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "alice").Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeE": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").AddV("person").Property("_partition", "a").Property("name", "bob")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).MergeE(p["xx1"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E().Has("knows", "_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0XmergeE": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").AddV("person").Property("_partition", "a").Property("name", "bob")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).Inject(0).MergeE(p["xx1"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E().Has("knows", "_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeVXlabel_person_name_aliceX_optionXonMatch_name_bobX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "a").Property("name", "alice").AddV("person").Property("_partition", "b").Property("name", "alice")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).MergeV(p["xx1"]).Option(gremlingo.Merge.OnMatch, p["xx2"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("person", "name", "bob").Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV_optionXonCreateX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "b").Property("name", "alice")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).MergeV(p["xx1"]).Option(gremlingo.Merge.OnCreate, p["xx2"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("name", "alice").Has("age", 35).Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}}, + "g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X__mergeV_optionXonCreateX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV("person").Property("_partition", "b").Property("name", "alice")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.PartitionStrategy(gremlingo.PartitionStrategyConfig{IncludeMetaProperties: false, PartitionKey: "_partition", ReadPartitions: gremlingo.NewSimpleSet("a"), WritePartition: "a"})).Inject(0).MergeV(p["xx1"]).Option(gremlingo.Merge.OnCreate, p["xx2"])}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Has("name", "alice").Has("age", 35).Has("_partition", "a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V()}}, "g_V_shortestpath": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().As("v").Both().As("v").Project("src", "tgt", "p").By(gremlingo.T__.Select(gremlingo.Pop.First, "v")).By(gremlingo.T__.Select(gremlingo.Pop.Last, "v")).By(gremlingo.T__.Select(gremlingo.Pop.All, "v")).As("triple").Group("x").By(gremlingo.T__.Select("src", "tgt")).By(gremlingo.T__.Select("p").Fold()).Select("tgt").Barrier().Repeat(gremlingo.T__.Both().As("v").Project("src", "tgt", "p").By(gremlingo.T__.Select(gremlingo.Pop.First, "v")).By(gremlingo.T__.Select(gremlingo.Pop.Last, "v")).By(gremlingo.T__.Select(gremlingo.Pop.All, "v")).As("t").Filter(gremlingo.T__.Select(gremlingo.Pop.All, "p").Count(gremlingo.Scope.Local).As("l").Select(gremlingo.Pop.Last, "t").Select(gremlingo.Pop.All, "p").Dedup(gremlingo.Scope.Local).Count(gremlingo.Scope.Local).Where(gremlingo.P.Eq("l"))).Select(gremlingo.Pop.Last, "t").Not(gremlingo.T__.Select(gremlingo.Pop.All, "p").As("p").Count(gremlingo.Scope.Local).As("l").Select(gremlingo.Pop.All, "x").Unfold().Filter(gremlingo.T__.Select(gremlingo.Column.Keys).Where(gremlingo.P.Eq("t")).By(gremlingo.T__.Select("src", "tgt"))).Filter(gremlingo.T__.Select(gremlingo.Column.Values).Unfold().Or(gremlingo.T__.Count(gremlingo.Scope.Local).Where(gremlingo.P.Lt("l")), gremlingo.T__.Where(gremlingo.P.Eq("p"))))).Barrier().Group("x").By(gremlingo.T__.Select("src", "tgt")).By(gremlingo.T__.Select(gremlingo.Pop.All, "p").Fold()).Select("tgt").Barrier()).Cap("x").Select(gremlingo.Column.Values).Unfold().Unfold().Map(gremlingo.T__.Unfold().Values("name").Fold())}}, "g_withStrategiesXReadOnlyStrategyX_V": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.ReadOnlyStrategy()).V()}}, "g_withStrategiesXReadOnlyStrategyX_V_outXknowsX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.WithStrategies(gremlingo.ReadOnlyStrategy()).V().Out("knows").Values("name")}}, diff --git a/gremlin-go/driver/strategies.go b/gremlin-go/driver/strategies.go index 4e370a8c4f7..7c7a5f3182a 100644 --- a/gremlin-go/driver/strategies.go +++ b/gremlin-go/driver/strategies.go @@ -86,7 +86,7 @@ func PartitionStrategy(config PartitionStrategyConfig) TraversalStrategy { if config.WritePartition != "" { configMap["writePartition"] = config.WritePartition } - if len(config.ReadPartitions) != 0 { + if len(config.ReadPartitions.ToSlice()) != 0 { configMap["readPartitions"] = config.ReadPartitions } return &traversalStrategy{name: decorationNamespace + "PartitionStrategy", configuration: configMap} @@ -97,7 +97,7 @@ func PartitionStrategy(config PartitionStrategyConfig) TraversalStrategy { type PartitionStrategyConfig struct { PartitionKey string WritePartition string - ReadPartitions []string + ReadPartitions Set IncludeMetaProperties bool } diff --git a/gremlin-go/driver/strategies_test.go b/gremlin-go/driver/strategies_test.go index 01a56b0b86e..188d953c9db 100644 --- a/gremlin-go/driver/strategies_test.go +++ b/gremlin-go/driver/strategies_test.go @@ -76,7 +76,7 @@ func TestStrategy(t *testing.T) { config := PartitionStrategyConfig{ PartitionKey: "partition", WritePartition: "write", - ReadPartitions: []string{"read"}, + ReadPartitions: NewSimpleSet("read"), IncludeMetaProperties: true, } count, err := g.WithStrategies(PartitionStrategy(config)).V().Count().ToList() diff --git a/gremlin-go/driver/translator_test.go b/gremlin-go/driver/translator_test.go index 019247f79e1..907ebf89430 100644 --- a/gremlin-go/driver/translator_test.go +++ b/gremlin-go/driver/translator_test.go @@ -602,7 +602,7 @@ func Test_translator_Translate(t *testing.T) { }, { assert: func(g *GraphTraversalSource) *GraphTraversal { - return g.WithStrategies(PartitionStrategy(PartitionStrategyConfig{PartitionKey: "partition", WritePartition: "a", ReadPartitions: []string{"a"}})).AddV("test") + return g.WithStrategies(PartitionStrategy(PartitionStrategyConfig{PartitionKey: "partition", WritePartition: "a", ReadPartitions: NewSimpleSet("a")})).AddV("test") }, containsRandomClassParams: true, equals: "g.withStrategies(new PartitionStrategy(includeMetaProperties:false,partitionKey:'partition',writePartition:'a',readPartitions:['a'])).addV('test')", diff --git a/gremlin-javascript/build/generate.groovy b/gremlin-javascript/build/generate.groovy index c726d0e2ff3..deb96871637 100644 --- a/gremlin-javascript/build/generate.groovy +++ b/gremlin-javascript/build/generate.groovy @@ -91,7 +91,7 @@ radishGremlinFile.withWriter('UTF-8') { Writer writer -> writer.writeLine( 'const graphTraversalModule = require(\'../../lib/process/graph-traversal\');\n' + 'const traversalModule = require(\'../../lib/process/traversal\');\n' + - 'const { TraversalStrategies, VertexProgramStrategy, OptionsStrategy, ReadOnlyStrategy, SeedStrategy, SubgraphStrategy, ProductiveByStrategy } = require(\'../../lib/process/traversal-strategy\');\n' + + 'const { TraversalStrategies, VertexProgramStrategy, OptionsStrategy, PartitionStrategy, ReadOnlyStrategy, SeedStrategy, SubgraphStrategy, ProductiveByStrategy } = require(\'../../lib/process/traversal-strategy\');\n' + 'const __ = graphTraversalModule.statics;\n' + 'const Barrier = traversalModule.barrier\n' + 'const Cardinality = traversalModule.cardinality\n' + diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js index ef2936d14f7..b180e15fa61 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js @@ -26,7 +26,7 @@ const graphTraversalModule = require('../../lib/process/graph-traversal'); const traversalModule = require('../../lib/process/traversal'); -const { TraversalStrategies, VertexProgramStrategy, OptionsStrategy, ReadOnlyStrategy, SeedStrategy, SubgraphStrategy, ProductiveByStrategy } = require('../../lib/process/traversal-strategy'); +const { TraversalStrategies, VertexProgramStrategy, OptionsStrategy, PartitionStrategy, ReadOnlyStrategy, SeedStrategy, SubgraphStrategy, ProductiveByStrategy } = require('../../lib/process/traversal-strategy'); const __ = graphTraversalModule.statics; const Barrier = traversalModule.barrier const Cardinality = traversalModule.cardinality @@ -345,6 +345,30 @@ const gremlins = { g_V_asXnX_whereXorXselectXnX_hasLabelXsoftwareX_selectXnX_hasLabelXpersonXXX_selectXnX_byXnameX: [function({g}) { return g.V().as("n").where(__.or(__.select("n").hasLabel("software"),__.select("n").hasLabel("person"))).select("n").by("name") }], g_V_coworker: [function({g, xx1}) { return g.V().hasLabel("person").filter(__.outE("created")).aggregate("p").as("p1").values("name").as("p1n").select("p").unfold().where(P.neq("p1")).as("p2").values("name").as("p2n").select("p2").out("created").choose(__.in_("created").where(P.eq("p1")),__.values("name"),__.constant(xx1)).group().by(__.select("p1n")).by(__.group().by(__.select("p2n")).by(__.unfold().fold().project("numCoCreated","coCreated").by(__.count(Scope.local)).by())).unfold() }], g_V_coworker_with_midV: [function({g}) { return g.V().hasLabel("person").filter(__.outE("created")).as("p1").V().hasLabel("person").where(P.neq("p1")).filter(__.outE("created")).as("p2").map(__.out("created").where(__.in_("created").as("p1")).values("name").fold()).group().by(__.select("p1").by("name")).by(__.group().by(__.select("p2").by("name")).by(__.project("numCoCreated","coCreated").by(__.count(Scope.local)).by())).unfold() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").addV("person").property("_partition","b").property("name","bob") }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).V().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").addV("person").property("_partition","b").property("name","bob") }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a", "b"],writePartition:"a"})).V().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").addV("person").property("_partition","b").property("name","bob") }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["c"],writePartition:"a"})).V().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_bothE_weight: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).V().bothE().values("weight") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_bothE_weight: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["b"],writePartition:"a"})).V().bothE().values("weight") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_bothE_dedup_weight: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a", "b"],writePartition:"a"})).V().bothE().dedup().values("weight") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_bothE_weight: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["c"],writePartition:"a"})).V().bothE().values("weight") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_both_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).V().both().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_both_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["b"],writePartition:"a"})).V().both().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_both_dedup_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a", "b"],writePartition:"a"})).V().both().dedup().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_both_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["c"],writePartition:"a"})).V().both().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_out_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).V().out().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_in_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["b"],writePartition:"a"})).V().in_().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_out_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a", "b"],writePartition:"a"})).V().out().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_out_name: [function({g}) { return g.addV("person").property("_partition","a").property("name","alice").as("a").addV("person").property("_partition","b").property("name","bob").as("b").addE("knows").from_("a").to("b").property("_partition","a").property("weight",1).addE("knows").from_("b").to("a").property("_partition","b").property("weight",2) }, function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["c"],writePartition:"a"})).V().out().values("name") }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_addVXpersonX_propertyXname_aliceX_addXselfX: [function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).addV("person").property("name","alice").addE("self") }, function({g}) { return g.V().has("person","name","alice").has("_partition","a") }, function({g}) { return g.V() }, function({g}) { return g.E().has("_partition","a") }, function({g}) { return g.E() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectXzeroX_addVXpersonX_propertyXname_aliceX_addXselfX: [function({g}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).inject(0).addV("person").property("name","alice").addE("self") }, function({g}) { return g.V().has("person","name","alice").has("_partition","a") }, function({g}) { return g.V() }, function({g}) { return g.E().has("_partition","a") }, function({g}) { return g.E() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV: [function({g, xx1}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).mergeV(xx1) }, function({g, xx1}) { return g.V().has("person","name","alice").has("_partition","a") }, function({g, xx1}) { return g.V() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X_mergeV: [function({g, xx1}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).inject(0).mergeV(xx1) }, function({g, xx1}) { return g.V().has("person","name","alice").has("_partition","a") }, function({g, xx1}) { return g.V() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeE: [function({g, xx1}) { return g.addV("person").property("_partition","a").property("name","alice").addV("person").property("_partition","a").property("name","bob") }, function({g, xx1}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).mergeE(xx1) }, function({g, xx1}) { return g.E().has("knows","_partition","a") }, function({g, xx1}) { return g.E() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0XmergeE: [function({g, xx1}) { return g.addV("person").property("_partition","a").property("name","alice").addV("person").property("_partition","a").property("name","bob") }, function({g, xx1}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).inject(0).mergeE(xx1) }, function({g, xx1}) { return g.E().has("knows","_partition","a") }, function({g, xx1}) { return g.E() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeVXlabel_person_name_aliceX_optionXonMatch_name_bobX: [function({g, xx1, xx2}) { return g.addV("person").property("_partition","a").property("name","alice").addV("person").property("_partition","b").property("name","alice") }, function({g, xx1, xx2}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).mergeV(xx1).option(Merge.onMatch,xx2) }, function({g, xx1, xx2}) { return g.V().has("person","name","bob").has("_partition","a") }, function({g, xx1, xx2}) { return g.V() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV_optionXonCreateX: [function({g, xx1, xx2}) { return g.addV("person").property("_partition","b").property("name","alice") }, function({g, xx1, xx2}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).mergeV(xx1).option(Merge.onCreate,xx2) }, function({g, xx1, xx2}) { return g.V().has("name","alice").has("age",35).has("_partition","a") }, function({g, xx1, xx2}) { return g.V() }], + g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X__mergeV_optionXonCreateX: [function({g, xx1, xx2}) { return g.addV("person").property("_partition","b").property("name","alice") }, function({g, xx1, xx2}) { return g.withStrategies(new PartitionStrategy({includeMetaProperties:false,partitionKey:"_partition",readPartitions:["a"],writePartition:"a"})).inject(0).mergeV(xx1).option(Merge.onCreate,xx2) }, function({g, xx1, xx2}) { return g.V().has("name","alice").has("age",35).has("_partition","a") }, function({g, xx1, xx2}) { return g.V() }], g_V_shortestpath: [function({g}) { return g.V().as("v").both().as("v").project("src","tgt","p").by(__.select(Pop.first,"v")).by(__.select(Pop.last,"v")).by(__.select(Pop.all,"v")).as("triple").group("x").by(__.select("src","tgt")).by(__.select("p").fold()).select("tgt").barrier().repeat(__.both().as("v").project("src","tgt","p").by(__.select(Pop.first,"v")).by(__.select(Pop.last,"v")).by(__.select(Pop.all,"v")).as("t").filter(__.select(Pop.all,"p").count(Scope.local).as("l").select(Pop.last,"t").select(Pop.all,"p").dedup(Scope.local).count(Scope.local).where(P.eq("l"))).select(Pop.last,"t").not(__.select(Pop.all,"p").as("p").count(Scope.local).as("l").select(Pop.all,"x").unfold().filter(__.select(Column.keys).where(P.eq("t")).by(__.select("src","tgt"))).filter(__.select(Column.values).unfold().or(__.count(Scope.local).where(P.lt("l")),__.where(P.eq("p"))))).barrier().group("x").by(__.select("src","tgt")).by(__.select(Pop.all,"p").fold()).select("tgt").barrier()).cap("x").select(Column.values).unfold().unfold().map(__.unfold().values("name").fold()) }], g_withStrategiesXReadOnlyStrategyX_V: [function({g}) { return g.withStrategies(new ReadOnlyStrategy()).V() }], g_withStrategiesXReadOnlyStrategyX_V_outXknowsX_name: [function({g}) { return g.withStrategies(new ReadOnlyStrategy()).V().out("knows").values("name") }], diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py index 38eab569e91..f9bf7975103 100644 --- a/gremlin-python/src/main/python/radish/gremlin.py +++ b/gremlin-python/src/main/python/radish/gremlin.py @@ -327,6 +327,30 @@ 'g_V_asXnX_whereXorXselectXnX_hasLabelXsoftwareX_selectXnX_hasLabelXpersonXXX_selectXnX_byXnameX': [(lambda g:g.V().as_('n').where(__.or_(__.select('n').hasLabel('software'),__.select('n').hasLabel('person'))).select('n').by('name'))], 'g_V_coworker': [(lambda g, xx1=None:g.V().hasLabel('person').filter_(__.outE('created')).aggregate('p').as_('p1').name.as_('p1n').select('p').unfold().where(P.neq('p1')).as_('p2').name.as_('p2n').select('p2').out('created').choose(__.in_('created').where(P.eq('p1')),__.name,__.constant(xx1)).group().by(__.select('p1n')).by(__.group().by(__.select('p2n')).by(__.unfold().fold().project('numCoCreated','coCreated').by(__.count(Scope.local)).by())).unfold())], 'g_V_coworker_with_midV': [(lambda g:g.V().hasLabel('person').filter_(__.outE('created')).as_('p1').V().hasLabel('person').where(P.neq('p1')).filter_(__.outE('created')).as_('p2').map(__.out('created').where(__.in_('created').as_('p1')).name.fold()).group().by(__.select('p1').by('name')).by(__.group().by(__.select('p2').by('name')).by(__.project('numCoCreated','coCreated').by(__.count(Scope.local)).by())).unfold())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').addV('person').property('_partition','b').property('name','bob')), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').addV('person').property('_partition','b').property('name','bob')), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a','b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').addV('person').property('_partition','b').property('name','bob')), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('c')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_bothE_weight': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().bothE().weight)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_bothE_weight': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().bothE().weight)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_bothE_dedup_weight': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a','b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().bothE().dedup().weight)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_bothE_weight': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('c')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().bothE().weight)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_both_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().both().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_both_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().both().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_both_dedup_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a','b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().both().dedup().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_both_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('c')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().both().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_out_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().out().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_in_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().in_().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_out_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a','b')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().out().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_out_name': [(lambda g:g.addV('person').property('_partition','a').property('name','alice').as_('a').addV('person').property('_partition','b').property('name','bob').as_('b').addE('knows').from_('a').to('b').property('_partition','a').property('weight',1).addE('knows').from_('b').to('a').property('_partition','b').property('weight',2)), (lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('c')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).V().out().name)], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_addVXpersonX_propertyXname_aliceX_addXselfX': [(lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).addV('person').property('name','alice').addE('self')), (lambda g:g.V().has('person','name','alice').has('_partition','a')), (lambda g:g.V()), (lambda g:g.E().has('_partition','a')), (lambda g:g.E())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectXzeroX_addVXpersonX_propertyXname_aliceX_addXselfX': [(lambda g:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).inject(0).addV('person').property('name','alice').addE('self')), (lambda g:g.V().has('person','name','alice').has('_partition','a')), (lambda g:g.V()), (lambda g:g.E().has('_partition','a')), (lambda g:g.E())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV': [(lambda g, xx1=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).merge_v(xx1)), (lambda g, xx1=None:g.V().has('person','name','alice').has('_partition','a')), (lambda g, xx1=None:g.V())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X_mergeV': [(lambda g, xx1=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).inject(0).merge_v(xx1)), (lambda g, xx1=None:g.V().has('person','name','alice').has('_partition','a')), (lambda g, xx1=None:g.V())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeE': [(lambda g, xx1=None:g.addV('person').property('_partition','a').property('name','alice').addV('person').property('_partition','a').property('name','bob')), (lambda g, xx1=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).merge_e(xx1)), (lambda g, xx1=None:g.E().has('knows','_partition','a')), (lambda g, xx1=None:g.E())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0XmergeE': [(lambda g, xx1=None:g.addV('person').property('_partition','a').property('name','alice').addV('person').property('_partition','a').property('name','bob')), (lambda g, xx1=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).inject(0).merge_e(xx1)), (lambda g, xx1=None:g.E().has('knows','_partition','a')), (lambda g, xx1=None:g.E())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeVXlabel_person_name_aliceX_optionXonMatch_name_bobX': [(lambda g, xx1=None,xx2=None:g.addV('person').property('_partition','a').property('name','alice').addV('person').property('_partition','b').property('name','alice')), (lambda g, xx1=None,xx2=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).merge_v(xx1).option(Merge.on_match,xx2)), (lambda g, xx1=None,xx2=None:g.V().has('person','name','bob').has('_partition','a')), (lambda g, xx1=None,xx2=None:g.V())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV_optionXonCreateX': [(lambda g, xx1=None,xx2=None:g.addV('person').property('_partition','b').property('name','alice')), (lambda g, xx1=None,xx2=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).merge_v(xx1).option(Merge.on_create,xx2)), (lambda g, xx1=None,xx2=None:g.V().has('name','alice').has('age',35).has('_partition','a')), (lambda g, xx1=None,xx2=None:g.V())], + 'g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X__mergeV_optionXonCreateX': [(lambda g, xx1=None,xx2=None:g.addV('person').property('_partition','b').property('name','alice')), (lambda g, xx1=None,xx2=None:g.withStrategies(*[TraversalStrategy('PartitionStrategy',{'includeMetaProperties':False,'partitionKey':'_partition','readPartitions':set(('a')),'strategy':'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy','writePartition':'a'}, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy')]).inject(0).merge_v(xx1).option(Merge.on_create,xx2)), (lambda g, xx1=None,xx2=None:g.V().has('name','alice').has('age',35).has('_partition','a')), (lambda g, xx1=None,xx2=None:g.V())], 'g_V_shortestpath': [(lambda g:g.V().as_('v').both().as_('v').project('src','tgt','p').by(__.select(Pop.first,'v')).by(__.select(Pop.last,'v')).by(__.select(Pop.all_,'v')).as_('triple').group('x').by(__.select('src','tgt')).by(__.select('p').fold()).select('tgt').barrier().repeat(__.both().as_('v').project('src','tgt','p').by(__.select(Pop.first,'v')).by(__.select(Pop.last,'v')).by(__.select(Pop.all_,'v')).as_('t').filter_(__.select(Pop.all_,'p').count(Scope.local).as_('l').select(Pop.last,'t').select(Pop.all_,'p').dedup(Scope.local).count(Scope.local).where(P.eq('l'))).select(Pop.last,'t').not_(__.select(Pop.all_,'p').as_('p').count(Scope.local).as_('l').select(Pop.all_,'x').unfold().filter_(__.select(Column.keys).where(P.eq('t')).by(__.select('src','tgt'))).filter_(__.select(Column.values).unfold().or_(__.count(Scope.local).where(P.lt('l')),__.where(P.eq('p'))))).barrier().group('x').by(__.select('src','tgt')).by(__.select(Pop.all_,'p').fold()).select('tgt').barrier()).cap('x').select(Column.values).unfold().unfold().map(__.unfold().name.fold()))], 'g_withStrategiesXReadOnlyStrategyX_V': [(lambda g:g.withStrategies(*[TraversalStrategy('ReadOnlyStrategy', None, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy')]).V())], 'g_withStrategiesXReadOnlyStrategyX_V_outXknowsX_name': [(lambda g:g.withStrategies(*[TraversalStrategy('ReadOnlyStrategy', None, 'org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy')]).V().out('knows').name)], diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/integrated/PartitionStrategy.feature b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/integrated/PartitionStrategy.feature new file mode 100644 index 00000000000..7c7212027e9 --- /dev/null +++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/integrated/PartitionStrategy.feature @@ -0,0 +1,458 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +@StepClassIntegrated +Feature: Step - PartitionStrategy + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice"). + addV("person").property("_partition","b").property("name","bob") + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])).V().values("name") + """ + When iterated to list + Then the result should be unordered + | result | + | alice | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice"). + addV("person").property("_partition","b").property("name","bob") + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a", "b"])).V().values("name") + """ + When iterated to list + Then the result should be unordered + | result | + | alice | + | bob | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice"). + addV("person").property("_partition","b").property("name","bob") + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["c"])).V().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_bothE_weight + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])).V(). + bothE().values("weight") + """ + When iterated to list + Then the result should be unordered + | result | + | d[1].i | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_bothE_weight + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["b"])).V(). + bothE().values("weight") + """ + When iterated to list + Then the result should be unordered + | result | + | d[2].i | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_bothE_dedup_weight + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a", "b"])).V(). + bothE().dedup().values("weight") + """ + When iterated to list + Then the result should be unordered + | result | + | d[1].i | + | d[2].i | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_bothE_weight + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["c"])).V(). + bothE().values("weight") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_both_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])).V(). + both().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_both_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["b"])).V(). + both().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_both_dedup_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a", "b"])).V(). + both().dedup().values("name") + """ + When iterated to list + Then the result should be unordered + | result | + | alice | + | bob | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_both_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["c"])).V(). + both().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_V_out_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])).V(). + out().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_bXX_V_in_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["b"])).V(). + in().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_a_bXX_V_out_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a", "b"])).V(). + out().values("name") + """ + When iterated to list + Then the result should be unordered + | result | + | alice | + | bob | + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_cXX_V_out_name + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice").as("a"). + addV("person").property("_partition","b").property("name","bob").as("b"). + addE("knows").from("a").to("b").property("_partition","a").property("weight",1). + addE("knows").from("b").to("a").property("_partition","b").property("weight",2) + """ + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["c"])).V(). + out().values("name") + """ + When iterated to list + Then the result should have a count of 0 + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_addVXpersonX_propertyXname_aliceX_addXselfX + Given the empty graph + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + addV("person").property("name","alice"). + addE("self") + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"person\",\"name\",\"alice\").has(\"_partition\",\"a\")" + And the graph should return 1 for count of "g.V()" + And the graph should return 1 for count of "g.E().has(\"_partition\",\"a\")" + And the graph should return 1 for count of "g.E()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectXzeroX_addVXpersonX_propertyXname_aliceX_addXselfX + Given the empty graph + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + inject(0). + addV("person").property("name","alice"). + addE("self") + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"person\",\"name\",\"alice\").has(\"_partition\",\"a\")" + And the graph should return 1 for count of "g.V()" + And the graph should return 1 for count of "g.E().has(\"_partition\",\"a\")" + And the graph should return 1 for count of "g.E()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV + Given the empty graph + And using the parameter xx1 defined as "m[{\"t[label]\": \"person\", \"name\":\"alice\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + mergeV(xx1) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"person\",\"name\",\"alice\").has(\"_partition\",\"a\")" + And the graph should return 1 for count of "g.V()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X_mergeV + Given the empty graph + And using the parameter xx1 defined as "m[{\"t[label]\": \"person\", \"name\":\"alice\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + inject(0). + mergeV(xx1) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"person\",\"name\",\"alice\").has(\"_partition\",\"a\")" + And the graph should return 1 for count of "g.V()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeE + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice"). + addV("person").property("_partition","a").property("name","bob") + """ + And using the parameter xx1 defined as "m[{\"t[label]\": \"knows\", \"D[OUT]\":\"v[alice].id\", \"D[IN]\":\"v[bob].id\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + mergeE(xx1) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.E().has(\"knows\",\"_partition\",\"a\")" + And the graph should return 1 for count of "g.E()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0XmergeE + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice"). + addV("person").property("_partition","a").property("name","bob") + """ + And using the parameter xx1 defined as "m[{\"t[label]\": \"knows\", \"D[OUT]\":\"v[alice].id\", \"D[IN]\":\"v[bob].id\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + inject(0). + mergeE(xx1) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.E().has(\"knows\",\"_partition\",\"a\")" + And the graph should return 1 for count of "g.E()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeVXlabel_person_name_aliceX_optionXonMatch_name_bobX + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","a").property("name","alice"). + addV("person").property("_partition","b").property("name","alice") + """ + And using the parameter xx1 defined as "m[{\"t[label]\": \"person\", \"name\":\"alice\"}]" + And using the parameter xx2 defined as "m[{\"name\":\"bob\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + mergeV(xx1).option(Merge.onMatch, xx2) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"person\",\"name\",\"bob\").has(\"_partition\",\"a\")" + And the graph should return 2 for count of "g.V()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_mergeV_optionXonCreateX + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","b").property("name","alice") + """ + And using the parameter xx1 defined as "m[{\"name\":\"alice\"}]" + And using the parameter xx2 defined as "m[{\"age\":\"d[35].i\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + mergeV(xx1).option(Merge.onCreate, xx2) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"name\",\"alice\").has(\"age\",35).has(\"_partition\",\"a\")" + And the graph should return 2 for count of "g.V()" + + @WithPartitionStrategy + Scenario: g_withStrategiesXPartitionStrategyXwrite_a_read_aXX_injectX0X__mergeV_optionXonCreateX + Given the empty graph + And the graph initializer of + """ + g.addV("person").property("_partition","b").property("name","alice") + """ + And using the parameter xx1 defined as "m[{\"name\":\"alice\"}]" + And using the parameter xx2 defined as "m[{\"age\":\"d[35].i\"}]" + And the traversal of + """ + g.withStrategies(new PartitionStrategy(partitionKey: "_partition", writePartition: "a", readPartitions: ["a"])). + inject(0). + mergeV(xx1).option(Merge.onCreate, xx2) + """ + When iterated to list + Then the result should have a count of 1 + And the graph should return 1 for count of "g.V().has(\"name\",\"alice\").has(\"age\",35).has(\"_partition\",\"a\")" + And the graph should return 2 for count of "g.V()" \ No newline at end of file