Skip to content

TINKERPOP-3147 Prevent aggregate step from having multiple by modulators #3113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: 3.8-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
=== TinkerPop 3.8.0 (Release Date: NOT OFFICIALLY RELEASED YET)

This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.

* Changed aggregate step to not allow multiple by modulators.
* Modified `TraversalStrategy` construction in Javascript where configurations are now supplied as a `Map` of options.
* Fixed bug in GraphSON v2 and v3 where full round trip of `TraversalStrategy` implementations was failing.
* Added missing strategies to the `TraversalStrategies` global cache as well as `CoreImports` in `gremlin-groovy`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public String toString() {

@Override
public void modulateBy(final Traversal.Admin<?, ?> aggregateTraversal) {
if (this.aggregateTraversal != null)
throw new IllegalStateException("Aggregate step can only have one by modulator");
this.aggregateTraversal = this.integrateChild(aggregateTraversal);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public List<Traversal.Admin<S, Object>> getLocalChildren() {

@Override
public void modulateBy(final Traversal.Admin<?, ?> storeTraversal) {
if (this.storeTraversal != null)
throw new IllegalStateException("Aggregate step can only have one by modulator");
this.storeTraversal = this.integrateChild(storeTraversal);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ private static IDictionary<string, List<Func<GraphTraversalSource, IDictionary<s
{"g_V_mapXin_hasIdX1XX_limitX2X_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Map<object>(__.In().HasId(p["vid1"])).Limit<object>(2).Values<object>("name")}},
{"g_V_rangeX2_1X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Range<object>(2, 1)}},
{"g_V_rangeX3_2X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Range<object>(3, 2)}},
{"g_V_aggregateXxX_byXnameX_byXageX_capXxX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Aggregate("x").By("name").By("age").Cap<object>("x")}},
{"g_V_aggregateXScope_local_xX_byXnameX_byXageX_capXxX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Aggregate(Scope.Local, "x").By("name").By("age").Cap<object>("x")}},
{"g_E_sampleX1X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.E().Sample(1)}},
{"g_E_sampleX2X_byXweightX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.E().Sample(2).By("weight")}},
{"g_V_localXoutE_sampleX1X_byXweightXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Local<object>(__.OutE().Sample(1).By("weight"))}},
Expand Down
2 changes: 2 additions & 0 deletions gremlin-go/driver/cucumber/gremlin.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_mapXin_hasIdX1XX_limitX2X_valuesXnameX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Map(gremlingo.T__.In().HasId(p["vid1"])).Limit(2).Values("name")}},
"g_V_rangeX2_1X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Range(2, 1)}},
"g_V_rangeX3_2X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Range(3, 2)}},
"g_V_aggregateXxX_byXnameX_byXageX_capXxX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Aggregate("x").By("name").By("age").Cap("x")}},
"g_V_aggregateXScope_local_xX_byXnameX_byXageX_capXxX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Aggregate(gremlingo.Scope.Local, "x").By("name").By("age").Cap("x")}},
"g_E_sampleX1X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E().Sample(1)}},
"g_E_sampleX2X_byXweightX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.E().Sample(2).By("weight")}},
"g_V_localXoutE_sampleX1X_byXweightXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Local(gremlingo.T__.OutE().Sample(1).By("weight"))}},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions gremlin-python/src/main/python/radish/gremlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@
'g_V_mapXin_hasIdX1XX_limitX2X_valuesXnameX': [(lambda g, vid1=None:g.V().map(__.in_().has_id(vid1)).limit(2).values('name'))],
'g_V_rangeX2_1X': [(lambda g:g.V().range_(2, 1))],
'g_V_rangeX3_2X': [(lambda g:g.V().range_(3, 2))],
'g_V_aggregateXxX_byXnameX_byXageX_capXxX': [(lambda g:g.V().aggregate('x').by('name').by('age').cap('x'))],
'g_V_aggregateXScope_local_xX_byXnameX_byXageX_capXxX': [(lambda g:g.V().aggregate(Scope.local, 'x').by('name').by('age').cap('x'))],
'g_E_sampleX1X': [(lambda g:g.E().sample(1))],
'g_E_sampleX2X_byXweightX': [(lambda g:g.E().sample(2).by('weight'))],
'g_V_localXoutE_sampleX1X_byXweightXX': [(lambda g:g.V().local(__.out_e().sample(1).by('weight')))],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
@StepClassFilter @StepSample
Feature: Step - sample()

Scenario: g_V_aggregateXxX_byXnameX_byXageX_capXxX
Given the modern graph
And the traversal of
"""
g.V().aggregate("x").by("name").by("age").cap("x")
"""
When iterated to list
Then the traversal will raise an error with message containing text of "Aggregate step can only have one by modulator"

Scenario: g_V_aggregateXScope_local_xX_byXnameX_byXageX_capXxX
Given the modern graph
And the traversal of
"""
g.V().aggregate(Scope.local, "x").by("name").by("age").cap("x")
"""
When iterated to list
Then the traversal will raise an error with message containing text of "Aggregate step can only have one by modulator"

Scenario: g_E_sampleX1X
Given the modern graph
And the traversal of
Expand Down