You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2020/02/13 11:08:17 UTC

[tinkerpop] branch TINKERPOP-2338 created (now d317339)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch TINKERPOP-2338
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


      at d317339  TINKERPOP-2338 wip

This branch includes the following new commits:

     new d317339  TINKERPOP-2338 wip

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[tinkerpop] 01/01: TINKERPOP-2338 wip

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2338
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit d31733952dfdbc727055c3d51b2ed35a4013f0c0
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Thu Feb 13 06:07:49 2020 -0500

    TINKERPOP-2338 wip
---
 .../strategy/optimization/LazyBarrierStrategy.java |  5 +++
 .../optimization/LazyBarrierStrategyTest.java      |  9 ++++-
 .../Gherkin/GherkinTestRunner.cs                   |  2 +-
 .../src/main/jython/radish/feature_steps.py        |  2 +
 gremlin-test/features/filter/Drop.feature          | 43 +++++++++++++++++++++-
 .../process/traversal/step/filter/DropTest.java    | 37 +++++++++++++++++++
 6 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
index 7a4b17d..1e2257f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
@@ -23,6 +23,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier;
 import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NoneStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep;
@@ -74,7 +75,11 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
+        // drop() is a problem for bulked edge/meta properties because of Property equality changes in TINKERPOP-2318
+        // which made it so that a Property is equal if the key/value is equal. as a result, they bulk together which
+        // is fine for almost all cases except when you wish to drop the property.
         if (TraversalHelper.onGraphComputer(traversal) ||
+                TraversalHelper.hasStepOfAssignableClass(DropStep.class, traversal) ||
                 traversal.getTraverserRequirements().contains(TraverserRequirement.PATH) ||
                 (IS_TESTING && ((TraversalHelper.hasStepOfAssignableClass(ProfileStep.class, TraversalHelper.getRootTraversal(traversal)) ||
                         TraversalHelper.hasStepOfAssignableClass(ProfileSideEffectStep.class, TraversalHelper.getRootTraversal(traversal)))))) // necessary cause ProfileTest analyzes counts
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
index b2bbd94..100ba8b 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
@@ -100,7 +100,14 @@ public class LazyBarrierStrategyTest {
                 {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().select("b").barrier(PATH_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
                 {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(PATH_SIZE).out().select("b").barrier(PATH_SIZE).out().barrier(LAZY_SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
                 {__.V().out().out().groupCount().by(__.out().out().out()).out(), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out(), Collections.emptyList()},
-                {__.V().out().out().groupCount().by(__.out().out().out()).out().as("a"), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out().as("a"), Collections.emptyList()}
+                {__.V().out().out().groupCount().by(__.out().out().out()).out().as("a"), __.V().out().barrier(LAZY_SIZE).out().groupCount().by(__.out().out().barrier(LAZY_SIZE).out()).out().as("a"), Collections.emptyList()},
+                {__.out().drop(), __.out().drop(), Collections.emptyList()},
+                {__.out().properties().drop(), __.out().properties().drop(), Collections.emptyList()},
+                {__.out().properties().properties().drop(), __.out().properties().properties().drop(), Collections.emptyList()},
+                {__.out().out().properties().drop(), __.out().out().properties().drop(), Collections.emptyList()},
+                {__.out().out().values().is(true), __.out().out().barrier(LAZY_SIZE).values().barrier(LAZY_SIZE).is(true), Collections.emptyList()},
+                {__.outE().drop(), __.outE().drop(), Collections.emptyList()},
+                {__.outE().properties().drop(), __.outE().properties().drop(), Collections.emptyList()}
         });
     }
 }
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
index ba3b4ee..621ec8e 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/GherkinTestRunner.cs
@@ -41,7 +41,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
             new Dictionary<string, IgnoreReason>
             {
                 // Add here the name of scenarios to ignore and the reason, e.g.:
-                // { "g_V_peerPressure_byXclusterX_byXoutEXknowsXX_pageRankX1X_byXrankX_byXoutEXknowsXX_timesX2X_group_byXclusterX_byXrank_sumX_limitX100X", IgnoreReason.NoReason },
+                { "g_V_properties_propertiesXstartTimeX_drop", IgnoreReason.NoReason },
             };
         
         private static class Keywords
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 441a3fb..40d2518 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -31,6 +31,7 @@ regex_and = re.compile(r"([(.,\s])and\(")
 regex_as = re.compile(r"([(.,\s])as\(")
 regex_from = re.compile(r"([(.,\s])from\(")
 regex_global = re.compile(r"([(.,\s])global")
+regex_cardlist = re.compile(r"Cardinality\.list")
 regex_in = re.compile(r"([(.,\s])in\(")
 regex_is = re.compile(r"([(.,\s])is\(")
 regex_not = re.compile(r"([(.,\s])not\(")
@@ -237,6 +238,7 @@ def _table_assertion(data, result, ctx, ordered):
 def _translate(traversal_):
     replaced = traversal_.replace("\n", "")
     replaced = regex_all.sub(r"Pop.all_", replaced)
+    replaced = regex_cardlist.sub(r"Cardinality.list_", replaced)
     replaced = regex_and.sub(r"\1and_(", replaced)
     replaced = regex_from.sub(r"\1from_(", replaced)
     replaced = regex_global.sub(r"\1global_", replaced)
diff --git a/gremlin-test/features/filter/Drop.feature b/gremlin-test/features/filter/Drop.feature
index 753b377..144399e 100644
--- a/gremlin-test/features/filter/Drop.feature
+++ b/gremlin-test/features/filter/Drop.feature
@@ -60,4 +60,45 @@ Feature: Step - drop()
     When iterated to list
     Then the result should be empty
     And the graph should return 2 for count of "g.V()"
-    And the graph should return 0 for count of "g.V().properties()"
\ No newline at end of file
+    And the graph should return 0 for count of "g.V().properties()"
+
+  Scenario: g_E_propertiesXweightX_drop
+    Given the empty graph
+    And the graph initializer of
+      """
+      g.addV("person").property(T.id, 1).property("name", "marko").property("age", 29).as("marko").
+        addV("person").property(T.id, 2).property("name", "vadas").property("age", 27).as("vadas").
+        addV("software").property(T.id, 3).property("name", "lop").property("lang", "java").as("lop").
+        addV("person").property(T.id, 4).property("name","josh").property("age", 32).as("josh").
+        addV("software").property(T.id, 5).property("name", "ripple").property("lang", "java").as("ripple").
+        addV("person").property(T.id, 6).property("name", "peter").property("age", 35).as('peter').
+        addE("knows").from("marko").to("vadas").property(T.id, 7).property("weight", 0.5).
+        addE("knows").from("marko").to("josh").property(T.id, 8).property("weight", 1.0).
+        addE("created").from("marko").to("lop").property(T.id, 9).property("weight", 0.4).
+        addE("created").from("josh").to("ripple").property(T.id, 10).property("weight", 1.0).
+        addE("created").from("josh").to("lop").property(T.id, 11).property("weight", 0.4).
+        addE("created").from("peter").to("lop").property(T.id, 12).property("weight", 0.2)
+      """
+    And the traversal of
+      """
+      g.E().properties("weight").drop()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 0 for count of "g.E().properties()"
+
+  Scenario: g_V_properties_propertiesXstartTimeX_drop
+    Given the empty graph
+    And the graph initializer of
+      """
+      g.addV().property("name","bob").property(Cardinality.list, "location", "ny", "startTime", 2014, "endTime", 2016).property(Cardinality.list, "location", "va", "startTime", 2016).
+        addV().property("name","alice").property(Cardinality.list, "location", "va", "startTime", 2014, "endTime", 2016).property(Cardinality.list, "location", "ny", "startTime", 2016)
+      """
+    And the traversal of
+      """
+      g.V().properties().properties("startTime").drop()
+      """
+    When iterated to list
+    Then the result should be empty
+    And the graph should return 2 for count of "g.V().properties().properties()"
+    And the graph should return 0 for count of "g.V().properties().properties(\"startTime\")"
\ No newline at end of file
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DropTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DropTest.java
index f33997e..2b6a9ad 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DropTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/DropTest.java
@@ -26,12 +26,14 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.CREW;
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -48,6 +50,10 @@ public abstract class DropTest extends AbstractGremlinTest {
 
     public abstract Traversal<Vertex, VertexProperty> get_g_V_properties_drop();
 
+    public abstract Traversal<Vertex, ? extends Property<Object>> get_g_V_properties_propertiesXstartTimeX_drop();
+
+    public abstract Traversal<Edge, ? extends Property<Object>> get_g_E_propertiesXweightX_drop();
+
     @Test
     @LoadGraphWith(MODERN)
     @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_REMOVE_VERTICES)
@@ -82,6 +88,27 @@ public abstract class DropTest extends AbstractGremlinTest {
         g.V().forEachRemaining(vertex -> assertEquals(0, IteratorUtils.count(vertex.properties())));
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_REMOVE_PROPERTY)
+    public void g_E_propertiesXweightX_drop() {
+        final Traversal<Edge, ? extends Property<Object>> traversal = get_g_E_propertiesXweightX_drop();
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+        g.E().forEachRemaining(edge -> assertEquals(0, IteratorUtils.count(edge.properties())));
+    }
+
+
+    @Test
+    @LoadGraphWith(CREW)
+    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_REMOVE_PROPERTY)
+    public void g_V_properties_propertiesXstartTimeX_drop() {
+        final Traversal<Vertex, ? extends Property<Object>> traversal = get_g_V_properties_propertiesXstartTimeX_drop();
+        printTraversalForm(traversal);
+        assertFalse(traversal.hasNext());
+        g.V().forEachRemaining(vertex -> assertEquals(0, IteratorUtils.count(IteratorUtils.flatMap(vertex.properties("location"), vp -> vp.properties("startTime")))));
+    }
+
 
     public static class Traversals extends DropTest {
 
@@ -99,5 +126,15 @@ public abstract class DropTest extends AbstractGremlinTest {
         public Traversal<Vertex, VertexProperty> get_g_V_properties_drop() {
             return (Traversal) g.V().properties().drop();
         }
+
+        @Override
+        public Traversal<Edge, ? extends Property<Object>> get_g_E_propertiesXweightX_drop() {
+            return g.E().properties("weight").drop();
+        }
+
+        @Override
+        public Traversal<Vertex, ? extends Property<Object>> get_g_V_properties_propertiesXstartTimeX_drop() {
+            return g.V().properties().properties("startTime").drop();
+        }
     }
 }
\ No newline at end of file