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 BCCF6200C4E for ; Thu, 6 Apr 2017 13:33:31 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BB8EC160BA8; Thu, 6 Apr 2017 11:33:31 +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 9409B160BB0 for ; Thu, 6 Apr 2017 13:33:30 +0200 (CEST) Received: (qmail 99201 invoked by uid 500); 6 Apr 2017 11:33:29 -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 98734 invoked by uid 99); 6 Apr 2017 11:33:29 -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; Thu, 06 Apr 2017 11:33:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DC9E7F2139; Thu, 6 Apr 2017 11:33:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: spmallette@apache.org To: commits@tinkerpop.apache.org Date: Thu, 06 Apr 2017 11:33:45 -0000 Message-Id: <7612f09f125c447eb2bb62020b928e0b@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [18/50] tinkerpop git commit: Add a slight optimization to ScopingStrategy that will not compute step labels if no Scoping steps are defined. Also added JavaDoc and comments accordingly. archived-at: Thu, 06 Apr 2017 11:33:31 -0000 Add a slight optimization to ScopingStrategy that will not compute step labels if no Scoping steps are defined. Also added JavaDoc and comments accordingly. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5711ee26 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5711ee26 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5711ee26 Branch: refs/heads/TINKERPOP-1443 Commit: 5711ee26c89f02896d404b47eebe7ca75ea71e94 Parents: b49c5be Author: Marko A. Rodriguez Authored: Mon Mar 6 08:07:39 2017 -0700 Committer: Stephen Mallette Committed: Wed Mar 29 11:20:44 2017 -0400 ---------------------------------------------------------------------- .../gremlin/process/traversal/step/Scoping.java | 5 +++++ .../strategy/finalization/ScopingStrategy.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5711ee26/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java index 68655e4..fae52d7 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/Scoping.java @@ -69,6 +69,11 @@ public interface Scoping { return null; } + /** + * Get the labels that this scoping step will access during the traversal + * + * @return the accessed labels of the scoping step + */ public Set getScopeKeys(); /** http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5711ee26/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java index ce66da4..073f45e 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/ScopingStrategy.java @@ -19,6 +19,7 @@ package org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization; +import org.apache.tinkerpop.gremlin.process.traversal.Step; import org.apache.tinkerpop.gremlin.process.traversal.Traversal; import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy; import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping; @@ -29,6 +30,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper; import java.util.Set; /** + * ScopingStrategy will analyze the traversal for step labels (e.g. as()) and provide {@link Scoping} steps that information. + * This enables Scoping steps to avoid having to generate step label data at {@link Step#getRequirements()} and thus, + * may significantly reduce compilation times. + * * @author Marko A. Rodriguez (http://markorodriguez.com) */ public final class ScopingStrategy extends AbstractTraversalStrategy implements TraversalStrategy.FinalizationStrategy { @@ -41,11 +46,14 @@ public final class ScopingStrategy extends AbstractTraversalStrategy traversal) { - // only operate on the root traversal and apply global step labels recursively - if (!(traversal.getParent() instanceof EmptyStep)) + // only operate on the root traversal and only if it contains scoping steps + if (!(traversal.getParent() instanceof EmptyStep) || + !TraversalHelper.hasStepOfAssignableClassRecursively(Scoping.class, traversal)) return; + // get the labels associated with the traveral final Set labels = TraversalHelper.getLabels(traversal); + // tell all scoping steps what those labels are for (final Scoping scoping : TraversalHelper.getStepsOfAssignableClassRecursively(Scoping.class, traversal)) { scoping.setPathLabels(labels); }