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/05/27 11:48:39 UTC

[12/12] incubator-tinkerpop git commit: Merge branch 'tp31'

Merge branch 'tp31'

Resolved Conflicts:
	gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
	tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java


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

Branch: refs/heads/master
Commit: 0397f252f1c7c33922bf59fd59f97e22d37d83bd
Parents: 67fd4ee 5d38bbe
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Fri May 27 13:47:46 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:47:46 2016 +0200

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../optimization/RangeByIsCountStrategy.java    | 54 +++++++++++++--
 .../traversal/util/DefaultTraversal.java        |  5 +-
 .../RangeByIsCountStrategyTest.java             | 73 +++++++++-----------
 .../structure/TinkerGraphPlayTest.java          | 22 ++----
 5 files changed, 90 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0397f252/CHANGELOG.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0397f252/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --cc gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
index 5ea5668,977e4ac..fe24dee
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
@@@ -308,4 -310,5 +309,4 @@@ public class DefaultTraversal<S, E> imp
          }
          return result;
      }
- }
 -
+ }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0397f252/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 40ea53c,03d5176..0e9539d
--- 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
@@@ -19,12 -19,13 +19,10 @@@
  package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
  
  import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 -import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
  import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
  import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
- import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
  import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
- import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 -import org.junit.Before;
  import org.junit.Test;
 -import org.junit.experimental.runners.Enclosed;
  import org.junit.runner.RunWith;
  import org.junit.runners.Parameterized;
  
@@@ -48,60 -48,107 +43,56 @@@ 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 String name;
++    public Traversal original;
  
 -        @Parameterized.Parameters(name = "{0}")
 -        public static Iterable<Object[]> data() {
 -            return generateTestParameters();
 -        }
 +    @Parameterized.Parameter(value = 1)
-     public Object predicate;
- 
-     @Parameterized.Parameter(value = 2)
-     public long expectedHighRange;
++    public Traversal optimized;
  
-     public void applyRangeByIsCountStrategy(final Traversal traversal) {
 -        @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().setEngine(this.traversalEngine);
 +        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() {
-         final AtomicInteger counter = new AtomicInteger(0);
-         final Traversal traversal = __.out().count().is(predicate);
- 
-         applyRangeByIsCountStrategy(traversal);
- 
-         final List<RangeGlobalStep> steps = TraversalHelper.getStepsOfClass(RangeGlobalStep.class, traversal.asAdmin());
-         assertEquals(1, steps.size());
- 
-         steps.forEach(step -> {
-             assertEquals(0, step.getLowRange());
-             assertEquals(expectedHighRange, step.getHighRange());
-             counter.incrementAndGet();
-         });
- 
-         assertEquals(1, counter.intValue());
++        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()))},
 -            });
 -        }
 +    @Parameterized.Parameters(name = "{0}")
 +    public static Iterable<Object[]> generateTestParameters() {
 +
-         return Arrays.asList(new Object[][]{
-                 {"countEqualsNullShouldLimitToOne", eq(0l), 1l},
-                 {"countNotEqualsFourShouldLimitToFive", neq(4l), 5l},
-                 {"countLessThanOrEqualThreeShouldLimitToFour", lte(3l), 4l},
-                 {"countLessThanThreeShouldLimitToThree", lt(3l), 3l},
-                 {"countGreaterThanTwoShouldLimitToThree", gt(2l), 3l},
-                 {"countGreaterThanOrEqualTwoShouldLimitToTwo", gte(2l), 2l},
-                 {"countInsideTwoAndFourShouldLimitToFour", inside(2l, 4l), 4l},
-                 {"countOutsideTwoAndFourShouldLimitToFive", outside(2l, 4l), 5l},
-                 {"countWithinTwoSixFourShouldLimitToSeven", within(2l, 6l, 4l), 7l},
-                 {"countWithoutTwoSixFourShouldLimitToSix", without(2l, 6l, 4l), 6l}});
++        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()))},
++        });
      }
- }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0397f252/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --cc tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index 5557716,269f400..7097b1c
--- 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
@@@ -18,8 -18,8 +18,7 @@@
   */
  package org.apache.tinkerpop.gremlin.tinkergraph.structure;
  
- import org.apache.tinkerpop.gremlin.process.computer.bulkloading.BulkLoaderVertexProgram;
  import org.apache.tinkerpop.gremlin.process.traversal.Operator;
 -import org.apache.tinkerpop.gremlin.process.traversal.Order;
  import org.apache.tinkerpop.gremlin.process.traversal.P;
  import org.apache.tinkerpop.gremlin.process.traversal.Scope;
  import org.apache.tinkerpop.gremlin.process.traversal.Traversal;