tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject tinkerpop git commit: found a happy medium -- if MatchStep.keepLabels contains both the matchStartLabels and matchEndLabels, then don't prune as it does nothing but incur runtime. This is a clean solution that ensures that full select()s are not pointles
Date Tue, 12 Jul 2016 20:22:10 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/master 8851987b8 -> 9242421e5


found a happy medium -- if MatchStep.keepLabels contains both the matchStartLabels and matchEndLabels,
then don't prune as it does nothing but incur runtime. This is a clean solution that ensures
that full select()s are not pointlessly inefficient and equal in speed to TinkerPop 3.2.0.
I think I'm done with this work for TinkerPop 3.2.0. I will run integration tests over night.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9242421e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9242421e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9242421e

Branch: refs/heads/master
Commit: 9242421e56b16db9164659bb582174bac6ae34af
Parents: 8851987
Author: Marko A. Rodriguez <okrammarko@gmail.com>
Authored: Tue Jul 12 14:21:59 2016 -0600
Committer: Marko A. Rodriguez <okrammarko@gmail.com>
Committed: Tue Jul 12 14:21:59 2016 -0600

----------------------------------------------------------------------
 .../process/traversal/step/map/MatchStep.java   | 20 ++++++++++++++++++--
 .../structure/TinkerGraphPlayTest.java          |  6 ++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9242421e/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
index a6804de..d829020 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchStep.java
@@ -181,8 +181,8 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S,
Map<String, E>>
     }
 
     @Override
-    public void setKeepLabels(Set<String> labels) {
-        this.keepLabels = labels;
+    public void setKeepLabels(final Set<String> labels) {
+        this.keepLabels = new HashSet<>(labels);
         if (null != this.dedupLabels)
             this.keepLabels.addAll(this.dedupLabels);
     }
@@ -360,12 +360,23 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S,
Map<String, E>>
             if (this.first) {
                 this.first = false;
                 this.initializeMatchAlgorithm(TraversalEngine.Type.STANDARD);
+                if (null != this.keepLabels &&
+                        this.keepLabels.containsAll(this.matchEndLabels) &&
+                        this.keepLabels.containsAll(this.matchStartLabels))
+                    this.keepLabels = null;
             } else { // TODO: if(standardAlgorithmBarrier.isEmpty()) -- leads to consistent
counts without retracting paths, but orders of magnitude slower.
+                boolean stop = false;
                 for (final Traversal.Admin<?, ?> matchTraversal : this.matchTraversals)
{
                     while (matchTraversal.hasNext() &&
                             this.standardAlgorithmBarrier.size() < PathRetractionStrategy.DEFAULT_STANDARD_BARRIER_SIZE)
{ // TODO: perhaps make MatchStep a LocalBarrierStep ??
                         this.standardAlgorithmBarrier.add(matchTraversal.getEndStep().next());
+                        if (null == this.keepLabels) {
+                            stop = true;
+                            break;
+                        }
                     }
+                    if (stop)
+                        break;
                 }
             }
             final Traverser.Admin traverser;
@@ -405,6 +416,10 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S,
Map<String, E>>
             if (this.first) {
                 this.first = false;
                 this.initializeMatchAlgorithm(TraversalEngine.Type.COMPUTER);
+                if (null != this.keepLabels &&
+                        this.keepLabels.containsAll(this.matchEndLabels) &&
+                        this.keepLabels.containsAll(this.matchStartLabels))
+                    this.keepLabels = null;
             }
             final Traverser.Admin traverser = this.starts.next();
             if (!traverser.getTags().contains(this.getId())) {
@@ -523,6 +538,7 @@ public final class MatchStep<S, E> extends ComputerAwareStep<S,
Map<String, E>>
         private <S> Traverser.Admin<S> retractUnnecessaryLabels(final Traverser.Admin<S>
traverser) {
             if (null == this.parent.getKeepLabels())
                 return traverser;
+
             final Set<String> keepers = new HashSet<>(this.parent.getKeepLabels());
             final Set<String> tags = traverser.getTags();
             for (final Traversal.Admin<?, ?> matchTraversal : this.parent.getGlobalChildren())
{ // get remaining traversal patterns for the traverser

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9242421e/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index abe6195..33a3d94 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.tinkerpop.gremlin.process.computer.Computer;
 import org.apache.tinkerpop.gremlin.process.traversal.Operator;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@@ -76,9 +77,10 @@ public class TinkerGraphPlayTest {
 
         for (final GraphTraversalSource source : Arrays.asList(d, c, b, a)) {
             System.out.println(source + "--PathRetractionStrategy[" + source.getStrategies().toList().contains(PathRetractionStrategy.instance())
+ "]");
-            System.out.println(source.V().match(
+            System.out.println(source.V().has("performances", P.gt(500)).match(
                     __.as("a").out().as("b"),
-                    __.as("a").in().as("c")).select("a").profile().next());
+                    __.as("b").out().as("c"),
+                    __.as("c").out().as("a")).select("a","b","c").profile().next());
         }
     }
 


Mime
View raw message