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 3F20A200C29 for ; Tue, 28 Feb 2017 20:06:20 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3D95A160B81; Tue, 28 Feb 2017 19:06:20 +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 60F21160B59 for ; Tue, 28 Feb 2017 20:06:19 +0100 (CET) Received: (qmail 66883 invoked by uid 500); 28 Feb 2017 19:05:47 -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 66873 invoked by uid 99); 28 Feb 2017 19:05:47 -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, 28 Feb 2017 19:05:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 52B41DFDE6; Tue, 28 Feb 2017 19:05:47 +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 Date: Tue, 28 Feb 2017 19:05:47 -0000 Message-Id: <51b13196d94c45048cf63596528ff855@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/30] tinkerpop git commit: Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals. [Forced Update!] archived-at: Tue, 28 Feb 2017 19:06:20 -0000 Repository: tinkerpop Updated Branches: refs/heads/TINKERPOP-1640 2cf41f55e -> 1a2597b88 (forced update) Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/fe905dda Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fe905dda Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fe905dda Branch: refs/heads/TINKERPOP-1640 Commit: fe905dda7aaf7262a2e074c2b185a4248bc7f479 Parents: 1f11dd3 Author: Daniel Kuppitz Authored: Thu Feb 23 15:33:28 2017 +0100 Committer: Daniel Kuppitz Committed: Thu Feb 23 15:33:28 2017 +0100 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../optimization/RangeByIsCountStrategy.java | 43 ++++++++++++-------- .../RangeByIsCountStrategyTest.java | 9 ++-- 3 files changed, 32 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe905dda/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 871a4c9..498d227 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -31,6 +31,7 @@ TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET) * Refactor `SparkContext` handler to support external kill and stop operations. * Fixed an optimization bug in `LazyBarrierStrategy` around appending barriers to the end of a `Traversal`. * `TraverserIterator` in GremlinServer is smart to try and bulk traversers prior to network I/O. +* Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals. [[release-3-2-4]] TinkerPop 3.2.4 (Release Date: February 8, 2017) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe905dda/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java index efe7685..9dcb380 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java @@ -138,25 +138,34 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy filterStep = parent.asStep(); + final Traversal.Admin parentTraversal = filterStep.getTraversal(); + final Step notStep = new NotStep<>(parentTraversal, + traversal.getSteps().isEmpty() ? __.identity() : traversal); + filterStep.getLabels().forEach(notStep::addLabel); + TraversalHelper.replaceStep(filterStep, notStep, parentTraversal); } else { - inner = __.identity().asAdmin(); + final Traversal.Admin inner; + if (prev != null) { + inner = __.start().asAdmin(); + for (; ; ) { + final Step pp = prev.getPreviousStep(); + inner.addStep(0, prev); + if (pp instanceof EmptyStep || pp instanceof GraphStep || + !(prev instanceof FilterStep || prev instanceof SideEffectStep)) break; + traversal.removeStep(prev); + prev = pp; + size--; + } + } else { + inner = __.identity().asAdmin(); + } + if (prev != null) + TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal); + else + traversal.asAdmin().addStep(new NotStep<>(traversal, inner)); } - if (prev != null) - TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal); - else - traversal.asAdmin().addStep(new NotStep<>(traversal, inner)); } } else { TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal, 0L, highRange), curr, traversal); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe905dda/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java index 55eb840..8023e35 100644 --- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java +++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java @@ -75,15 +75,16 @@ public class RangeByIsCountStrategyTest { {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))}, {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))}, {__.flatMap(__.count().is(0)).as("a"), __.flatMap(__.count().is(0)).as("a")}, - {__.filter(__.count().is(0)).as("a"), __.filter(__.not(__.identity())).as("a")}, - {__.filter(__.count().is(0)), __.filter(__.not(__.identity()))}, + {__.filter(__.count().is(0)).as("a"), __.not(__.identity()).as("a")}, + {__.filter(__.count().is(0)), __.not(__.identity())}, {__.sideEffect(__.count().is(0)), __.sideEffect(__.not(__.identity()))}, {__.branch(__.count().is(0)), __.branch(__.limit(1).count().is(0))}, {__.count().is(0).store("x"), __.limit(1).count().is(0).store("x")}, {__.repeat(__.out()).until(__.outE().count().is(0)), __.repeat(__.out()).until(__.not(__.outE()))}, {__.repeat(__.out()).emit(__.outE().count().is(0)), __.repeat(__.out()).emit(__.not(__.outE()))}, - {__.where(__.outE().hasLabel("created").count().is(0)), __.where(__.not(__.outE().hasLabel("created")))}, - {__.where(__.out().outE().hasLabel("created").count().is(0)), __.where(__.out().not(__.outE().hasLabel("created")))}, + {__.where(__.outE().hasLabel("created").count().is(0)), __.not(__.outE().hasLabel("created"))}, + {__.where(__.out().outE().hasLabel("created").count().is(0)), __.not(__.out().outE().hasLabel("created"))}, + {__.where(__.out().outE().hasLabel("created").count().is(0).store("x")), __.where(__.out().outE().hasLabel("created").limit(1).count().is(0).store("x"))}, {__.filter(__.bothE().count().is(gt(0))), __.filter(__.bothE())}, {__.filter(__.bothE().count().is(gte(1))), __.filter(__.bothE())}, {__.filter(__.bothE().count().is(gt(1))), __.filter(__.bothE().limit(2).count().is(gt(1)))},