You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2016/09/15 18:10:05 UTC
[1/4] tinkerpop git commit: Enclose filter steps and side-effect
steps in `RangeByIsCountStrategy` when `NotStep` is used to wrap part of the
traversal.
Repository: tinkerpop
Updated Branches:
refs/heads/master 687ae742d -> 3a4f70510
Enclose filter steps and side-effect steps in `RangeByIsCountStrategy` when `NotStep` is used to wrap part of the traversal.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/61aaaf3e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/61aaaf3e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/61aaaf3e
Branch: refs/heads/master
Commit: 61aaaf3ea82d7481aff1adf2951e7347506b184c
Parents: 7fa75fd
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Mon Sep 12 19:21:19 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Mon Sep 12 19:21:19 2016 +0200
----------------------------------------------------------------------
.../optimization/RangeByIsCountStrategy.java | 20 +++++++++++++++++---
.../RangeByIsCountStrategyTest.java | 2 ++
2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/61aaaf3e/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 451d561..6957abe 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
@@ -32,6 +32,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -130,12 +131,25 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
traversal.asAdmin().removeStep(next); // IsStep
traversal.asAdmin().removeStep(curr); // CountStep
size -= 2;
+ 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) {
- final Traversal.Admin inner = __.start().asAdmin();
- TraversalHelper.insertAfterStep(prev, inner.getStartStep(), inner);
TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal);
} else {
- traversal.asAdmin().addStep(new NotStep<>(traversal, __.identity()));
+ 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/61aaaf3e/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 03d5176..a48c0f0 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
@@ -148,6 +148,8 @@ public class RangeByIsCountStrategyTest {
{__.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")))},
});
}
}
[4/4] tinkerpop git commit: Merge branch 'TINKERPOP-1391-master'
Posted by dk...@apache.org.
Merge branch 'TINKERPOP-1391-master'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3a4f7051
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3a4f7051
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3a4f7051
Branch: refs/heads/master
Commit: 3a4f70510b8b2a536748f3f5d85b824e23431d37
Parents: 687ae74 eeb218c
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu Sep 15 20:09:23 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Thu Sep 15 20:09:23 2016 +0200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 3 ++-
.../optimization/RangeByIsCountStrategy.java | 20 +++++++++++++++++---
.../RangeByIsCountStrategyTest.java | 2 ++
3 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3a4f7051/CHANGELOG.asciidoc
----------------------------------------------------------------------
[2/4] tinkerpop git commit: Updated CHANGELOG
Posted by dk...@apache.org.
Updated CHANGELOG
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5ff97ef4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5ff97ef4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5ff97ef4
Branch: refs/heads/master
Commit: 5ff97ef41135d1e96552265f5e3519bf044109f2
Parents: 61aaaf3
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Tue Sep 13 02:01:17 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue Sep 13 02:01:17 2016 +0200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5ff97ef4/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 6e43233..f01966d 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.1.5 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Fixed a bug in `RangeByIsCountStrategy` which didn't use the `NotStep` properly.
[[release-3-1-4]]
[3/4] tinkerpop git commit: Merge branch 'TINKERPOP-1391' into
TINKERPOP-1391-master
Posted by dk...@apache.org.
Merge branch 'TINKERPOP-1391' into TINKERPOP-1391-master
Resolved Conflicts:
CHANGELOG.asciidoc
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/eeb218c4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/eeb218c4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/eeb218c4
Branch: refs/heads/master
Commit: eeb218c48b1f40734ec25f6fe257f27b8792f42e
Parents: 2492a3a 5ff97ef
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Tue Sep 13 16:35:58 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue Sep 13 16:35:58 2016 +0200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 3 ++-
.../optimization/RangeByIsCountStrategy.java | 20 +++++++++++++++++---
.../RangeByIsCountStrategyTest.java | 2 ++
3 files changed, 21 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eeb218c4/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 7035b5e,f01966d..506b3a9
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -390,8 -26,9 +390,9 @@@ image::https://raw.githubusercontent.co
TinkerPop 3.1.5 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- + Removed the `appveyor.yml` file as the AppVeyor build is no longer enabled by Apache Infrastructure.
++* Removed the `appveyor.yml` file as the AppVeyor build is no longer enabled by Apache Infrastructure.
+ * Fixed a bug in `RangeByIsCountStrategy` which didn't use the `NotStep` properly.
-
[[release-3-1-4]]
TinkerPop 3.1.4 (Release Date: September 6, 2016)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eeb218c4/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
index 0e9539d,a48c0f0..99d2f75
--- 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
@@@ -43,56 -48,109 +43,58 @@@ import static org.junit.Assert.assertEq
* @author Daniel Kuppitz (http://gremlin.guru)
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
-@RunWith(Enclosed.class)
+@RunWith(Parameterized.class)
public class RangeByIsCountStrategyTest {
- @RunWith(Parameterized.class)
- public static class StandardTest extends AbstractRangeByIsCountStrategyTest {
+ @Parameterized.Parameter(value = 0)
+ public Traversal original;
- @Parameterized.Parameters(name = "{0}")
- public static Iterable<Object[]> data() {
- return generateTestParameters();
- }
+ @Parameterized.Parameter(value = 1)
+ public Traversal optimized;
- @Parameterized.Parameter(value = 0)
- public Traversal original;
-
- @Parameterized.Parameter(value = 1)
- public Traversal optimized;
-
- @Before
- public void setup() {
- this.traversalEngine = mock(TraversalEngine.class);
- when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.STANDARD);
- }
-
- @Test
- public void shouldApplyStrategy() {
- doTest(original, optimized);
- }
+ void applyRangeByIsCountStrategy(final Traversal traversal) {
+ final TraversalStrategies strategies = new DefaultTraversalStrategies();
+ strategies.addStrategies(RangeByIsCountStrategy.instance());
+ traversal.asAdmin().setStrategies(strategies);
+ traversal.asAdmin().applyStrategies();
}
- @RunWith(Parameterized.class)
- public static class ComputerTest extends AbstractRangeByIsCountStrategyTest {
-
- @Parameterized.Parameters(name = "{0}")
- public static Iterable<Object[]> data() {
- return generateTestParameters();
- }
-
- @Parameterized.Parameter(value = 0)
- public Traversal original;
-
- @Parameterized.Parameter(value = 1)
- public Traversal optimized;
-
- @Before
- public void setup() {
- this.traversalEngine = mock(TraversalEngine.class);
- when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.COMPUTER);
- }
-
- @Test
- public void shouldApplyStrategy() {
- doTest(original, optimized);
- }
+ @Test
+ public void doTest() {
+ applyRangeByIsCountStrategy(original);
+ assertEquals(optimized, original);
}
- private static abstract class AbstractRangeByIsCountStrategyTest {
-
- protected TraversalEngine traversalEngine;
-
- void applyRangeByIsCountStrategy(final Traversal traversal) {
- final TraversalStrategies strategies = new DefaultTraversalStrategies();
- strategies.addStrategies(RangeByIsCountStrategy.instance());
-
- traversal.asAdmin().setStrategies(strategies);
- traversal.asAdmin().setEngine(this.traversalEngine);
- traversal.asAdmin().applyStrategies();
- }
-
- public void doTest(final Traversal traversal, final Traversal optimized) {
- applyRangeByIsCountStrategy(traversal);
- assertEquals(optimized, traversal);
- }
-
- static Iterable<Object[]> generateTestParameters() {
-
- return Arrays.asList(new Traversal[][]{
- {__.count().is(0), __.not(__.identity())},
- {__.count().is(1), __.limit(2).count().is(1)},
- {__.out().count().is(0), __.not(__.out())},
- {__.outE().count().is(lt(1)), __.not(__.outE())},
- {__.both().count().is(lte(0)), __.not(__.both())},
- {__.store("x").count().is(0).as("a"), __.store("x").limit(1).count().is(0).as("a")},
- {__.out().count().as("a").is(0), __.out().limit(1).count().as("a").is(0)},
- {__.out().count().is(neq(4)), __.out().limit(5).count().is(neq(4))},
- {__.out().count().is(lte(3)), __.out().limit(4).count().is(lte(3))},
- {__.out().count().is(lt(3)), __.out().limit(3).count().is(lt(3))},
- {__.out().count().is(gt(2)), __.out().limit(3).count().is(gt(2))},
- {__.out().count().is(gte(2)), __.out().limit(2).count().is(gte(2))},
- {__.out().count().is(inside(2, 4)), __.out().limit(4).count().is(inside(2, 4))},
- {__.out().count().is(outside(2, 4)), __.out().limit(5).count().is(outside(2, 4))},
- {__.out().count().is(within(2, 6, 4)), __.out().limit(7).count().is(within(2, 6, 4))},
- {__.out().count().is(without(2, 6, 4)), __.out().limit(6).count().is(without(2, 6, 4))},
- {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))},
- {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))},
- {__.filter(__.count().is(0)), __.filter(__.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")))},
- });
- }
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<Object[]> generateTestParameters() {
+
+ return Arrays.asList(new Traversal[][]{
+ {__.count().is(0), __.not(__.identity())},
+ {__.count().is(1), __.limit(2).count().is(1)},
+ {__.out().count().is(0), __.not(__.out())},
+ {__.outE().count().is(lt(1)), __.not(__.outE())},
+ {__.both().count().is(lte(0)), __.not(__.both())},
+ {__.store("x").count().is(0).as("a"), __.store("x").limit(1).count().is(0).as("a")},
+ {__.out().count().as("a").is(0), __.out().limit(1).count().as("a").is(0)},
+ {__.out().count().is(neq(4)), __.out().limit(5).count().is(neq(4))},
+ {__.out().count().is(lte(3)), __.out().limit(4).count().is(lte(3))},
+ {__.out().count().is(lt(3)), __.out().limit(3).count().is(lt(3))},
+ {__.out().count().is(gt(2)), __.out().limit(3).count().is(gt(2))},
+ {__.out().count().is(gte(2)), __.out().limit(2).count().is(gte(2))},
+ {__.out().count().is(inside(2, 4)), __.out().limit(4).count().is(inside(2, 4))},
+ {__.out().count().is(outside(2, 4)), __.out().limit(5).count().is(outside(2, 4))},
+ {__.out().count().is(within(2, 6, 4)), __.out().limit(7).count().is(within(2, 6, 4))},
+ {__.out().count().is(without(2, 6, 4)), __.out().limit(6).count().is(without(2, 6, 4))},
+ {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))},
+ {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))},
+ {__.filter(__.count().is(0)), __.filter(__.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")))},
+ });
}
}