Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5E542200B53 for ; Tue, 12 Jul 2016 22:22:12 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5CD55160A56; Tue, 12 Jul 2016 20:22:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7A2C0160A53 for ; Tue, 12 Jul 2016 22:22:11 +0200 (CEST) Received: (qmail 37877 invoked by uid 500); 12 Jul 2016 20:22:10 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 37868 invoked by uid 99); 12 Jul 2016 20:22:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2016 20:22:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8B541DFF68; Tue, 12 Jul 2016 20:22:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: okram@apache.org To: commits@tinkerpop.apache.org Message-Id: <8af3ccc20a8241668fdc4d79610794ad@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) archived-at: Tue, 12 Jul 2016 20:22:12 -0000 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 Authored: Tue Jul 12 14:21:59 2016 -0600 Committer: Marko A. Rodriguez 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 extends ComputerAwareStep> } @Override - public void setKeepLabels(Set labels) { - this.keepLabels = labels; + public void setKeepLabels(final Set labels) { + this.keepLabels = new HashSet<>(labels); if (null != this.dedupLabels) this.keepLabels.addAll(this.dedupLabels); } @@ -360,12 +360,23 @@ public final class MatchStep extends ComputerAwareStep> 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 extends ComputerAwareStep> 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 extends ComputerAwareStep> private Traverser.Admin retractUnnecessaryLabels(final Traverser.Admin traverser) { if (null == this.parent.getKeepLabels()) return traverser; + final Set keepers = new HashSet<>(this.parent.getKeepLabels()); final Set 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()); } }