Skip to content

Commit

Permalink
Revert discard to using "none" bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 committed Dec 7, 2023
1 parent ae6bc6f commit 8036ea2
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private Symbols() {
}

public static final String profile = "profile";
public static final String discard = "discard";
public static final String discard = "none";
public static final String none = "none";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void setup() {
@Test
public void shouldParseTraversalMethod_discard() {
compare(g.V().discard(), eval("g.V().discard()"));
compare(g.V().union(__.identity().discard()), eval("g.V().union(__.identity().discard())"));
compare(g.V().union(__.identity().discard()), eval("g.V().union(__.identity().none())"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ else if (stepMethod.getName().equals("option"))
traversal.branch(__.identity().out(randomString(random)));
else if (stepMethod.getName().equals("to") || stepMethod.getName().equals("from"))
traversal.addE(randomString(random));
else if (stepMethod.getName().equals("discard"))
continue;

if (stepMethod.getName().equals("range")) {
if (Scope.class.isAssignableFrom(stepMethod.getParameterTypes()[0])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public bool HasNext()
/// <returns>The fully drained traversal.</returns>
public ITraversal<TStart, TEnd> Iterate()
{
Bytecode.AddStep("discard");
Bytecode.AddStep("none");
while (MoveNext())
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ public GraphTraversal<TStart, TEnd> Difference (object differenceObject)
/// </summary>
public GraphTraversal<TStart, TEnd> Discard ()
{
Bytecode.AddStep("discard");
Bytecode.AddStep("none");
return Wrap<TStart, TEnd>(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ private static IDictionary<string, List<Func<GraphTraversalSource, IDictionary<s
{"g_V_both_dedup_age_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Both().Dedup().By("age").Values<object>("name")}},
{"g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).As("a").Both().As("b").Both().As("c").Dedup("a","b").By("age").Select<object>("a","b","c").By("name")}},
{"g_VX1X_valuesXageX_dedupXlocalX_unfold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Values<object>("age").Dedup(Scope.Local).Unfold<object>()}},
{"g_V_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Discard()}},
{"g_VX1X_outXcreatedX_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").Discard()}},
{"g_V_hasLabelXpersonX_filterXoutEXcreatedXX_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().HasLabel("person").Filter(__.OutE("created")).Discard()}},
{"g_V_count_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Count().None()}},
{"g_V_hasLabelXpersonX_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().HasLabel("person").None()}},
{"g_VX1X_outXcreatedX_discard", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").None()}},
{"g_V_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().As("a").AddV().As("b").AddE("knows").To("a"), (g,p) =>g.V().Drop(), (g,p) =>g.V(), (g,p) =>g.E()}},
{"g_V_outE_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().As("a").AddV().As("b").AddE("knows").To("a"), (g,p) =>g.V().OutE().Drop(), (g,p) =>g.V(), (g,p) =>g.E()}},
{"g_V_properties_drop", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.AddV().Property("name","bob").AddV().Property("name","alice"), (g,p) =>g.V().Properties<object>().Drop(), (g,p) =>g.V(), (g,p) =>g.V().Properties<object>()}},
Expand Down Expand Up @@ -315,6 +315,9 @@ private static IDictionary<string, List<Func<GraphTraversalSource, IDictionary<s
{"g_V_valuesXageX_isXgte_29X_isXlt_34X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("age").Is(P.Gte(29)).Is(P.Lt(34))}},
{"g_V_whereXinXcreatedX_count_isX1XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(1)).Values<object>("name")}},
{"g_V_whereXinXcreatedX_count_isXgte_2XX_valuesXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Where(__.In("created").Count().Is(P.Gte(2))).Values<object>("name")}},
{"g_V_count_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Count().None()}},
{"g_V_hasLabelXpersonX_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().HasLabel("person").None()}},
{"g_VX1X_outXcreatedX_none", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Out("created").None()}},
{"g_V_orXhasXage_gt_27X__outE_count_gte_2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.Has("age",P.Gt(27)),__.OutE().Count().Is(P.Gte(2))).Values<object>("name")}},
{"g_V_orXoutEXknowsX__hasXlabel_softwareX_or_hasXage_gte_35XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Or(__.OutE("knows"),__.Has(T.Label,"software").Or().Has("age",P.Gte(35))).Values<object>("name")}},
{"g_V_asXaX_orXselectXaX_selectXaXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().As("a").Or(__.Select<object>("a"),__.Select<object>("a"))}},
Expand Down
6 changes: 3 additions & 3 deletions gremlin-go/driver/cucumber/gremlin.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
"g_V_both_dedup_age_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Both().Dedup().By("age").Values("name")}},
"g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).As("a").Both().As("b").Both().As("c").Dedup("a", "b").By("age").Select("a", "b", "c").By("name")}},
"g_VX1X_valuesXageX_dedupXlocalX_unfold": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Values("age").Dedup(gremlingo.Scope.Local).Unfold()}},
"g_V_count_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Count().Discard()}},
"g_V_hasLabelXpersonX_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().HasLabel("person").Discard()}},
"g_VX1X_outXcreatedX_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Out("created").Discard()}},
"g_V_count_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Count().None()}},
"g_V_hasLabelXpersonX_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().HasLabel("person").None()}},
"g_VX1X_outXcreatedX_discard": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Out("created").None()}},
"g_V_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().As("a").AddV().As("b").AddE("knows").To("a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Drop()}, 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()}},
"g_V_outE_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().As("a").AddV().As("b").AddE("knows").To("a")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().OutE().Drop()}, 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()}},
"g_V_properties_drop": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.AddV().Property("name", "bob").AddV().Property("name", "alice")}, func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Properties().Drop()}, 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.V().Properties()}},
Expand Down
2 changes: 1 addition & 1 deletion gremlin-go/driver/graphTraversal.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (g *GraphTraversal) Difference(args ...interface{}) *GraphTraversal {

// Discard adds the discard step to the GraphTraversal.
func (g *GraphTraversal) Discard(args ...interface{}) *GraphTraversal {
g.Bytecode.AddStep("discard", args...)
g.Bytecode.AddStep("none", args...)
return g
}

Expand Down
2 changes: 1 addition & 1 deletion gremlin-go/driver/traversal.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (t *Traversal) Iterate() <-chan error {
return
}

if err := t.Bytecode.AddStep("discard"); err != nil {
if err := t.Bytecode.AddStep("none"); err != nil {
r <- err
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class GraphTraversal extends Traversal {
* @returns {GraphTraversal}
*/
discard(...args) {
this.bytecode.addStep('discard', args);
this.bytecode.addStep('none', args);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Traversal {
* @returns {Promise}
*/
iterate() {
this.bytecode.addStep('discard');
this.bytecode.addStep('none');
return this._applyStrategies().then(() => {
let it;
while ((it = this._getNext()) && !it.done) {
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def difference(self, *args):
return self

def discard(self, *args):
self.bytecode.add_step("discard", *args)
self.bytecode.add_step("none", *args)
return self

def disjunct(self, *args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def to_set(self):
return set(iter(self))

def iterate(self):
self.bytecode.add_step("discard")
self.bytecode.add_step("none")
while True:
try: self.next_traverser()
except StopIteration: return self
Expand Down
6 changes: 3 additions & 3 deletions gremlin-python/src/main/python/radish/gremlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@
'g_V_both_dedup_age_name': [(lambda g:g.V().both().dedup().by('age').name)],
'g_VX1X_asXaX_both_asXbX_both_asXcX_dedupXa_bX_age_selectXa_b_cX_name': [(lambda g, vid1=None:g.V(vid1).as_('a').both().as_('b').both().as_('c').dedup('a','b').by('age').select('a','b','c').by('name'))],
'g_VX1X_valuesXageX_dedupXlocalX_unfold': [(lambda g, vid1=None:g.V(vid1).age.dedup(Scope.local).unfold())],
'g_V_count_discard': [(lambda g:g.V().count().discard())],
'g_V_hasLabelXpersonX_discard': [(lambda g:g.V().hasLabel('person').discard())],
'g_VX1X_outXcreatedX_discard': [(lambda g, vid1=None:g.V(vid1).out('created').discard())],
'g_V_count_discard': [(lambda g:g.V().count().none())],
'g_V_hasLabelXpersonX_discard': [(lambda g:g.V().hasLabel('person').none())],
'g_VX1X_outXcreatedX_discard': [(lambda g, vid1=None:g.V(vid1).out('created').none())],
'g_V_drop': [(lambda g:g.addV().as_('a').addV().as_('b').addE('knows').to('a')), (lambda g:g.V().drop()), (lambda g:g.V()), (lambda g:g.E())],
'g_V_outE_drop': [(lambda g:g.addV().as_('a').addV().as_('b').addE('knows').to('a')), (lambda g:g.V().outE().drop()), (lambda g:g.V()), (lambda g:g.E())],
'g_V_properties_drop': [(lambda g:g.addV().property('name','bob').addV().property('name','alice')), (lambda g:g.V().properties().drop()), (lambda g:g.V()), (lambda g:g.V().properties())],
Expand Down

0 comments on commit 8036ea2

Please sign in to comment.