You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/10/06 21:40:24 UTC
[1/4] tinkerpop git commit: LazyBarrierStrategy is now a default
strategy and is smart about labels, retractions, flatMaps, barriers,
etc. In short,
all the queries that were given to it are either equal in speed or faster.
Repository: tinkerpop
Updated Branches:
refs/heads/master c1206f04d -> 3caa2a99a
LazyBarrierStrategy is now a default strategy and is smart about labels, retractions, flatMaps, barriers, etc. In short, all the queries that were given to it are either equal in speed or faster.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5f0e8438
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5f0e8438
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5f0e8438
Branch: refs/heads/master
Commit: 5f0e8438c92555b79e7387c10a9ce915b29c8840
Parents: 8ab682f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Oct 4 16:50:48 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Oct 4 16:50:48 2016 -0600
----------------------------------------------------------------------
.../process/traversal/TraversalStrategies.java | 3 +-
.../finalization/LazyBarrierStrategy.java | 108 -------------------
.../optimization/LazyBarrierStrategy.java | 103 ++++++++++++++++++
.../tinkerpop/gremlin/util/CoreImports.java | 2 +-
.../finalization/LazyBarrierStrategyTest.java | 74 -------------
.../optimization/LazyBarrierStrategyTest.java | 101 +++++++++++++++++
.../process/traversal/step/map/ProfileTest.java | 38 +++++--
7 files changed, 234 insertions(+), 195 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
index a01eef6..407d16e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java
@@ -24,9 +24,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.Connec
import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.FilterRankingStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IdentityRemovalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.IncidentToAdjacentStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.InlineFilterStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.MatchPredicateStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.OrderLimitStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.PathProcessorStrategy;
@@ -211,6 +211,7 @@ public interface TraversalStrategies extends Serializable, Cloneable {
RepeatUnrollStrategy.instance(),
RangeByIsCountStrategy.instance(),
PathRetractionStrategy.instance(),
+ LazyBarrierStrategy.instance(),
ProfileStrategy.instance(),
StandardVerificationStrategy.instance());
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java
deleted file mode 100644
index 9bc3cdf..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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.Barrier;
-import org.apache.tinkerpop.gremlin.process.traversal.step.HasContainerHolder;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class LazyBarrierStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy> implements TraversalStrategy.FinalizationStrategy {
-
- private static final LazyBarrierStrategy INSTANCE = new LazyBarrierStrategy();
- private static final Set<Class<? extends FinalizationStrategy>> PRIORS = new HashSet<>();
- private static final Set<Class<? extends FinalizationStrategy>> POSTS = new HashSet<>();
-
- private static final int REQUIRED_DEPTH = 2;
- private static final int BIG_START_SIZE = 5;
- protected static final int MAX_BARRIER_SIZE = 10000;
-
- static {
- POSTS.add(ProfileStrategy.class);
- }
-
-
- private LazyBarrierStrategy() {
- }
-
- @Override
- public void apply(final Traversal.Admin<?, ?> traversal) {
- if (TraversalHelper.onGraphComputer(traversal))
- return;
-
- if (traversal.getTraverserRequirements().contains(TraverserRequirement.PATH))
- return;
-
- int depth = 0;
- for (final Step<?, ?> step : traversal.getSteps()) {
- if (step instanceof VertexStep)
- depth++;
- }
-
- if (depth > REQUIRED_DEPTH) {
- boolean bigStart = false;
- char foundVertexStep = 'x';
- for (int i = 0; i < traversal.getSteps().size() - 1; i++) {
- final Step<?, ?> step = traversal.getSteps().get(i);
- if (i == 0)
- bigStart = step instanceof GraphStep && (((GraphStep) step).getIds().length >= BIG_START_SIZE || (((GraphStep) step).getIds().length == 0 && step instanceof HasContainerHolder && ((HasContainerHolder) step).getHasContainers().isEmpty()));
- else if ('v' == foundVertexStep || bigStart) {
- if (!(step instanceof FilterStep) && !(step instanceof Barrier) && !(step instanceof VertexStep && ((VertexStep) step).returnsEdge())) {
- TraversalHelper.insertAfterStep(new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE), step, traversal);
- }
- }
-
- if ('x' == foundVertexStep && step instanceof VertexStep)
- foundVertexStep = ((VertexStep) step).returnsVertex() ? 'v' : 'e';
- else if ('e' == foundVertexStep && step instanceof EdgeVertexStep)
- foundVertexStep = 'v';
- }
- }
- }
-
-
- @Override
- public Set<Class<? extends FinalizationStrategy>> applyPrior() {
- return PRIORS;
- }
-
- @Override
- public Set<Class<? extends FinalizationStrategy>> applyPost() {
- return POSTS;
- }
-
- public static LazyBarrierStrategy instance() {
- return INSTANCE;
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
new file mode 100644
index 0000000..f6f9021
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
+
+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.Barrier;
+import org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class LazyBarrierStrategy extends AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy> implements TraversalStrategy.OptimizationStrategy {
+
+ private static final LazyBarrierStrategy INSTANCE = new LazyBarrierStrategy();
+ private static final Set<Class<? extends OptimizationStrategy>> PRIORS = new HashSet<>(Arrays.asList(
+ RangeByIsCountStrategy.class,
+ PathRetractionStrategy.class,
+ IncidentToAdjacentStrategy.class,
+ AdjacentToIncidentStrategy.class,
+ FilterRankingStrategy.class,
+ InlineFilterStrategy.class,
+ MatchPredicateStrategy.class));
+
+ private static final int BIG_START_SIZE = 5;
+ protected static final int MAX_BARRIER_SIZE = 10000;
+
+ private LazyBarrierStrategy() {
+ }
+
+ @Override
+ public void apply(final Traversal.Admin<?, ?> traversal) {
+ if (TraversalHelper.onGraphComputer(traversal) ||
+ traversal.getTraverserRequirements().contains(TraverserRequirement.PATH))
+ return;
+
+ boolean foundFlatMap = false;
+ boolean labeledPath = false;
+ for (int i = 0; i < traversal.getSteps().size() - 1; i++) {
+ final Step<?, ?> step = traversal.getSteps().get(i);
+
+ if (step instanceof PathProcessor) {
+ final Set<String> keepLabels = ((PathProcessor) step).getKeepLabels();
+ if (null == keepLabels || keepLabels.isEmpty())
+ labeledPath = false;
+ }
+ if (step instanceof FlatMapStep &&
+ !(step instanceof VertexStep && ((VertexStep) step).returnsEdge()) ||
+ (step instanceof GraphStep &&
+ (((GraphStep) step).getIds().length >= BIG_START_SIZE ||
+ (((GraphStep) step).getIds().length == 0 && !(step.getNextStep() instanceof HasStep))))) {
+ if (foundFlatMap && !labeledPath && !(step.getNextStep() instanceof Barrier)) {
+ final Step noOpBarrierStep = new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE);
+ TraversalHelper.copyLabels(step, noOpBarrierStep, true);
+ TraversalHelper.insertAfterStep(noOpBarrierStep, step, traversal);
+ } else
+ foundFlatMap = true;
+ }
+ if (!step.getLabels().isEmpty())
+ labeledPath = true;
+
+ }
+ }
+
+
+ @Override
+ public Set<Class<? extends OptimizationStrategy>> applyPrior() {
+ return PRIORS;
+ }
+
+ public static LazyBarrierStrategy instance() {
+ return INSTANCE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
index 6dd1164..1c76f0e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/CoreImports.java
@@ -50,7 +50,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventS
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.LazyBarrierStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.MatchAlgorithmStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.AdjacentToIncidentStrategy;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategyTest.java
deleted file mode 100644
index 97f8c7f..0000000
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategyTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-@RunWith(Parameterized.class)
-public class LazyBarrierStrategyTest {
-
- @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;
-
- void applyAdjacentToIncidentStrategy(final Traversal traversal) {
- final TraversalStrategies strategies = new DefaultTraversalStrategies();
- strategies.addStrategies(LazyBarrierStrategy.instance());
- traversal.asAdmin().setStrategies(strategies);
- traversal.asAdmin().applyStrategies();
- }
-
- @Test
- public void doTest() {
- applyAdjacentToIncidentStrategy(original);
- assertEquals(optimized, original);
- }
-
- @Parameterized.Parameters(name = "{0}")
- public static Iterable<Object[]> generateTestParameters() {
- final int size = LazyBarrierStrategy.MAX_BARRIER_SIZE;
- return Arrays.asList(new Traversal[][]{
- {__.out().count(), __.out().count()},
- {__.out().out().count(), __.out().out().count()},
- {__.out().out().out().count(), __.out().out().barrier(size).out().barrier(size).count()},
- {__.outE().inV().outE().inV().outE().inV().groupCount(), __.outE().inV().outE().inV().barrier(size).outE().inV().barrier(size).groupCount()},
- {__.out().out().has("age", 32).out().count(), __.out().out().barrier(size).has("age", 32).out().barrier(size).count()},
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
new file mode 100644
index 0000000..314cfeb
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
+
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(Parameterized.class)
+public class LazyBarrierStrategyTest {
+
+ @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;
+
+ @Parameterized.Parameter(value = 2)
+ public Collection<TraversalStrategy> otherStrategies;
+
+ @Test
+ public void doTest() {
+ final TraversalStrategies strategies = new DefaultTraversalStrategies();
+ strategies.addStrategies(LazyBarrierStrategy.instance());
+ for (final TraversalStrategy strategy : this.otherStrategies) {
+ strategies.addStrategies(strategy);
+ }
+ this.original.asAdmin().setStrategies(strategies);
+ this.original.asAdmin().applyStrategies();
+ assertEquals(this.optimized, this.original);
+ }
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<Object[]> generateTestParameters() {
+ final int SIZE = LazyBarrierStrategy.MAX_BARRIER_SIZE;
+ return Arrays.asList(new Object[][]{
+ {__.out().count(), __.out().count(), Collections.emptyList()},
+ {__.out().out().count(), __.out().out().count(), Collections.emptyList()},
+ {__.out().out().out().count(), __.out().out().barrier(SIZE).out().count(), Collections.emptyList()},
+ {__.out().out().out().out().count(), __.out().out().barrier(SIZE).out().barrier(SIZE).out().count(), Collections.emptyList()},
+ {__.out().out().out().count(), __.out().out().barrier(SIZE).outE().count(), Arrays.asList(RangeByIsCountStrategy.instance(), AdjacentToIncidentStrategy.instance())},
+ {__.out().out().out().count().is(P.gt(10)), __.out().out().barrier(SIZE).outE().limit(11).count().is(P.gt(10)), Arrays.asList(RangeByIsCountStrategy.instance(), AdjacentToIncidentStrategy.instance())},
+ {__.outE().inV().outE().inV().outE().inV().groupCount(), __.outE().inV().outE().inV().barrier(SIZE).outE().inV().groupCount(), Collections.emptyList()},
+ {__.outE().inV().outE().inV().outE().inV().groupCount(), __.out().out().barrier(SIZE).out().groupCount(), Collections.singletonList(IncidentToAdjacentStrategy.instance())},
+ {__.out().out().has("age", 32).out().count(), __.out().out().barrier(SIZE).has("age", 32).out().count(), Collections.emptyList()},
+ {__.V().out().out().has("age", 32).out().count(), __.V().out().barrier(SIZE).out().barrier(SIZE).has("age", 32).out().count(), Collections.emptyList()},
+ {__.V().out().has("age", 32).out().count(), __.V().out().barrier(SIZE).has("age", 32).out().count(), Collections.emptyList()},
+ {__.V().out().has("age", 32).V().out().count(), __.V().out().barrier(SIZE).has("age", 32).V().barrier(SIZE).out().count(), Collections.emptyList()},
+ {__.repeat(__.out()).times(4), __.repeat(__.out()).times(4), Collections.emptyList()},
+ {__.repeat(__.out()).times(4), __.out().barrier(5000).out().barrier(5000).out().barrier(5000).out().barrier(5000), Collections.singletonList(RepeatUnrollStrategy.instance())},
+ {__.out().out().as("a").select("a").out(), __.out().out().barrier(SIZE).as("a").select("a").out(), Collections.emptyList()},
+ {__.out().out().as("a").select("a").out(), __.out().out().barrier(SIZE).as("a").select("a").barrier(2500).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ {__.out().out().as("a").out().select("a").out(), __.out().out().barrier(SIZE).as("a").out().select("a").barrier(2500).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ {__.out().out().out().limit(10).out(), __.out().out().barrier(SIZE).out().limit(10).out(), Collections.emptyList()},
+ {__.V().out().in().where(P.neq("a")), __.V().out().barrier(SIZE).in().barrier(SIZE).where(P.neq("a")), Collections.emptyList()},
+ {__.V().as("a").out().in().where(P.neq("a")), __.V().as("a").out().in().where(P.neq("a")), Collections.emptyList()},
+ {__.out().out().in().where(P.neq("a")), __.out().out().barrier(SIZE).in().barrier(SIZE).where(P.neq("a")), Collections.emptyList()},
+ {__.out().as("a").out().in().where(P.neq("a")), __.out().as("a").out().in().where(P.neq("a")), Collections.emptyList()},
+ {__.out().as("a").out().in().where(P.neq("a")).out().out(), __.out().as("a").out().in().where(P.neq("a")).barrier(2500).out().barrier(SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ {__.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(2500).out().barrier(SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(2500).out().select("b").barrier(2500).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ {__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(2500).out().select("b").barrier(2500).out().barrier(SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5f0e8438/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
index 548e7ab..927f91d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
@@ -32,6 +32,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.step.Profiling;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RangeByIsCountStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
@@ -92,6 +93,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void modern_V_out_out_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_out_out_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
validate_g_V_out_out_profile_modern(traversal, traversal.next());
}
@@ -100,6 +102,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void modern_V_out_out_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_out_out_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
validate_g_V_out_out_profile_modern(traversal, traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY));
@@ -135,6 +138,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(GRATEFUL)
public void grateful_V_out_out_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_out_out_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
final TraversalMetrics traversalMetrics = traversal.next();
validate_g_V_out_out_profile_grateful(traversalMetrics);
@@ -144,6 +148,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(GRATEFUL)
public void grateful_V_out_out_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_out_out_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
@@ -185,6 +190,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
TraversalMetrics traversalMetrics = traversal.next();
assertEquals("There should be 8 steps in this traversal (counting injected profile steps).", 8, traversal.asAdmin().getSteps().size());
@@ -196,6 +202,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
assertEquals("There should be 7 steps in this traversal (counting injected profile steps).", 7, traversal.asAdmin().getSteps().size());
@@ -230,6 +237,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_repeat_both_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_repeatXbothX_timesX3X_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
final TraversalMetrics traversalMetrics = traversal.next();
@@ -242,6 +250,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_repeat_both_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_repeatXbothX_timesX3X_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
@@ -307,6 +316,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_whereXinXcreatedX_count_isX1XX_name_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_whereXinXcreatedX_count_isX1XX_name_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
final TraversalMetrics traversalMetrics = traversal.next();
validate_g_V_whereXinXcreatedX_count_isX1XX_name_profile(traversal, traversalMetrics);
@@ -316,6 +326,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_whereXinXcreatedX_count_isX1XX_name_profileXmetricsX() {
final Traversal<Vertex, String> traversal = get_g_V_whereXinXcreatedX_count_isX1XX_name_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
@@ -353,13 +364,14 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@Test
@LoadGraphWith(MODERN)
public void testProfileStrategyCallback() {
- final Traversal<Vertex, TraversalMetrics> t = get_g_V_out_out_profile();
- MockStep mockStep = new MockStep(t.asAdmin());
- t.asAdmin().addStep(3, mockStep);
- TraversalMetrics traversalMetrics = t.next();
+ final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_out_out_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
+ MockStep mockStep = new MockStep(traversal.asAdmin());
+ traversal.asAdmin().addStep(3, mockStep);
+ TraversalMetrics traversalMetrics = traversal.next();
assertTrue(mockStep.callbackCalled);
- if (!onGraphComputer(t.asAdmin())) {
+ if (!onGraphComputer(traversal.asAdmin())) {
assertEquals(100, traversalMetrics.getMetrics(3).getCount("bogusCount").longValue());
}
}
@@ -367,14 +379,15 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@Test
@LoadGraphWith(MODERN)
public void testProfileStrategyCallbackSideEffect() {
- final Traversal<Vertex, Vertex> t = get_g_V_out_out_profileXmetricsX();
- MockStep mockStep = new MockStep(t.asAdmin());
- t.asAdmin().addStep(3, mockStep);
- t.iterate();
+ final Traversal<Vertex, Vertex> traversal = get_g_V_out_out_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
+ MockStep mockStep = new MockStep(traversal.asAdmin());
+ traversal.asAdmin().addStep(3, mockStep);
+ traversal.iterate();
assertTrue(mockStep.callbackCalled);
- if (!onGraphComputer(t.asAdmin())) {
- final TraversalMetrics traversalMetrics = t.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
+ if (!onGraphComputer(traversal.asAdmin())) {
+ final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
assertEquals(100, traversalMetrics.getMetrics(3).getCount("bogusCount").longValue());
}
}
@@ -383,6 +396,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
}
@@ -391,6 +405,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profileXmetricsX() {
final Traversal<Vertex, Map<String, String>> traversal = get_g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profileXmetricsX();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
}
@@ -400,6 +415,7 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@IgnoreEngine(TraversalEngine.Type.STANDARD)
public void g_V_hasLabelXpersonX_pageRank_byXrankX_byXbothEX_rank_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_hasLabelXpersonX_pageRank_byXrankX_byXbothEX_rank_profile();
+ traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
//printTraversalForm(traversal);
try {
traversal.iterate();
[3/4] tinkerpop git commit: added back a Deprecated version of
LazyBarrierStrategy that is a finalization. Updated CHANGELOG.
Posted by ok...@apache.org.
added back a Deprecated version of LazyBarrierStrategy that is a finalization. Updated CHANGELOG.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/aa3cd937
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/aa3cd937
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/aa3cd937
Branch: refs/heads/master
Commit: aa3cd937bd8100e3dc9fce131b131ac2c9d9d35b
Parents: 658630a
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Oct 6 12:37:48 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Oct 6 12:37:48 2016 -0600
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../finalization/LazyBarrierStrategy.java | 111 +++++++++++++++++++
2 files changed, 112 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa3cd937/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index dc2b03b..6a21b7d 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.2.3 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* A new version of `LazyBarrierStrategy` has been created and added to the default strategies.
* `FilterRankStrategy` now propagates labels "right" over non-`Scoping` filters.
* Fixed a bug in `ConnectiveP` where nested equivalent connectives should be inlined.
* Fixed a bug in `IncidentToAdjacentStrategy` where `TreeStep` traversals were allowed.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aa3cd937/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java
new file mode 100644
index 0000000..4a89b1b
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/finalization/LazyBarrierStrategy.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+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.Barrier;
+import org.apache.tinkerpop.gremlin.process.traversal.step.HasContainerHolder;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.EdgeVertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @deprecated As of release 3.2.3. Please use {@link org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy}.
+ */
+@Deprecated
+public final class LazyBarrierStrategy extends AbstractTraversalStrategy<TraversalStrategy.FinalizationStrategy> implements TraversalStrategy.FinalizationStrategy {
+
+ private static final LazyBarrierStrategy INSTANCE = new LazyBarrierStrategy();
+ private static final Set<Class<? extends FinalizationStrategy>> PRIORS = new HashSet<>();
+ private static final Set<Class<? extends FinalizationStrategy>> POSTS = new HashSet<>();
+
+ private static final int REQUIRED_DEPTH = 2;
+ private static final int BIG_START_SIZE = 5;
+ protected static final int MAX_BARRIER_SIZE = 10000;
+
+ static {
+ POSTS.add(ProfileStrategy.class);
+ }
+
+
+ private LazyBarrierStrategy() {
+ }
+
+ @Override
+ public void apply(final Traversal.Admin<?, ?> traversal) {
+ if (TraversalHelper.onGraphComputer(traversal))
+ return;
+
+ if (traversal.getTraverserRequirements().contains(TraverserRequirement.PATH))
+ return;
+
+ int depth = 0;
+ for (final Step<?, ?> step : traversal.getSteps()) {
+ if (step instanceof VertexStep)
+ depth++;
+ }
+
+ if (depth > REQUIRED_DEPTH) {
+ boolean bigStart = false;
+ char foundVertexStep = 'x';
+ for (int i = 0; i < traversal.getSteps().size() - 1; i++) {
+ final Step<?, ?> step = traversal.getSteps().get(i);
+ if (i == 0)
+ bigStart = step instanceof GraphStep && (((GraphStep) step).getIds().length >= BIG_START_SIZE || (((GraphStep) step).getIds().length == 0 && step instanceof HasContainerHolder && ((HasContainerHolder) step).getHasContainers().isEmpty()));
+ else if ('v' == foundVertexStep || bigStart) {
+ if (!(step instanceof FilterStep) && !(step instanceof Barrier) && !(step instanceof VertexStep && ((VertexStep) step).returnsEdge())) {
+ TraversalHelper.insertAfterStep(new NoOpBarrierStep<>(traversal, MAX_BARRIER_SIZE), step, traversal);
+ }
+ }
+
+ if ('x' == foundVertexStep && step instanceof VertexStep)
+ foundVertexStep = ((VertexStep) step).returnsVertex() ? 'v' : 'e';
+ else if ('e' == foundVertexStep && step instanceof EdgeVertexStep)
+ foundVertexStep = 'v';
+ }
+ }
+ }
+
+
+ @Override
+ public Set<Class<? extends FinalizationStrategy>> applyPrior() {
+ return PRIORS;
+ }
+
+ @Override
+ public Set<Class<? extends FinalizationStrategy>> applyPost() {
+ return POSTS;
+ }
+
+ public static LazyBarrierStrategy instance() {
+ return INSTANCE;
+ }
+}
[4/4] tinkerpop git commit: Merge branch 'TINKERPOP-1488'
Posted by ok...@apache.org.
Merge branch 'TINKERPOP-1488'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3caa2a99
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3caa2a99
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3caa2a99
Branch: refs/heads/master
Commit: 3caa2a99a9bbc2ead5561cd3554d82ea78e5d76f
Parents: c1206f0 aa3cd93
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Oct 6 15:40:15 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Oct 6 15:40:15 2016 -0600
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../process/traversal/TraversalStrategies.java | 3 +-
.../finalization/LazyBarrierStrategy.java | 31 +++---
.../optimization/LazyBarrierStrategy.java | 108 +++++++++++++++++++
.../tinkerpop/gremlin/util/CoreImports.java | 2 +-
.../finalization/LazyBarrierStrategyTest.java | 74 -------------
.../optimization/LazyBarrierStrategyTest.java | 102 ++++++++++++++++++
7 files changed, 231 insertions(+), 90 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3caa2a99/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --cc CHANGELOG.asciidoc
index 6826ca8,6a21b7d..cda6d8c
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@@ -26,16 -26,7 +26,17 @@@ image::https://raw.githubusercontent.co
TinkerPop 3.2.3 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Fixed a `Set`, `List`, `Map` bug in the various `Translators` where such collections were not being internally translated.
+* Fixed a `Bytecode` bug where nested structures (map, list, set) were not being analyzed for bindings and bytecode conversions.
+* Fixed a `String` bug in `GroovyTranslator` and `PythonTranslator` where if the string has double-quotes it now uses """ """.
+* Added a default `TraversalStrategy.getConfiguration()` which returns the configuration needed to construct the strategy.
+* Gremlin-Java `TraversalStrategy` and `Computer` instances are now converted to `Map`-representations in `Bytecode`.
+* `Computer` instances can be created with `Computer.create(Configuration)` and accessed via `Computer.getConf()`.
+* Every `TraversalStrategy` can be created via a `Configuration` and a static `MyStrategy.create(Configuration)`.
+* Added `TraversalSource.withComputer(Map<String,Object>)` for better language variant support.
+* Added `TraversalSource.withStrategies(Map<String,Object>...)`/`withoutStrategies(String...)` for better language variant support.
+* Added `PartitionStrategy.Builder.readPartitions()` and deprecated `PartitionStrategy.Builder.addPartition()`.
+ * A new version of `LazyBarrierStrategy` has been created and added to the default strategies.
* `FilterRankStrategy` now propagates labels "right" over non-`Scoping` filters.
* Fixed a bug in `ConnectiveP` where nested equivalent connectives should be inlined.
* Fixed a bug in `IncidentToAdjacentStrategy` where `TreeStep` traversals were allowed.
[2/4] tinkerpop git commit: ProfileTests and LazyBArrierStrategy
don't play well with each other because ProfileTests expect certain
bulks/counts/etc. Thus, if testing and there is ProfileStep,
then the strategy is not applied.
Posted by ok...@apache.org.
ProfileTests and LazyBArrierStrategy don't play well with each other because ProfileTests expect certain bulks/counts/etc. Thus, if testing and there is ProfileStep, then the strategy is not applied.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/658630a9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/658630a9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/658630a9
Branch: refs/heads/master
Commit: 658630a9785952cada916377bb06283e9e85c6c4
Parents: 5f0e843
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Oct 4 17:11:51 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Oct 4 17:11:51 2016 -0600
----------------------------------------------------------------------
.../optimization/LazyBarrierStrategy.java | 9 +++--
.../optimization/LazyBarrierStrategyTest.java | 1 +
.../process/traversal/step/map/ProfileTest.java | 38 ++++++--------------
3 files changed, 19 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/658630a9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
index f6f9021..176921e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategy.java
@@ -28,6 +28,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.ProfileSideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
@@ -41,6 +43,7 @@ import java.util.Set;
*/
public final class LazyBarrierStrategy extends AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy> implements TraversalStrategy.OptimizationStrategy {
+ private final boolean IS_TESTING = Boolean.valueOf(System.getProperty("is.testing", "false"));
private static final LazyBarrierStrategy INSTANCE = new LazyBarrierStrategy();
private static final Set<Class<? extends OptimizationStrategy>> PRIORS = new HashSet<>(Arrays.asList(
RangeByIsCountStrategy.class,
@@ -60,7 +63,9 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
if (TraversalHelper.onGraphComputer(traversal) ||
- traversal.getTraverserRequirements().contains(TraverserRequirement.PATH))
+ traversal.getTraverserRequirements().contains(TraverserRequirement.PATH) ||
+ (IS_TESTING && (TraversalHelper.hasStepOfAssignableClass(ProfileStep.class, TraversalHelper.getRootTraversal(traversal))) ||
+ TraversalHelper.hasStepOfAssignableClass(ProfileSideEffectStep.class, TraversalHelper.getRootTraversal(traversal)))) // necessary cause ProfileTest analyzes counts
return;
boolean foundFlatMap = false;
@@ -70,7 +75,7 @@ public final class LazyBarrierStrategy extends AbstractTraversalStrategy<Travers
if (step instanceof PathProcessor) {
final Set<String> keepLabels = ((PathProcessor) step).getKeepLabels();
- if (null == keepLabels || keepLabels.isEmpty())
+ if (null != keepLabels && keepLabels.isEmpty()) // if no more path data, then start barrier'ing again
labeledPath = false;
}
if (step instanceof FlatMapStep &&
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/658630a9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
index 314cfeb..f21c64a 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/LazyBarrierStrategyTest.java
@@ -94,6 +94,7 @@ public class LazyBarrierStrategyTest {
{__.out().as("a").out().in().where(P.neq("a")), __.out().as("a").out().in().where(P.neq("a")), Collections.emptyList()},
{__.out().as("a").out().in().where(P.neq("a")).out().out(), __.out().as("a").out().in().where(P.neq("a")).barrier(2500).out().barrier(SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
{__.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(2500).out().barrier(SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
+ {__.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).out().out(), Collections.emptyList()},
{__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(2500).out().select("b").barrier(2500).out(), Collections.singletonList(PathRetractionStrategy.instance())},
{__.out().as("a").out().as("b").in().where(P.neq("a")).out().select("b").out().out(), __.out().as("a").out().as("b").in().where(P.neq("a")).barrier(2500).out().select("b").barrier(2500).out().barrier(SIZE).out(), Collections.singletonList(PathRetractionStrategy.instance())},
});
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/658630a9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
index 927f91d..548e7ab 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ProfileTest.java
@@ -32,7 +32,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.step.Profiling;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.ProfileStep;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RangeByIsCountStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
@@ -93,7 +92,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void modern_V_out_out_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_out_out_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
validate_g_V_out_out_profile_modern(traversal, traversal.next());
}
@@ -102,7 +100,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void modern_V_out_out_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_out_out_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
validate_g_V_out_out_profile_modern(traversal, traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY));
@@ -138,7 +135,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(GRATEFUL)
public void grateful_V_out_out_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_out_out_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
final TraversalMetrics traversalMetrics = traversal.next();
validate_g_V_out_out_profile_grateful(traversalMetrics);
@@ -148,7 +144,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(GRATEFUL)
public void grateful_V_out_out_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_out_out_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
@@ -190,7 +185,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
TraversalMetrics traversalMetrics = traversal.next();
assertEquals("There should be 8 steps in this traversal (counting injected profile steps).", 8, traversal.asAdmin().getSteps().size());
@@ -202,7 +196,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_sideEffectXThread_sleepX10XX_sideEffectXThread_sleepX5XX_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
assertEquals("There should be 7 steps in this traversal (counting injected profile steps).", 7, traversal.asAdmin().getSteps().size());
@@ -237,7 +230,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_repeat_both_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_repeatXbothX_timesX3X_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
final TraversalMetrics traversalMetrics = traversal.next();
@@ -250,7 +242,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_repeat_both_profileXmetricsX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_repeatXbothX_timesX3X_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
@@ -316,7 +307,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_whereXinXcreatedX_count_isX1XX_name_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_whereXinXcreatedX_count_isX1XX_name_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
final TraversalMetrics traversalMetrics = traversal.next();
validate_g_V_whereXinXcreatedX_count_isX1XX_name_profile(traversal, traversalMetrics);
@@ -326,7 +316,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_whereXinXcreatedX_count_isX1XX_name_profileXmetricsX() {
final Traversal<Vertex, String> traversal = get_g_V_whereXinXcreatedX_count_isX1XX_name_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
@@ -364,14 +353,13 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@Test
@LoadGraphWith(MODERN)
public void testProfileStrategyCallback() {
- final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_out_out_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
- MockStep mockStep = new MockStep(traversal.asAdmin());
- traversal.asAdmin().addStep(3, mockStep);
- TraversalMetrics traversalMetrics = traversal.next();
+ final Traversal<Vertex, TraversalMetrics> t = get_g_V_out_out_profile();
+ MockStep mockStep = new MockStep(t.asAdmin());
+ t.asAdmin().addStep(3, mockStep);
+ TraversalMetrics traversalMetrics = t.next();
assertTrue(mockStep.callbackCalled);
- if (!onGraphComputer(traversal.asAdmin())) {
+ if (!onGraphComputer(t.asAdmin())) {
assertEquals(100, traversalMetrics.getMetrics(3).getCount("bogusCount").longValue());
}
}
@@ -379,15 +367,14 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@Test
@LoadGraphWith(MODERN)
public void testProfileStrategyCallbackSideEffect() {
- final Traversal<Vertex, Vertex> traversal = get_g_V_out_out_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
- MockStep mockStep = new MockStep(traversal.asAdmin());
- traversal.asAdmin().addStep(3, mockStep);
- traversal.iterate();
+ final Traversal<Vertex, Vertex> t = get_g_V_out_out_profileXmetricsX();
+ MockStep mockStep = new MockStep(t.asAdmin());
+ t.asAdmin().addStep(3, mockStep);
+ t.iterate();
assertTrue(mockStep.callbackCalled);
- if (!onGraphComputer(traversal.asAdmin())) {
- final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
+ if (!onGraphComputer(t.asAdmin())) {
+ final TraversalMetrics traversalMetrics = t.asAdmin().getSideEffects().<TraversalMetrics>get(METRICS_KEY);
assertEquals(100, traversalMetrics.getMetrics(3).getCount("bogusCount").longValue());
}
}
@@ -396,7 +383,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
}
@@ -405,7 +391,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@LoadGraphWith(MODERN)
public void g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profileXmetricsX() {
final Traversal<Vertex, Map<String, String>> traversal = get_g_V_matchXa_created_b__b_in_count_isXeqX1XXX_selectXa_bX_profileXmetricsX();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
printTraversalForm(traversal);
traversal.iterate();
}
@@ -415,7 +400,6 @@ public abstract class ProfileTest extends AbstractGremlinProcessTest {
@IgnoreEngine(TraversalEngine.Type.STANDARD)
public void g_V_hasLabelXpersonX_pageRank_byXrankX_byXbothEX_rank_profile() {
final Traversal<Vertex, TraversalMetrics> traversal = get_g_V_hasLabelXpersonX_pageRank_byXrankX_byXbothEX_rank_profile();
- traversal.asAdmin().getStrategies().removeStrategies(LazyBarrierStrategy.class);
//printTraversalForm(traversal);
try {
traversal.iterate();