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/31 12:49:08 UTC

[01/49] incubator-tinkerpop git commit: Fixes a problem where cardinality is better respected with subgraph step. [Forced Update!]

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1298 0c366a076 -> 741ca4026 (forced update)


Fixes a problem where cardinality is better respected with subgraph step.

SubgraphStep now consults the parent graph features to determine cardinality of a property.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 636b2e5fc22ae2b92a96c5bda8c5979a756779d5
Parents: 0a34d2d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 13 13:36:01 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon May 16 09:04:50 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../traversal/step/sideEffect/SubgraphStep.java | 19 +++++-----
 .../step/sideEffect/GroovySubgraphTest.groovy   |  5 +++
 .../traversal/step/sideEffect/SubgraphTest.java | 38 ++++++++++++++++++--
 4 files changed, 52 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/636b2e5f/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 1e33187..a0d5c70 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -29,6 +29,7 @@ TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
 * Fixed a bug in `BulkSet.equals()` which made itself apparent when using `store()` and `aggregate()` with labeled `cap()`.
 * Ensured that all asserts of vertex and edge counts were being applied properly in the test suite.
 * Fixed bug in `gremlin-driver` where certain channel-level errors would not allow the driver to reconnect.
+* `SubgraphStep` now consults the parent graph features to determine cardinality of a property.
 * Use of `Ctrl-C` in Gremlin Console now triggers closing of open remotes.
 * Bumped SLF4J to 1.7.21 as previous versions suffered from a memory leak.
 * Fixed a bug in `Neo4jGraphStepStrategy` where it wasn't defined properly as a `ProviderOptimizationStrategy`.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/636b2e5f/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
index 7290bdb..c7bcd57 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
@@ -43,6 +43,7 @@ public final class SubgraphStep extends SideEffectStep<Edge> implements SideEffe
 
     private Graph subgraph;
     private String sideEffectKey;
+    private Graph.Features.VertexFeatures parentGraphFeatures;
 
     private static final Map<String, Object> DEFAULT_CONFIGURATION = new HashMap<String, Object>() {{
         put(Graph.GRAPH, "org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph"); // hard coded because TinkerGraph is not part of gremlin-core
@@ -56,12 +57,13 @@ public final class SubgraphStep extends SideEffectStep<Edge> implements SideEffe
 
     @Override
     protected void sideEffect(final Traverser.Admin<Edge> traverser) {
+        parentGraphFeatures = ((Graph) traversal.getGraph().get()).features().vertex();
         if (null == this.subgraph) {
             this.subgraph = traverser.sideEffects(this.sideEffectKey);
             if (!this.subgraph.features().vertex().supportsUserSuppliedIds() || !this.subgraph.features().edge().supportsUserSuppliedIds())
                 throw new IllegalArgumentException("The provided subgraph must support user supplied ids for vertices and edges: " + this.subgraph);
         }
-        SubgraphStep.addEdgeToSubgraph(this.subgraph, traverser.get());
+        addEdgeToSubgraph(traverser.get());
     }
 
     @Override
@@ -93,24 +95,25 @@ public final class SubgraphStep extends SideEffectStep<Edge> implements SideEffe
 
     ///
 
-    private static Vertex getOrCreate(final Graph subgraph, final Vertex vertex) {
+    private Vertex getOrCreate(final Vertex vertex) {
         final Iterator<Vertex> vertexIterator = subgraph.vertices(vertex.id());
         if (vertexIterator.hasNext()) return vertexIterator.next();
         final Vertex subgraphVertex = subgraph.addVertex(T.id, vertex.id(), T.label, vertex.label());
         vertex.properties().forEachRemaining(vertexProperty -> {
-            final VertexProperty<?> subgraphVertexProperty = subgraphVertex.property(vertexProperty.key(), vertexProperty.value(), T.id, vertexProperty.id());
-            vertexProperty.properties().forEachRemaining(property -> subgraphVertexProperty.<Object>property(property.key(), property.value()));
+            final VertexProperty.Cardinality cardinality = parentGraphFeatures.getCardinality(vertexProperty.key());
+            final VertexProperty<?> subgraphVertexProperty = subgraphVertex.property(cardinality, vertexProperty.key(), vertexProperty.value(), T.id, vertexProperty.id());
+            vertexProperty.properties().forEachRemaining(property -> subgraphVertexProperty.property(property.key(), property.value()));
         });
         return subgraphVertex;
     }
 
-    private static void addEdgeToSubgraph(final Graph subgraph, final Edge edge) {
+    private void addEdgeToSubgraph(final Edge edge) {
         final Iterator<Edge> edgeIterator = subgraph.edges(edge.id());
         if (edgeIterator.hasNext()) return;
         final Iterator<Vertex> vertexIterator = edge.vertices(Direction.BOTH);
-        final Vertex subGraphOutVertex = getOrCreate(subgraph, vertexIterator.next());
-        final Vertex subGraphInVertex = getOrCreate(subgraph, vertexIterator.next());
+        final Vertex subGraphOutVertex = getOrCreate(vertexIterator.next());
+        final Vertex subGraphInVertex = getOrCreate(vertexIterator.next());
         final Edge subGraphEdge = subGraphOutVertex.addEdge(edge.label(), subGraphInVertex, T.id, edge.id());
-        edge.properties().forEachRemaining(property -> subGraphEdge.<Object>property(property.key(), property.value()));
+        edge.properties().forEachRemaining(property -> subGraphEdge.property(property.key(), property.value()));
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/636b2e5f/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
index 1918b00..c3ae74a 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
@@ -41,5 +41,10 @@ public abstract class GroovySubgraphTest {
                 final Graph subgraph) {
             TraversalScriptHelper.compute("g.withSideEffect('sg') { subgraph }.V.repeat(__.bothE('created').subgraph('sg').outV).times(5).name.dedup", g, "subgraph", subgraph)
         }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(final Graph subgraph) {
+            TraversalScriptHelper.compute("g.withSideEffect('sg') { subgraph }.V.has('name','daniel').outE.subgraph('sg').inV", g, "subgraph", subgraph);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/636b2e5f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
index ad4b0cc..dc55685 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
@@ -30,16 +30,19 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.util.Arrays;
+import java.util.List;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
+import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.CREW;
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.bothE;
 import static org.apache.tinkerpop.gremlin.structure.Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES;
 import static org.apache.tinkerpop.gremlin.structure.Graph.Features.ElementFeatures.FEATURE_USER_SUPPLIED_IDS;
 import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -49,6 +52,8 @@ public abstract class SubgraphTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, String> get_g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup(final Graph subgraph);
 
+    public abstract Traversal<Vertex, Vertex> get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(final Graph subgraph);
+
     @Test
     @LoadGraphWith(MODERN)
     @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
@@ -90,17 +95,39 @@ public abstract class SubgraphTest extends AbstractGremlinProcessTest {
     public void g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup() throws Exception {
         final Configuration config = graphProvider.newGraphConfiguration("subgraph", this.getClass(), name.getMethodName(), MODERN);
         graphProvider.clear(config);
-        final Graph subgraph = graphProvider.openTestGraph(config);
+        Graph subgraph = graphProvider.openTestGraph(config);
         /////
         final Traversal<Vertex, String> traversal = get_g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup(subgraph);
         printTraversalForm(traversal);
         checkResults(Arrays.asList("marko", "josh", "peter"), traversal);
-        final Graph subGraph = traversal.asAdmin().getSideEffects().<Graph>get("sg").get();
+        subgraph = traversal.asAdmin().getSideEffects().<Graph>get("sg").get();
         assertVertexEdgeCounts(subgraph, 5, 4);
 
         graphProvider.clear(subgraph, config);
     }
 
+    @Test
+    @LoadGraphWith(CREW)
+    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
+    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = FEATURE_ADD_EDGES)
+    @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+    @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+    public void g_withSideEffectXsgX_V_hasXname_danielXout_capXsgX() throws Exception {
+        final Configuration config = graphProvider.newGraphConfiguration("subgraph", this.getClass(), name.getMethodName(), CREW);
+        graphProvider.clear(config);
+        final Graph subgraph = graphProvider.openTestGraph(config);
+        /////
+        final Traversal<Vertex, Vertex> traversal = get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(subgraph);
+        printTraversalForm(traversal);
+        traversal.iterate();
+        assertVertexEdgeCounts(subgraph, 3, 2);
+
+        final List<String> locations = subgraph.traversal().V().has("name", "daniel").<String>values("location").toList();
+        assertThat(locations, contains("spremberg", "kaiserslautern", "aachen"));
+
+        graphProvider.clear(subgraph, config);
+    }
+
     public static class Traversals extends SubgraphTest {
 
         @Override
@@ -112,5 +139,10 @@ public abstract class SubgraphTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, String> get_g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup(final Graph subgraph) {
             return g.withSideEffect("sg", () -> subgraph).V().repeat(bothE("created").subgraph("sg").outV()).times(5).<String>values("name").dedup();
         }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(final Graph subgraph) {
+            return g.withSideEffect("sg", () -> subgraph).V().has("name","daniel").outE().subgraph("sg").inV();
+        }
     }
 }


[16/49] incubator-tinkerpop git commit: Giraph integration tests are passing now. @spmallette and I chatted tonight and came up with some good ideas regarding how to leverage HaltedTraverserStrategy for both OLTP and OLAP. In short, 'metadata strategies'

Posted by dk...@apache.org.
Giraph integration tests are passing now. @spmallette and I chatted tonight and came up with some good ideas regarding how to leverage HaltedTraverserStrategy for both OLTP and OLAP. In short, 'metadata strategies' might be the new thing.


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

Branch: refs/heads/TINKERPOP-1298
Commit: f78d1cb631c91fefb46829840e6f4247955a1a5b
Parents: e6f2caa
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 19:58:28 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 19:58:28 2016 -0600

----------------------------------------------------------------------
 .../traversal/TraversalVertexProgram.java       |  19 ++--
 .../step/map/TraversalVertexProgramStep.java    |  10 +-
 .../HaltedTraverserFactoryStrategy.java         |  67 ------------
 .../decoration/HaltedTraverserStrategy.java     |  54 ++++++++++
 .../HaltedTraverserFactoryStrategyTest.java     |  96 -----------------
 .../decoration/HaltedTraverserStrategyTest.java | 102 +++++++++++++++++++
 6 files changed, 165 insertions(+), 183 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f78d1cb6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
index 4479306..07ab98a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
@@ -32,6 +32,7 @@ import org.apache.tinkerpop.gremlin.process.computer.VertexComputeKey;
 import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ComputerResultStep;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
 import org.apache.tinkerpop.gremlin.process.computer.util.AbstractVertexProgramBuilder;
 import org.apache.tinkerpop.gremlin.process.computer.util.SingleMessenger;
@@ -64,7 +65,6 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.function.MutableMetricsSupplier;
 import org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -94,7 +94,6 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     public static final String TRAVERSAL = "gremlin.traversalVertexProgram.traversal";
     public static final String HALTED_TRAVERSERS = "gremlin.traversalVertexProgram.haltedTraversers";
     public static final String ACTIVE_TRAVERSERS = "gremlin.traversalVertexProgram.activeTraversers";
-    public static final String HALTED_TRAVERSER_FACTORY = "gremlin.traversalVertexProgram.haltedTraverserFactory";
     protected static final String MUTATED_MEMORY_KEYS = "gremlin.traversalVertexProgram.mutatedMemoryKeys";
     private static final String VOTE_TO_HALT = "gremlin.traversalVertexProgram.voteToHalt";
     private static final String COMPLETED_BARRIERS = "gremlin.traversalVertexProgram.completedBarriers";
@@ -168,7 +167,11 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                         (this.traversal.get().getParent().asStep().getNextStep() instanceof ProfileStep && // same as above, but needed for profiling
                                 this.traversal.get().getParent().asStep().getNextStep().getNextStep() instanceof ComputerResultStep));
         // determine how to store halted traversers
-        this.haltedTraverserDetachFactory = configuration.containsKey(HALTED_TRAVERSER_FACTORY) ? (Class) configuration.getProperty(HALTED_TRAVERSER_FACTORY) : ReferenceFactory.class;
+        this.haltedTraverserDetachFactory = ((HaltedTraverserStrategy) this.traversal.get().getStrategies().toList()
+                .stream()
+                .filter(strategy -> strategy instanceof HaltedTraverserStrategy)
+                .findAny()
+                .orElse(HaltedTraverserStrategy.reference())).getHaltedTraverserFactory();
         // register traversal side-effects in memory
         this.memoryComputeKeys.addAll(MemoryTraversalSideEffects.getMemoryComputeKeys(this.traversal.get()));
         // register MapReducer memory compute keys
@@ -196,7 +199,6 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     public void storeState(final Configuration configuration) {
         VertexProgram.super.storeState(configuration);
         this.traversal.storeState(configuration, TRAVERSAL);
-        configuration.setProperty(HALTED_TRAVERSER_FACTORY, this.haltedTraverserDetachFactory);
         TraversalVertexProgram.storeHaltedTraversers(configuration, this.haltedTraversers);
     }
 
@@ -280,9 +282,9 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                 });
             }
             memory.add(VOTE_TO_HALT, activeTraversers.isEmpty() || WorkerExecutor.execute(vertex, new SingleMessenger<>(messenger, activeTraversers), this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserDetachFactory));
-        } else {  // ITERATION 1+
+        } else   // ITERATION 1+
             memory.add(VOTE_TO_HALT, WorkerExecutor.execute(vertex, messenger, this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserDetachFactory));
-        }
+        // save space by not having an empty halted traversers property
         if (this.returnHaltedTraversers || haltedTraversers.isEmpty())
             vertex.<TraverserSet>property(HALTED_TRAVERSERS).remove();
     }
@@ -414,11 +416,6 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
             return this;
         }
 
-        public Builder haltedTraverserFactory(final Class detachFactory) {
-            this.configuration.setProperty(HALTED_TRAVERSER_FACTORY, detachFactory);
-            return this;
-        }
-
         public Builder traversal(final TraversalSource traversalSource, final String scriptEngine, final String traversalScript, final Object... bindings) {
             return this.traversal(new ScriptTraversal<>(traversalSource, scriptEngine, traversalScript, bindings));
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f78d1cb6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
index 2b2498b..58e44a2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
@@ -30,7 +30,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequire
 import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 
 import java.util.Collections;
 import java.util.List;
@@ -42,7 +41,6 @@ import java.util.Set;
 public final class TraversalVertexProgramStep extends VertexProgramStep implements TraversalParent {
 
     public PureTraversal<?, ?> computerTraversal;
-    private Class haltedTraverserFactory = ReferenceFactory.class;
 
     public TraversalVertexProgramStep(final Traversal.Admin traversal, final Traversal.Admin<?, ?> computerTraversal) {
         super(traversal);
@@ -71,9 +69,7 @@ public final class TraversalVertexProgramStep extends VertexProgramStep implemen
         this.getTraversal().getStrategies().toList().forEach(computerSpecificTraversal.getStrategies()::addStrategies);
         computerSpecificTraversal.setSideEffects(new MemoryTraversalSideEffects(this.getTraversal().getSideEffects()));
         computerSpecificTraversal.setParent(this);
-        final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build()
-                .traversal(computerSpecificTraversal)
-                .haltedTraverserFactory(this.haltedTraverserFactory);
+        final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build().traversal(computerSpecificTraversal);
         if (memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS))
             builder.haltedTraversers(memory.get(TraversalVertexProgram.HALTED_TRAVERSERS));
         return builder.create(graph);
@@ -100,10 +96,6 @@ public final class TraversalVertexProgramStep extends VertexProgramStep implemen
         this.integrateChild(this.computerTraversal.get());
     }
 
-    public void setHaltedTraverserFactory(final Class haltedTraverserDetachFactory) {
-        this.haltedTraverserFactory = haltedTraverserDetachFactory;
-    }
-
     /*@Override
     public int hashCode() {
         return super.hashCode() ^ this.computerTraversal.hashCode();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f78d1cb6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
deleted file mode 100644
index c2f3855..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
+++ /dev/null
@@ -1,67 +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.computer.traversal.strategy.decoration;
-
-import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class HaltedTraverserFactoryStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy> implements TraversalStrategy.DecorationStrategy {
-
-    private final Class haltedTraverserFactory;
-
-    private HaltedTraverserFactoryStrategy(final Class haltedTraverserFactory) {
-        this.haltedTraverserFactory = haltedTraverserFactory;
-    }
-
-    public void apply(final Traversal.Admin<?, ?> traversal) {
-        // only the root traversal should be processed
-        if (traversal.getParent() instanceof EmptyStep) {
-            final List<TraversalVertexProgramStep> steps = TraversalHelper.getStepsOfAssignableClass(TraversalVertexProgramStep.class, traversal);
-            // only the last step (the one returning data) needs to have a non-reference traverser factory
-            if (!steps.isEmpty())
-                steps.get(steps.size() - 1).setHaltedTraverserFactory(this.haltedTraverserFactory);
-        }
-    }
-
-    public static HaltedTraverserFactoryStrategy detached() {
-        return new HaltedTraverserFactoryStrategy(DetachedFactory.class);
-    }
-
-    public static HaltedTraverserFactoryStrategy reference() {
-        return new HaltedTraverserFactoryStrategy(ReferenceFactory.class);
-    }
-
-    public Set<Class<? extends DecorationStrategy>> applyPrior() {
-        return Collections.singleton(VertexProgramStrategy.class);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f78d1cb6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
new file mode 100644
index 0000000..fd07e23
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
@@ -0,0 +1,54 @@
+/*
+ * 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.computer.traversal.strategy.decoration;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HaltedTraverserStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy> implements TraversalStrategy.DecorationStrategy {
+
+    private final Class haltedTraverserFactory;
+
+    private HaltedTraverserStrategy(final Class haltedTraverserFactory) {
+        this.haltedTraverserFactory = haltedTraverserFactory;
+    }
+
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        // do nothing as this is simply a metadata strategy
+    }
+
+    public Class getHaltedTraverserFactory() {
+        return this.haltedTraverserFactory;
+    }
+
+    public static HaltedTraverserStrategy detached() {
+        return new HaltedTraverserStrategy(DetachedFactory.class);
+    }
+
+    public static HaltedTraverserStrategy reference() {
+        return new HaltedTraverserStrategy(ReferenceFactory.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f78d1cb6/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
deleted file mode 100644
index 43bc94e..0000000
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
+++ /dev/null
@@ -1,96 +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.tinkergraph.process.computer.traversal.strategy.decoration;
-
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserFactoryStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class HaltedTraverserFactoryStrategyTest {
-
-    @Before
-    public void setup() {
-        // necessary as ComputerResult step for testing purposes attaches Attachables
-        System.setProperty("is.testing", "false");
-    }
-
-    @After
-    public void shutdown() {
-        System.setProperty("is.testing", "true");
-    }
-
-    @Test
-    public void shouldReturnDetachedElements() {
-        Graph graph = TinkerFactory.createModern();
-        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserFactoryStrategy.detached());
-        g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
-        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
-        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
-        g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
-        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
-        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
-        g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
-        g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
-    }
-
-    @Test
-    public void shouldReturnReferenceElements() {
-        Graph graph = TinkerFactory.createModern();
-        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserFactoryStrategy.reference());
-        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
-        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
-        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
-        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
-        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
-        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
-        // the default should be reference elements
-        g = graph.traversal().withComputer();
-        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
-        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
-        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
-        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
-        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
-        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f78d1cb6/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
new file mode 100644
index 0000000..9c92efe
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.tinkergraph.process.computer.traversal.strategy.decoration;
+
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class HaltedTraverserStrategyTest {
+
+    @Before
+    public void setup() {
+        // necessary as ComputerResult step for testing purposes attaches Attachables
+        System.setProperty("is.testing", "false");
+    }
+
+    @After
+    public void shutdown() {
+        System.setProperty("is.testing", "true");
+    }
+
+    @Test
+    public void shouldReturnDetachedElements() {
+        final Graph graph = TinkerFactory.createModern();
+        final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.detached());
+        g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
+        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+    }
+
+    @Test
+    public void shouldReturnReferenceElements() {
+        final Graph graph = TinkerFactory.createModern();
+        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.reference());
+        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
+        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        // the default should be reference elements
+        g = graph.traversal().withComputer();
+        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
+        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+    }
+
+}


[25/49] incubator-tinkerpop git commit: Special `RangeByIsCountStrategy` handling for `repeat()`'s `emit()` and `until()`.

Posted by dk...@apache.org.
Special `RangeByIsCountStrategy` handling for `repeat()`'s `emit()` and `until()`.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 70e8c2a682e9b6849e4e893c2109b7d924292a2d
Parents: 498585b
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 15:14:48 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:37 2016 +0200

----------------------------------------------------------------------
 .../optimization/RangeByIsCountStrategy.java        | 16 ++++++++++++++--
 .../optimization/RangeByIsCountStrategyTest.java    |  2 ++
 2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70e8c2a6/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 09aa730..835a8f9 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
@@ -26,6 +26,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
 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;
@@ -41,6 +42,7 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.function.BiPredicate;
 
@@ -94,9 +96,19 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             final boolean update = highRange == null || highRangeCandidate > highRange;
                             if (update) {
                                 final boolean isNested = !(parent instanceof EmptyStep);
+                                if (isNested) {
+                                    if (parent instanceof RepeatStep) {
+                                        final RepeatStep repeatStep = (RepeatStep) parent;
+                                        useNotStep = Objects.equals(traversal, repeatStep.getUntilTraversal())
+                                                || Objects.equals(traversal, repeatStep.getEmitTraversal());
+                                    } else {
+                                        useNotStep = parent instanceof SideEffectStep;
+                                    }
+                                } else {
+                                    useNotStep = true;
+                                }
                                 highRange = highRangeCandidate;
-                                useNotStep = curr.getLabels().isEmpty() && next.getLabels().isEmpty()
-                                        && (!isNested || parent instanceof SideEffectStep)
+                                useNotStep &= curr.getLabels().isEmpty() && next.getLabels().isEmpty()
                                         && next.getNextStep() instanceof EmptyStep
                                         && ((highRange <= 1L && predicate.equals(Compare.lt))
                                         || (highRange == 1L && (predicate.equals(Compare.eq) || predicate.equals(Compare.lte))));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/70e8c2a6/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 e62c3a6..820d4cc 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
@@ -145,6 +145,8 @@ public class RangeByIsCountStrategyTest {
                     {__.sideEffect(__.count().is(0)), __.sideEffect(__.not(__.identity()))},
                     {__.branch(__.count().is(0)), __.branch(__.count().limit(1).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()))},
             });
         }
     }


[26/49] incubator-tinkerpop git commit: More robust pattern for `RangeByIsCountStrategy`.

Posted by dk...@apache.org.
More robust pattern for `RangeByIsCountStrategy`.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 51f55df12d42e72a8d859e1f5b27473e4bf71862
Parents: 041c033
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 11:03:52 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:37 2016 +0200

----------------------------------------------------------------------
 .../RangeByIsCountStrategyTest.java             | 180 +++----------------
 1 file changed, 23 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/51f55df1/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 a72df8e..b6d0e27 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
@@ -22,11 +22,7 @@ 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.NotStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep;
 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;
@@ -34,10 +30,7 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
 import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
 
-import static org.apache.tinkerpop.gremlin.process.traversal.P.eq;
 import static org.apache.tinkerpop.gremlin.process.traversal.P.gt;
 import static org.apache.tinkerpop.gremlin.process.traversal.P.gte;
 import static org.apache.tinkerpop.gremlin.process.traversal.P.inside;
@@ -67,39 +60,10 @@ public class RangeByIsCountStrategyTest {
         }
 
         @Parameterized.Parameter(value = 0)
-        public String name;
+        public Traversal original;
 
         @Parameterized.Parameter(value = 1)
-        public Object predicate;
-
-        @Parameterized.Parameter(value = 2)
-        public long expectedHighRange;
-
-        @Before
-        public void setup() {
-            this.traversalEngine = mock(TraversalEngine.class);
-            when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.STANDARD);
-        }
-
-        @Test
-        public void shouldApplyStrategy() {
-            doTest(predicate, expectedHighRange);
-        }
-    }
-
-    @RunWith(Parameterized.class)
-    public static class StandardNotTest extends AbstractRangeByIsCountStrategyTest {
-
-        @Parameterized.Parameters(name = "{0}")
-        public static Iterable<Object[]> data() {
-            return generateNotTestParameters();
-        }
-
-        @Parameterized.Parameter(value = 0)
-        public String name;
-
-        @Parameterized.Parameter(value = 1)
-        public Object predicate;
+        public Traversal optimized;
 
         @Before
         public void setup() {
@@ -109,7 +73,7 @@ public class RangeByIsCountStrategyTest {
 
         @Test
         public void shouldApplyStrategy() {
-            doTest(predicate);
+            doTest(original, optimized);
         }
     }
 
@@ -122,39 +86,10 @@ public class RangeByIsCountStrategyTest {
         }
 
         @Parameterized.Parameter(value = 0)
-        public String name;
-
-        @Parameterized.Parameter(value = 1)
-        public Object predicate;
-
-        @Parameterized.Parameter(value = 2)
-        public long expectedHighRange;
-
-        @Before
-        public void setup() {
-            this.traversalEngine = mock(TraversalEngine.class);
-            when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.COMPUTER);
-        }
-
-        @Test
-        public void shouldApplyStrategy() {
-            doTest(predicate, expectedHighRange);
-        }
-    }
-
-    @RunWith(Parameterized.class)
-    public static class ComputerNotTest extends AbstractRangeByIsCountStrategyTest {
-
-        @Parameterized.Parameters(name = "{0}")
-        public static Iterable<Object[]> data() {
-            return generateNotTestParameters();
-        }
-
-        @Parameterized.Parameter(value = 0)
-        public String name;
+        public Traversal original;
 
         @Parameterized.Parameter(value = 1)
-        public Object predicate;
+        public Traversal optimized;
 
         @Before
         public void setup() {
@@ -164,47 +99,7 @@ public class RangeByIsCountStrategyTest {
 
         @Test
         public void shouldApplyStrategy() {
-            doTest(predicate);
-        }
-    }
-
-    public static class SpecificComputerTest extends AbstractRangeByIsCountStrategyTest {
-
-        @Before
-        public void setup() {
-            this.traversalEngine = mock(TraversalEngine.class);
-            when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.COMPUTER);
-        }
-
-        @Test
-        public void nestedCountEqualsOneShouldLimitToTwo() {
-            final AtomicInteger counter = new AtomicInteger(0);
-            final Traversal traversal = __.out().where(__.outE("created").count().is(1));
-            applyRangeByIsCountStrategy(traversal);
-
-            final TraversalFilterStep filterStep = TraversalHelper.getStepsOfClass(TraversalFilterStep.class, traversal.asAdmin()).stream().findFirst().get();
-            final Traversal nestedTraversal = (Traversal) filterStep.getLocalChildren().get(0);
-            TraversalHelper.getStepsOfClass(RangeGlobalStep.class, nestedTraversal.asAdmin()).stream().forEach(step -> {
-                assertEquals(0, step.getLowRange());
-                assertEquals(2, step.getHighRange());
-                counter.incrementAndGet();
-            });
-            assertEquals(1, counter.get());
-        }
-
-        @Test
-        public void nestedCountEqualsNullShouldUseNotStep() {
-            final AtomicInteger counter = new AtomicInteger(0);
-            final Traversal traversal = __.out().where(__.outE("created").count().is(0));
-            applyRangeByIsCountStrategy(traversal);
-
-            final TraversalFilterStep filterStep = TraversalHelper.getStepsOfClass(TraversalFilterStep.class, traversal.asAdmin()).stream().findFirst().get();
-            final Traversal nestedTraversal = (Traversal) filterStep.getLocalChildren().get(0);
-            TraversalHelper.getStepsOfClass(NotStep.class, nestedTraversal.asAdmin()).stream().forEach(step -> {
-                assertEquals(__.outE("created"), step.getLocalChildren().get(0));
-                counter.incrementAndGet();
-            });
-            assertEquals(1, counter.get());
+            doTest(original, optimized);
         }
     }
 
@@ -212,7 +107,7 @@ public class RangeByIsCountStrategyTest {
 
         protected TraversalEngine traversalEngine;
 
-        void applyRangeByIsCountStrategy(final Traversal traversal) {
+        void applyAdjacentToIncidentStrategy(final Traversal traversal) {
             final TraversalStrategies strategies = new DefaultTraversalStrategies();
             strategies.addStrategies(RangeByIsCountStrategy.instance());
 
@@ -221,55 +116,26 @@ public class RangeByIsCountStrategyTest {
             traversal.asAdmin().applyStrategies();
         }
 
-        public void doTest(final Object predicate, final long expectedHighRange) {
-            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());
-        }
-
-        public void doTest(final Object predicate) {
-            final Traversal traversal = __.out().count().is(predicate);
-
-            applyRangeByIsCountStrategy(traversal);
-
-            final List<NotStep> steps = TraversalHelper.getStepsOfClass(NotStep.class, traversal.asAdmin());
-            assertEquals(1, steps.size());
-
-            steps.forEach(step -> assertEquals(__.out(), step.getLocalChildren().get(0)));
+        public void doTest(final Traversal traversal, final Traversal optimized) {
+            applyAdjacentToIncidentStrategy(traversal);
+            assertEquals(optimized, traversal);
         }
 
         static Iterable<Object[]> generateTestParameters() {
 
-            return Arrays.asList(new Object[][]{
-                    {"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}});
-        }
-
-        static Iterable<Object[]> generateNotTestParameters() {
-
-            return Arrays.asList(new Object[][]{
-                    {"countEqualsNullShouldUseNotStep", eq(0l)},
-                    {"countLessThanOneShouldUseNotStep", lt(1l)},
-                    {"countLessThanOrEqualNullShouldUseNotStep", lte(0l)}});
+            return Arrays.asList(new Traversal[][]{
+                    {__.out().count().is(0), __.not(__.out())},
+                    {__.out().count().is(lt(1)), __.not(__.out())},
+                    {__.out().count().is(lte(0)), __.not(__.out())},
+                    {__.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))}});
         }
     }
 }


[31/49] incubator-tinkerpop git commit: Forgot to handle `FilterSteps`.

Posted by dk...@apache.org.
Forgot to handle `FilterSteps`.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 5d38bbeb591a49f5c47ed0aa7d9aece12cf3dd21
Parents: ef53888
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 22:18:25 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:39 2016 +0200

----------------------------------------------------------------------
 .../strategy/optimization/RangeByIsCountStrategy.java     | 10 +++++-----
 .../strategy/optimization/RangeByIsCountStrategyTest.java |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5d38bbeb/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 835a8f9..451d561 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
@@ -27,6 +27,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
 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;
@@ -95,17 +96,16 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             final Long highRangeCandidate = ((Number) value).longValue() + highRangeOffset;
                             final boolean update = highRange == null || highRangeCandidate > highRange;
                             if (update) {
-                                final boolean isNested = !(parent instanceof EmptyStep);
-                                if (isNested) {
+                                if (parent instanceof EmptyStep) {
+                                    useNotStep = true;
+                                } else {
                                     if (parent instanceof RepeatStep) {
                                         final RepeatStep repeatStep = (RepeatStep) parent;
                                         useNotStep = Objects.equals(traversal, repeatStep.getUntilTraversal())
                                                 || Objects.equals(traversal, repeatStep.getEmitTraversal());
                                     } else {
-                                        useNotStep = parent instanceof SideEffectStep;
+                                        useNotStep = parent instanceof FilterStep || parent instanceof SideEffectStep;
                                     }
-                                } else {
-                                    useNotStep = true;
                                 }
                                 highRange = highRangeCandidate;
                                 useNotStep &= curr.getLabels().isEmpty() && next.getLabels().isEmpty()

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5d38bbeb/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 8b42e7f..03d5176 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
@@ -142,6 +142,7 @@ public class RangeByIsCountStrategyTest {
                     {__.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")},


[39/49] incubator-tinkerpop git commit: Refactored gryo serialization tests to have better re-use.

Posted by dk...@apache.org.
Refactored gryo serialization tests to have better re-use.


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

Branch: refs/heads/TINKERPOP-1298
Commit: bd9972e0aec1ad9fede94abf117bba9b50277d7a
Parents: 954e382
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon May 23 16:37:54 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 27 10:59:46 2016 -0400

----------------------------------------------------------------------
 .../ser/GryoBaseMessageSerializerV1d0Test.java  | 520 +++++++++++++++++++
 .../ser/GryoLiteMessageSerializerV1d0Test.java  | 439 ----------------
 .../ser/GryoMessageSerializerV1d0Test.java      | 445 +---------------
 3 files changed, 523 insertions(+), 881 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bd9972e0/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
new file mode 100644
index 0000000..99bd564
--- /dev/null
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoBaseMessageSerializerV1d0Test.java
@@ -0,0 +1,520 @@
+/*
+ * 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.driver.ser;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.apache.tinkerpop.shaded.kryo.ClassResolver;
+import org.apache.tinkerpop.shaded.kryo.Kryo;
+import org.apache.tinkerpop.shaded.kryo.KryoException;
+import org.apache.tinkerpop.shaded.kryo.Registration;
+import org.apache.tinkerpop.shaded.kryo.Serializer;
+import org.apache.tinkerpop.shaded.kryo.io.Input;
+import org.apache.tinkerpop.shaded.kryo.io.Output;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Supplier;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(Parameterized.class)
+public class GryoBaseMessageSerializerV1d0Test {
+    @Parameterized.Parameters(name = "expect({0})")
+    public static Iterable<Object[]> data() {
+        final GryoMessageSerializerV1d0 v1d0Text = new GryoMessageSerializerV1d0();
+        v1d0Text.configure(config, null);
+
+        final GryoMessageSerializerV1d0 v1d0LiteText = new GryoMessageSerializerV1d0();
+        v1d0LiteText.configure(config, null);
+
+        return Arrays.asList(new Object[][]{
+                {"V1d0", new GryoMessageSerializerV1d0(), v1d0Text},
+                {"V1d0Lite", new GryoLiteMessageSerializerV1d0(), v1d0LiteText }});
+    }
+
+    @Parameterized.Parameter(value = 0)
+    public String name;
+
+    @Parameterized.Parameter(value = 1)
+    public MessageSerializer binarySerializer;
+
+    @Parameterized.Parameter(value = 2)
+    public MessageSerializer textSerializer;
+
+    private static final Map<String, Object> config = new HashMap<String, Object>() {{
+        put(GryoMessageSerializerV1d0.TOKEN_SERIALIZE_RESULT_TO_STRING, true);
+    }};
+
+    private UUID requestId = UUID.fromString("6457272A-4018-4538-B9AE-08DD5DDC0AA1");
+    private ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(requestId);
+    private static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
+
+    @Test
+    public void shouldConfigureIoRegistry() throws Exception {
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(GryoMessageSerializerV1d0.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistry.class.getName()));
+        }};
+
+        serializer.configure(config, null);
+
+        final ResponseMessage toSerialize = ResponseMessage.build(requestId).result(Color.RED).create();
+        final ByteBuf bb = serializer.serializeResponseAsBinary(toSerialize, allocator);
+        final ResponseMessage deserialized = serializer.deserializeResponse(bb);
+
+        assertCommon(deserialized);
+        assertEquals(Color.RED, deserialized.getResult().getData());
+    }
+
+    @Test
+    public void shouldConfigureCustomClassResolver() {
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(GryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplier.class.getName());
+        }};
+
+        serializer.configure(config, null);
+
+        try {
+            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
+            fail("Should fail because the ClassResolver used here always generates an error");
+        } catch (Exception ex) {
+            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
+        }
+    }
+
+    @Test
+    public void shouldConfigureCustomClassResolverFromInstance() {
+        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(GryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplierAsInstance.class.getName());
+        }};
+
+        serializer.configure(config, null);
+
+        try {
+            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
+            fail("Should fail because the ClassResolver used here always generates an error");
+        } catch (Exception ex) {
+            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
+        }
+    }
+
+    @Test
+    public void shouldSerializeIterable() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(100);
+
+        final ResponseMessage response = convertBinary(list);
+        assertCommon(response);
+
+        final java.util.List<Integer> deserializedFunList = (java.util.List<Integer>) response.getResult().getData();
+        assertEquals(2, deserializedFunList.size());
+        assertEquals(new Integer(1), deserializedFunList.get(0));
+        assertEquals(new Integer(100), deserializedFunList.get(1));
+    }
+
+    @Test
+    public void shouldSerializeIterableToString() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(100);
+
+        final ResponseMessage response = convertText(list);
+        assertCommon(response);
+
+        final java.util.List deserializedFunList = (java.util.List) response.getResult().getData();
+        assertEquals(2, deserializedFunList.size());
+        assertEquals("1", deserializedFunList.get(0));
+        assertEquals("100", deserializedFunList.get(1));
+    }
+
+    @Test
+    public void shouldSerializeIterableToStringWithNull() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(null);
+        list.add(100);
+
+        final ResponseMessage response = convertText(list);
+        assertCommon(response);
+
+        final java.util.List deserializedFunList = (java.util.List) response.getResult().getData();
+        assertEquals(3, deserializedFunList.size());
+        assertEquals("1", deserializedFunList.get(0).toString());
+        assertEquals("null", deserializedFunList.get(1).toString());
+        assertEquals("100", deserializedFunList.get(2).toString());
+    }
+
+    @Test
+    public void shouldSerializeIterableWithNull() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(null);
+        list.add(100);
+
+        final ResponseMessage response = convertBinary(list);
+        assertCommon(response);
+
+        final java.util.List<Integer> deserializedFunList = (java.util.List<Integer>) response.getResult().getData();
+        assertEquals(3, deserializedFunList.size());
+        assertEquals(new Integer(1), deserializedFunList.get(0));
+        assertNull(deserializedFunList.get(1));
+        assertEquals(new Integer(100), deserializedFunList.get(2));
+    }
+
+    @Test
+    public void shouldSerializeMap() throws Exception {
+        final Map<String, Object> map = new HashMap<>();
+        final Map<String, String> innerMap = new HashMap<>();
+        innerMap.put("a", "b");
+
+        map.put("x", 1);
+        map.put("y", "some");
+        map.put("z", innerMap);
+
+        final ResponseMessage response = convertBinary(map);
+        assertCommon(response);
+
+        final Map<String, Object> deserializedMap = (Map<String, Object>) response.getResult().getData();
+        assertEquals(3, deserializedMap.size());
+        assertEquals(1, deserializedMap.get("x"));
+        assertEquals("some", deserializedMap.get("y"));
+
+        final Map<String, String> deserializedInnerMap = (Map<String, String>) deserializedMap.get("z");
+        assertEquals(1, deserializedInnerMap.size());
+        assertEquals("b", deserializedInnerMap.get("a"));
+    }
+
+    @Test
+    public void shouldSerializeMapEntry() throws Exception {
+        final Graph graph = TinkerGraph.open();
+        final Vertex v1 = graph.addVertex();
+        final Date d = new Date();
+
+        final Map<Object, Object> map = new HashMap<>();
+        map.put("x", 1);
+        map.put(v1, 100);
+        map.put(d, "test");
+
+        final ResponseMessage response = convertBinary(IteratorUtils.asList(map.entrySet()));
+        assertCommon(response);
+
+        final java.util.List<Map.Entry<Object, Object>> deserializedEntries = (java.util.List<Map.Entry<Object, Object>>) response.getResult().getData();
+        assertEquals(3, deserializedEntries.size());
+        deserializedEntries.forEach(e -> {
+            if (e.getKey().equals("x"))
+                assertEquals(1, e.getValue());
+            else if (e.getKey().equals(v1))
+                assertEquals(100, e.getValue());
+            else if (e.getKey().equals(d))
+                assertEquals("test", e.getValue());
+            else
+                fail("Map entries contains a key that is not part of what was serialized");
+        });
+    }
+
+    @Test
+    public void shouldSerializeTree() throws Exception {
+        final Graph g = TinkerFactory.createModern();
+        final Tree t = g.traversal().V().out().out().tree().by("name").next();
+
+        final ResponseMessage response = convertBinary(t);
+        assertCommon(response);
+
+        final Tree deserialized = (Tree) response.getResult().getData();
+        assertEquals(t, deserialized);
+
+        assertThat(deserialized.containsKey("marko"), is(true));
+        assertEquals(1, deserialized.size());
+
+        final Tree markoChildren = (Tree) deserialized.get("marko");
+        assertThat(markoChildren.containsKey("josh"), is(true));
+        assertEquals(1, markoChildren.size());
+
+        final Tree joshChildren = (Tree) markoChildren.get("josh");
+        assertThat(joshChildren.containsKey("lop"), is(true));
+        assertThat(joshChildren.containsKey("ripple"), is(true));
+        assertEquals(2, joshChildren.size());
+    }
+
+    @Test
+    public void shouldSerializeFullResponseMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put("test", "this");
+        metaData.put("one", 1);
+
+        final Map<String, Object> attributes = new HashMap<>();
+        attributes.put("test", "that");
+        attributes.put("two", 2);
+
+        final ResponseMessage response = ResponseMessage.build(id)
+                .responseMetaData(metaData)
+                .code(ResponseStatusCode.SUCCESS)
+                .result("some-result")
+                .statusAttributes(attributes)
+                .statusMessage("worked")
+                .create();
+
+        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(response, allocator);
+        final ResponseMessage deserialized = binarySerializer.deserializeResponse(bb);
+
+        assertEquals(id, deserialized.getRequestId());
+        assertEquals("this", deserialized.getResult().getMeta().get("test"));
+        assertEquals(1, deserialized.getResult().getMeta().get("one"));
+        assertEquals("some-result", deserialized.getResult().getData());
+        assertEquals("that", deserialized.getStatus().getAttributes().get("test"));
+        assertEquals(2, deserialized.getStatus().getAttributes().get("two"));
+        assertEquals(ResponseStatusCode.SUCCESS.getValue(), deserialized.getStatus().getCode().getValue());
+        assertEquals("worked", deserialized.getStatus().getMessage());
+    }
+
+    @Test
+    public void shouldHaveTooSmallBufferToSerializeResponseMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put("test", "this");
+        metaData.put("one", 1);
+
+        final Map<String, Object> attributes = new HashMap<>();
+        attributes.put("test", "that");
+        attributes.put("two", 2);
+
+        final ResponseMessage response = ResponseMessage.build(id)
+                .responseMetaData(metaData)
+                .code(ResponseStatusCode.SUCCESS)
+                .result("some-result")
+                .statusAttributes(attributes)
+                .statusMessage("worked")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            put("bufferSize", 1);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        try {
+            binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
+            fail("Should have a buffer size that is too small");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(KryoException.class));
+        }
+    }
+
+    @Test
+    public void shouldReturnAllBytesInResponse() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put("test", "this");
+        metaData.put("one", 1);
+
+        final Map<String, Object> attributes = new HashMap<>();
+        attributes.put("test", "that");
+        attributes.put("two", 2);
+
+        final ResponseMessage response = ResponseMessage.build(id)
+                .responseMetaData(metaData)
+                .code(ResponseStatusCode.SUCCESS)
+                .result("some-result")
+                .statusAttributes(attributes)
+                .statusMessage("worked")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            // set to bufferSize < total message size but still greater than any individual object requires
+            put("bufferSize", 50);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        ByteBuf buf = binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
+        assertTrue(buf.isReadable());
+        assertEquals(82, buf.readableBytes());
+    }
+
+    @Test
+    public void shouldSerializeFullRequestMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final RequestMessage request = RequestMessage.build("try")
+                .overrideRequestId(id)
+                .processor("pro")
+                .addArg("test", "this")
+                .create();
+        final ByteBuf bb = binarySerializer.serializeRequestAsBinary(request, allocator);
+        final int mimeLen = bb.readByte();
+        bb.readBytes(new byte[mimeLen]);
+        final RequestMessage deserialized = binarySerializer.deserializeRequest(bb);
+
+        assertEquals(id, deserialized.getRequestId());
+        assertEquals("pro", deserialized.getProcessor());
+        assertEquals("try", deserialized.getOp());
+        assertEquals("this", deserialized.getArgs().get("test"));
+    }
+
+    @Test
+    public void shouldHaveTooSmallBufferToSerializeRequestMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final RequestMessage request = RequestMessage.build("try")
+                .overrideRequestId(id)
+                .processor("pro")
+                .addArg("test", "this")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            put("bufferSize", 1);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        try {
+            binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
+            fail("Should have a buffer size that is too small");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(KryoException.class));
+        }
+    }
+
+    @Test
+    public void shouldReturnAllBytesInRequest() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final RequestMessage request = RequestMessage.build("try")
+                .overrideRequestId(id)
+                .processor("pro")
+                .addArg("test", "this")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            // set to bufferSize < total message size but still greater than any individual object requires
+            put("bufferSize", 50);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        ByteBuf buf = binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
+        assertTrue(buf.isReadable());
+        assertEquals(71, buf.readableBytes());
+    }
+
+    private void assertCommon(final ResponseMessage response) {
+        assertEquals(requestId, response.getRequestId());
+        assertEquals(ResponseStatusCode.SUCCESS, response.getStatus().getCode());
+    }
+
+    private ResponseMessage convertBinary(final Object toSerialize) throws SerializationException {
+        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
+        return binarySerializer.deserializeResponse(bb);
+    }
+
+    private ResponseMessage convertText(final Object toSerialize) throws SerializationException {
+        final ByteBuf bb = textSerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
+        return textSerializer.deserializeResponse(bb);
+    }
+
+    public static class ErrorOnlyClassResolverSupplierAsInstance implements Supplier<ClassResolver> {
+
+        private static final ErrorOnlyClassResolverSupplierAsInstance instance = new ErrorOnlyClassResolverSupplierAsInstance();
+
+        private ErrorOnlyClassResolverSupplierAsInstance() {}
+
+        public static ErrorOnlyClassResolverSupplierAsInstance getInstance() {
+            return instance;
+        }
+
+        @Override
+        public ClassResolver get() {
+            return new ErrorOnlyClassResolver();
+        }
+    }
+
+    public static class ErrorOnlyClassResolverSupplier implements Supplier<ClassResolver> {
+        @Override
+        public ClassResolver get() {
+            return new ErrorOnlyClassResolver();
+        }
+    }
+
+    public static class ErrorOnlyClassResolver extends GryoClassResolver {
+        @Override
+        public Registration getRegistration(Class clazz) {
+            throw new RuntimeException("Registration is not allowed with this ClassResolver - it is not a good implementation");
+        }
+    }
+
+    public static class ColorIoRegistry extends AbstractIoRegistry {
+        public ColorIoRegistry() {
+            register(GryoIo.class, Color.class, new ColorSerializer());
+        }
+    }
+
+    public static class ColorSerializer extends Serializer<Color> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Color color) {
+            output.write(color.equals(Color.RED) ? 1 : 0);
+        }
+
+        @Override
+        public Color read(final Kryo kryo, final Input input, final Class<Color> aClass) {
+            return input.read() == 1 ? Color.RED : Color.BLACK;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bd9972e0/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
index 0880f5f..2a23d02 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
@@ -21,51 +21,28 @@ package org.apache.tinkerpop.gremlin.driver.ser;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufAllocator;
 import io.netty.buffer.UnpooledByteBufAllocator;
-import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
-import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.apache.tinkerpop.shaded.kryo.ClassResolver;
-import org.apache.tinkerpop.shaded.kryo.Kryo;
-import org.apache.tinkerpop.shaded.kryo.KryoException;
-import org.apache.tinkerpop.shaded.kryo.Registration;
-import org.apache.tinkerpop.shaded.kryo.Serializer;
-import org.apache.tinkerpop.shaded.kryo.io.Input;
-import org.apache.tinkerpop.shaded.kryo.io.Output;
 import org.junit.Test;
 
-import java.awt.Color;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import java.util.function.Supplier;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Serializer tests that cover non-lossy serialization/deserialization methods.
@@ -83,178 +60,6 @@ public class GryoLiteMessageSerializerV1d0Test {
 
     public MessageSerializer binarySerializer = new GryoLiteMessageSerializerV1d0();
 
-    public MessageSerializer textSerializer = new GryoLiteMessageSerializerV1d0();
-
-    public GryoLiteMessageSerializerV1d0Test() {
-        textSerializer.configure(config, null);
-    }
-
-    @Test
-    public void shouldConfigureIoRegistry() throws Exception {
-        final MessageSerializer serializer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> config = new HashMap<String, Object>() {{
-            put(AbstractGryoMessageSerializerV1d0.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistry.class.getName()));
-        }};
-
-        serializer.configure(config, null);
-
-        final ResponseMessage toSerialize = ResponseMessage.build(requestId).result(Color.RED).create();
-        final ByteBuf bb = serializer.serializeResponseAsBinary(toSerialize, allocator);
-        final ResponseMessage deserialized = serializer.deserializeResponse(bb);
-
-        assertCommon(deserialized);
-        assertEquals(Color.RED, deserialized.getResult().getData());
-    }
-
-    @Test
-    public void shouldConfigureCustomClassResolver() {
-        final MessageSerializer serializer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> config = new HashMap<String, Object>() {{
-            put(AbstractGryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplier.class.getName());
-        }};
-
-        serializer.configure(config, null);
-
-        try {
-            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
-            fail("Should fail because the ClassResolver used here always generates an error");
-        } catch (Exception ex) {
-            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
-        }
-    }
-
-    @Test
-    public void shouldConfigureCustomClassResolverFromInstance() {
-        final MessageSerializer serializer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> config = new HashMap<String, Object>() {{
-            put(AbstractGryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplierAsInstance.class.getName());
-        }};
-
-        serializer.configure(config, null);
-
-        try {
-            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
-            fail("Should fail because the ClassResolver used here always generates an error");
-        } catch (Exception ex) {
-            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
-        }
-    }
-
-    @Test
-    public void shouldSerializeIterable() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(100);
-
-        final ResponseMessage response = convertBinary(list);
-        assertCommon(response);
-
-        final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
-        assertEquals(2, deserializedFunList.size());
-        assertEquals(new Integer(1), deserializedFunList.get(0));
-        assertEquals(new Integer(100), deserializedFunList.get(1));
-    }
-
-    @Test
-    public void shouldSerializeIterableToString() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(100);
-
-        final ResponseMessage response = convertText(list);
-        assertCommon(response);
-
-        final List deserializedFunList = (List) response.getResult().getData();
-        assertEquals(2, deserializedFunList.size());
-        assertEquals("1", deserializedFunList.get(0));
-        assertEquals("100", deserializedFunList.get(1));
-    }
-
-    @Test
-    public void shouldSerializeIterableToStringWithNull() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(null);
-        list.add(100);
-
-        final ResponseMessage response = convertText(list);
-        assertCommon(response);
-
-        final List deserializedFunList = (List) response.getResult().getData();
-        assertEquals(3, deserializedFunList.size());
-        assertEquals("1", deserializedFunList.get(0).toString());
-        assertEquals("null", deserializedFunList.get(1).toString());
-        assertEquals("100", deserializedFunList.get(2).toString());
-    }
-
-    @Test
-    public void shouldSerializeIterableWithNull() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(null);
-        list.add(100);
-
-        final ResponseMessage response = convertBinary(list);
-        assertCommon(response);
-
-        final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
-        assertEquals(3, deserializedFunList.size());
-        assertEquals(new Integer(1), deserializedFunList.get(0));
-        assertNull(deserializedFunList.get(1));
-        assertEquals(new Integer(100), deserializedFunList.get(2));
-    }
-
-    @Test
-    public void shouldSerializeMap() throws Exception {
-        final Map<String, Object> map = new HashMap<>();
-        final Map<String, String> innerMap = new HashMap<>();
-        innerMap.put("a", "b");
-
-        map.put("x", 1);
-        map.put("y", "some");
-        map.put("z", innerMap);
-
-        final ResponseMessage response = convertBinary(map);
-        assertCommon(response);
-
-        final Map<String, Object> deserializedMap = (Map<String, Object>) response.getResult().getData();
-        assertEquals(3, deserializedMap.size());
-        assertEquals(1, deserializedMap.get("x"));
-        assertEquals("some", deserializedMap.get("y"));
-
-        final Map<String, String> deserializedInnerMap = (Map<String, String>) deserializedMap.get("z");
-        assertEquals(1, deserializedInnerMap.size());
-        assertEquals("b", deserializedInnerMap.get("a"));
-    }
-
-    @Test
-    public void shouldSerializeMapEntry() throws Exception {
-        final Graph graph = TinkerGraph.open();
-        final Vertex v1 = graph.addVertex();
-        final Date d = new Date();
-
-        final Map<Object, Object> map = new HashMap<>();
-        map.put("x", 1);
-        map.put(v1, 100);
-        map.put(d, "test");
-
-        final ResponseMessage response = convertBinary(IteratorUtils.asList(map.entrySet()));
-        assertCommon(response);
-
-        final List<Map.Entry<Object, Object>> deserializedEntries = (List<Map.Entry<Object, Object>>) response.getResult().getData();
-        assertEquals(3, deserializedEntries.size());
-        deserializedEntries.forEach(e -> {
-            if (e.getKey().equals("x"))
-                assertEquals(1, e.getValue());
-            else if (e.getKey().equals(v1))
-                assertEquals(100, e.getValue());
-            else if (e.getKey().equals(d))
-                assertEquals("test", e.getValue());
-            else
-                fail("Map entries contains a key that is not part of what was serialized");
-        });
-    }
-
     @Test
     public void shouldSerializeEdge() throws Exception {
         final Graph g = TinkerGraph.open();
@@ -283,30 +88,6 @@ public class GryoLiteMessageSerializerV1d0Test {
     }
 
     @Test
-    public void shouldSerializeTree() throws Exception {
-        final Graph g = TinkerFactory.createModern();
-        final Tree t = g.traversal().V().out().out().tree().by("name").next();
-
-        final ResponseMessage response = convertBinary(t);
-        assertCommon(response);
-
-        final Tree deserialized = (Tree) response.getResult().getData();
-        assertEquals(t, deserialized);
-
-        assertThat(deserialized.containsKey("marko"), is(true));
-        assertEquals(1, deserialized.size());
-
-        final Tree markoChildren = (Tree) deserialized.get("marko");
-        assertThat(markoChildren.containsKey("josh"), is(true));
-        assertEquals(1, markoChildren.size());
-
-        final Tree joshChildren = (Tree) markoChildren.get("josh");
-        assertThat(joshChildren.containsKey("lop"), is(true));
-        assertThat(joshChildren.containsKey("ripple"), is(true));
-        assertEquals(2, joshChildren.size());
-    }
-
-    @Test
     public void shouldSerializeVertexWithEmbeddedMap() throws Exception {
         final Graph g = TinkerGraph.open();
         final Vertex v = g.addVertex();
@@ -357,173 +138,6 @@ public class GryoLiteMessageSerializerV1d0Test {
         assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
     }
 
-    @Test
-    public void shouldSerializeFullResponseMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final Map<String, Object> metaData = new HashMap<>();
-        metaData.put("test", "this");
-        metaData.put("one", 1);
-
-        final Map<String, Object> attributes = new HashMap<>();
-        attributes.put("test", "that");
-        attributes.put("two", 2);
-
-        final ResponseMessage response = ResponseMessage.build(id)
-                .responseMetaData(metaData)
-                .code(ResponseStatusCode.SUCCESS)
-                .result("some-result")
-                .statusAttributes(attributes)
-                .statusMessage("worked")
-                .create();
-
-        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(response, allocator);
-        final ResponseMessage deserialized = binarySerializer.deserializeResponse(bb);
-
-        assertEquals(id, deserialized.getRequestId());
-        assertEquals("this", deserialized.getResult().getMeta().get("test"));
-        assertEquals(1, deserialized.getResult().getMeta().get("one"));
-        assertEquals("some-result", deserialized.getResult().getData());
-        assertEquals("that", deserialized.getStatus().getAttributes().get("test"));
-        assertEquals(2, deserialized.getStatus().getAttributes().get("two"));
-        assertEquals(ResponseStatusCode.SUCCESS.getValue(), deserialized.getStatus().getCode().getValue());
-        assertEquals("worked", deserialized.getStatus().getMessage());
-    }
-
-    @Test
-    public void shouldHaveTooSmallBufferToSerializeResponseMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final Map<String, Object> metaData = new HashMap<>();
-        metaData.put("test", "this");
-        metaData.put("one", 1);
-
-        final Map<String, Object> attributes = new HashMap<>();
-        attributes.put("test", "that");
-        attributes.put("two", 2);
-
-        final ResponseMessage response = ResponseMessage.build(id)
-                .responseMetaData(metaData)
-                .code(ResponseStatusCode.SUCCESS)
-                .result("some-result")
-                .statusAttributes(attributes)
-                .statusMessage("worked")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            put("bufferSize", 1);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        try {
-            binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
-            fail("Should have a buffer size that is too small");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(KryoException.class));
-        }
-    }
-
-    @Test
-    public void shouldReturnAllBytesInResponse() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final Map<String, Object> metaData = new HashMap<>();
-        metaData.put("test", "this");
-        metaData.put("one", 1);
-
-        final Map<String, Object> attributes = new HashMap<>();
-        attributes.put("test", "that");
-        attributes.put("two", 2);
-
-        final ResponseMessage response = ResponseMessage.build(id)
-                .responseMetaData(metaData)
-                .code(ResponseStatusCode.SUCCESS)
-                .result("some-result")
-                .statusAttributes(attributes)
-                .statusMessage("worked")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            // set to bufferSize < total message size but still greater than any individual object requires
-            put("bufferSize", 50);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        ByteBuf buf = binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
-        assertTrue(buf.isReadable());
-        assertEquals(82, buf.readableBytes());
-    }
-
-    @Test
-    public void shouldSerializeFullRequestMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final RequestMessage request = RequestMessage.build("try")
-                .overrideRequestId(id)
-                .processor("pro")
-                .addArg("test", "this")
-                .create();
-        final ByteBuf bb = binarySerializer.serializeRequestAsBinary(request, allocator);
-        final int mimeLen = bb.readByte();
-        bb.readBytes(new byte[mimeLen]);
-        final RequestMessage deserialized = binarySerializer.deserializeRequest(bb);
-
-        assertEquals(id, deserialized.getRequestId());
-        assertEquals("pro", deserialized.getProcessor());
-        assertEquals("try", deserialized.getOp());
-        assertEquals("this", deserialized.getArgs().get("test"));
-    }
-
-    @Test
-    public void shouldHaveTooSmallBufferToSerializeRequestMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final RequestMessage request = RequestMessage.build("try")
-                .overrideRequestId(id)
-                .processor("pro")
-                .addArg("test", "this")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            put("bufferSize", 1);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        try {
-            binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
-            fail("Should have a buffer size that is too small");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(KryoException.class));
-        }
-    }
-
-    @Test
-    public void shouldReturnAllBytesInRequest() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final RequestMessage request = RequestMessage.build("try")
-                .overrideRequestId(id)
-                .processor("pro")
-                .addArg("test", "this")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            // set to bufferSize < total message size but still greater than any individual object requires
-            put("bufferSize", 50);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        ByteBuf buf = binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
-        assertTrue(buf.isReadable());
-        assertEquals(76, buf.readableBytes());
-    }
-
     private void assertCommon(final ResponseMessage response) {
         assertEquals(requestId, response.getRequestId());
         assertEquals(ResponseStatusCode.SUCCESS, response.getStatus().getCode());
@@ -533,57 +147,4 @@ public class GryoLiteMessageSerializerV1d0Test {
         final ByteBuf bb = binarySerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
         return binarySerializer.deserializeResponse(bb);
     }
-
-    private ResponseMessage convertText(final Object toSerialize) throws SerializationException {
-        final ByteBuf bb = textSerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
-        return textSerializer.deserializeResponse(bb);
-    }
-
-    public static class ErrorOnlyClassResolverSupplierAsInstance implements Supplier<ClassResolver> {
-
-        private static final ErrorOnlyClassResolverSupplierAsInstance instance = new ErrorOnlyClassResolverSupplierAsInstance();
-
-        private ErrorOnlyClassResolverSupplierAsInstance() {}
-
-        public static ErrorOnlyClassResolverSupplierAsInstance getInstance() {
-            return instance;
-        }
-
-        @Override
-        public ClassResolver get() {
-            return new ErrorOnlyClassResolver();
-        }
-    }
-
-    public static class ErrorOnlyClassResolverSupplier implements Supplier<ClassResolver> {
-        @Override
-        public ClassResolver get() {
-            return new ErrorOnlyClassResolver();
-        }
-    }
-
-    public static class ErrorOnlyClassResolver extends GryoClassResolver {
-        @Override
-        public Registration getRegistration(Class clazz) {
-            throw new RuntimeException("Registration is not allowed with this ClassResolver - it is not a good implementation");
-        }
-    }
-
-    public static class ColorIoRegistry extends AbstractIoRegistry {
-        public ColorIoRegistry() {
-            register(GryoIo.class, Color.class, new ColorSerializer());
-        }
-    }
-
-    public static class ColorSerializer extends Serializer<Color> {
-        @Override
-        public void write(final Kryo kryo, final Output output, final Color color) {
-            output.write(color.equals(Color.RED) ? 1 : 0);
-        }
-
-        @Override
-        public Color read(final Kryo kryo, final Input input, final Class<Color> aClass) {
-            return input.read() == 1 ? Color.RED : Color.BLACK;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bd9972e0/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
index 4064f49..36e17c0 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
@@ -18,54 +18,31 @@
  */
 package org.apache.tinkerpop.gremlin.driver.ser;
 
-import org.apache.commons.lang.exception.ExceptionUtils;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.UnpooledByteBufAllocator;
 import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
-import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
-import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.UnpooledByteBufAllocator;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.apache.tinkerpop.shaded.kryo.ClassResolver;
-import org.apache.tinkerpop.shaded.kryo.Kryo;
-import org.apache.tinkerpop.shaded.kryo.KryoException;
-import org.apache.tinkerpop.shaded.kryo.Registration;
-import org.apache.tinkerpop.shaded.kryo.Serializer;
-import org.apache.tinkerpop.shaded.kryo.io.Input;
-import org.apache.tinkerpop.shaded.kryo.io.Output;
 import org.junit.Test;
 
-import java.awt.Color;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import java.util.function.Supplier;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 /**
  * Serializer tests that cover non-lossy serialization/deserialization methods.
@@ -83,178 +60,6 @@ public class GryoMessageSerializerV1d0Test {
 
     public MessageSerializer binarySerializer = new GryoMessageSerializerV1d0();
 
-    public MessageSerializer textSerializer = new GryoMessageSerializerV1d0();
-
-    public GryoMessageSerializerV1d0Test() {
-        textSerializer.configure(config, null);
-    }
-
-    @Test
-    public void shouldConfigureIoRegistry() throws Exception {
-        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> config = new HashMap<String, Object>() {{
-            put(GryoMessageSerializerV1d0.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistry.class.getName()));
-        }};
-
-        serializer.configure(config, null);
-
-        final ResponseMessage toSerialize = ResponseMessage.build(requestId).result(Color.RED).create();
-        final ByteBuf bb = serializer.serializeResponseAsBinary(toSerialize, allocator);
-        final ResponseMessage deserialized = serializer.deserializeResponse(bb);
-
-        assertCommon(deserialized);
-        assertEquals(Color.RED, deserialized.getResult().getData());
-    }
-
-    @Test
-    public void shouldConfigureCustomClassResolver() {
-        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> config = new HashMap<String, Object>() {{
-            put(GryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplier.class.getName());
-        }};
-
-        serializer.configure(config, null);
-
-        try {
-            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
-            fail("Should fail because the ClassResolver used here always generates an error");
-        } catch (Exception ex) {
-            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
-        }
-    }
-
-    @Test
-    public void shouldConfigureCustomClassResolverFromInstance() {
-        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> config = new HashMap<String, Object>() {{
-            put(GryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplierAsInstance.class.getName());
-        }};
-
-        serializer.configure(config, null);
-
-        try {
-            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
-            fail("Should fail because the ClassResolver used here always generates an error");
-        } catch (Exception ex) {
-            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
-        }
-    }
-
-    @Test
-    public void shouldSerializeIterable() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(100);
-
-        final ResponseMessage response = convertBinary(list);
-        assertCommon(response);
-
-        final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
-        assertEquals(2, deserializedFunList.size());
-        assertEquals(new Integer(1), deserializedFunList.get(0));
-        assertEquals(new Integer(100), deserializedFunList.get(1));
-    }
-
-    @Test
-    public void shouldSerializeIterableToString() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(100);
-
-        final ResponseMessage response = convertText(list);
-        assertCommon(response);
-
-        final List deserializedFunList = (List) response.getResult().getData();
-        assertEquals(2, deserializedFunList.size());
-        assertEquals("1", deserializedFunList.get(0));
-        assertEquals("100", deserializedFunList.get(1));
-    }
-
-    @Test
-    public void shouldSerializeIterableToStringWithNull() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(null);
-        list.add(100);
-
-        final ResponseMessage response = convertText(list);
-        assertCommon(response);
-
-        final List deserializedFunList = (List) response.getResult().getData();
-        assertEquals(3, deserializedFunList.size());
-        assertEquals("1", deserializedFunList.get(0).toString());
-        assertEquals("null", deserializedFunList.get(1).toString());
-        assertEquals("100", deserializedFunList.get(2).toString());
-    }
-
-    @Test
-    public void shouldSerializeIterableWithNull() throws Exception {
-        final ArrayList<Integer> list = new ArrayList<>();
-        list.add(1);
-        list.add(null);
-        list.add(100);
-
-        final ResponseMessage response = convertBinary(list);
-        assertCommon(response);
-
-        final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
-        assertEquals(3, deserializedFunList.size());
-        assertEquals(new Integer(1), deserializedFunList.get(0));
-        assertNull(deserializedFunList.get(1));
-        assertEquals(new Integer(100), deserializedFunList.get(2));
-    }
-
-    @Test
-    public void shouldSerializeMap() throws Exception {
-        final Map<String, Object> map = new HashMap<>();
-        final Map<String, String> innerMap = new HashMap<>();
-        innerMap.put("a", "b");
-
-        map.put("x", 1);
-        map.put("y", "some");
-        map.put("z", innerMap);
-
-        final ResponseMessage response = convertBinary(map);
-        assertCommon(response);
-
-        final Map<String, Object> deserializedMap = (Map<String, Object>) response.getResult().getData();
-        assertEquals(3, deserializedMap.size());
-        assertEquals(1, deserializedMap.get("x"));
-        assertEquals("some", deserializedMap.get("y"));
-
-        final Map<String, String> deserializedInnerMap = (Map<String, String>) deserializedMap.get("z");
-        assertEquals(1, deserializedInnerMap.size());
-        assertEquals("b", deserializedInnerMap.get("a"));
-    }
-
-    @Test
-    public void shouldSerializeMapEntry() throws Exception {
-        final Graph graph = TinkerGraph.open();
-        final Vertex v1 = graph.addVertex();
-        final Date d = new Date();
-
-        final Map<Object, Object> map = new HashMap<>();
-        map.put("x", 1);
-        map.put(v1, 100);
-        map.put(d, "test");
-
-        final ResponseMessage response = convertBinary(IteratorUtils.asList(map.entrySet()));
-        assertCommon(response);
-
-        final List<Map.Entry<Object, Object>> deserializedEntries = (List<Map.Entry<Object, Object>>) response.getResult().getData();
-        assertEquals(3, deserializedEntries.size());
-        deserializedEntries.forEach(e -> {
-            if (e.getKey().equals("x"))
-                assertEquals(1, e.getValue());
-            else if (e.getKey().equals(v1))
-                assertEquals(100, e.getValue());
-            else if (e.getKey().equals(d))
-                assertEquals("test", e.getValue());
-            else
-                fail("Map entries contains a key that is not part of what was serialized");
-        });
-    }
-
     @Test
     public void shouldSerializeEdge() throws Exception {
         final Graph g = TinkerGraph.open();
@@ -284,30 +89,6 @@ public class GryoMessageSerializerV1d0Test {
     }
 
     @Test
-    public void shouldSerializeTree() throws Exception {
-        final Graph g = TinkerFactory.createModern();
-        final Tree t = g.traversal().V().out().out().tree().by("name").next();
-
-        final ResponseMessage response = convertBinary(t);
-        assertCommon(response);
-
-        final Tree deserialized = (Tree) response.getResult().getData();
-        assertEquals(t, deserialized);
-
-        assertThat(deserialized.containsKey("marko"), is(true));
-        assertEquals(1, deserialized.size());
-
-        final Tree markoChildren = (Tree) deserialized.get("marko");
-        assertThat(markoChildren.containsKey("josh"), is(true));
-        assertEquals(1, markoChildren.size());
-
-        final Tree joshChildren = (Tree) markoChildren.get("josh");
-        assertThat(joshChildren.containsKey("lop"), is(true));
-        assertThat(joshChildren.containsKey("ripple"), is(true));
-        assertEquals(2, joshChildren.size());
-    }
-
-    @Test
     public void shouldSerializeVertexWithEmbeddedMap() throws Exception {
         final Graph g = TinkerGraph.open();
         final Vertex v = g.addVertex();
@@ -370,173 +151,6 @@ public class GryoMessageSerializerV1d0Test {
         assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
     }
 
-    @Test
-    public void shouldSerializeFullResponseMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final Map<String, Object> metaData = new HashMap<>();
-        metaData.put("test", "this");
-        metaData.put("one", 1);
-
-        final Map<String, Object> attributes = new HashMap<>();
-        attributes.put("test", "that");
-        attributes.put("two", 2);
-
-        final ResponseMessage response = ResponseMessage.build(id)
-                .responseMetaData(metaData)
-                .code(ResponseStatusCode.SUCCESS)
-                .result("some-result")
-                .statusAttributes(attributes)
-                .statusMessage("worked")
-                .create();
-
-        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(response, allocator);
-        final ResponseMessage deserialized = binarySerializer.deserializeResponse(bb);
-
-        assertEquals(id, deserialized.getRequestId());
-        assertEquals("this", deserialized.getResult().getMeta().get("test"));
-        assertEquals(1, deserialized.getResult().getMeta().get("one"));
-        assertEquals("some-result", deserialized.getResult().getData());
-        assertEquals("that", deserialized.getStatus().getAttributes().get("test"));
-        assertEquals(2, deserialized.getStatus().getAttributes().get("two"));
-        assertEquals(ResponseStatusCode.SUCCESS.getValue(), deserialized.getStatus().getCode().getValue());
-        assertEquals("worked", deserialized.getStatus().getMessage());
-    }
-
-    @Test
-    public void shouldHaveTooSmallBufferToSerializeResponseMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final Map<String, Object> metaData = new HashMap<>();
-        metaData.put("test", "this");
-        metaData.put("one", 1);
-
-        final Map<String, Object> attributes = new HashMap<>();
-        attributes.put("test", "that");
-        attributes.put("two", 2);
-
-        final ResponseMessage response = ResponseMessage.build(id)
-                .responseMetaData(metaData)
-                .code(ResponseStatusCode.SUCCESS)
-                .result("some-result")
-                .statusAttributes(attributes)
-                .statusMessage("worked")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            put("bufferSize", 1);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        try {
-            binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
-            fail("Should have a buffer size that is too small");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(KryoException.class));
-        }
-    }
-
-    @Test
-    public void shouldReturnAllBytesInResponse() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final Map<String, Object> metaData = new HashMap<>();
-        metaData.put("test", "this");
-        metaData.put("one", 1);
-
-        final Map<String, Object> attributes = new HashMap<>();
-        attributes.put("test", "that");
-        attributes.put("two", 2);
-
-        final ResponseMessage response = ResponseMessage.build(id)
-                .responseMetaData(metaData)
-                .code(ResponseStatusCode.SUCCESS)
-                .result("some-result")
-                .statusAttributes(attributes)
-                .statusMessage("worked")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            // set to bufferSize < total message size but still greater than any individual object requires
-            put("bufferSize", 50);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        ByteBuf buf = binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
-        assertTrue(buf.isReadable());
-        assertEquals(82, buf.readableBytes());
-    }
-
-    @Test
-    public void shouldSerializeFullRequestMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final RequestMessage request = RequestMessage.build("try")
-                .overrideRequestId(id)
-                .processor("pro")
-                .addArg("test", "this")
-                .create();
-        final ByteBuf bb = binarySerializer.serializeRequestAsBinary(request, allocator);
-        final int mimeLen = bb.readByte();
-        bb.readBytes(new byte[mimeLen]);
-        final RequestMessage deserialized = binarySerializer.deserializeRequest(bb);
-
-        assertEquals(id, deserialized.getRequestId());
-        assertEquals("pro", deserialized.getProcessor());
-        assertEquals("try", deserialized.getOp());
-        assertEquals("this", deserialized.getArgs().get("test"));
-    }
-
-    @Test
-    public void shouldHaveTooSmallBufferToSerializeRequestMessage() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final RequestMessage request = RequestMessage.build("try")
-                .overrideRequestId(id)
-                .processor("pro")
-                .addArg("test", "this")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            put("bufferSize", 1);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        try {
-            binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
-            fail("Should have a buffer size that is too small");
-        } catch (Exception ex) {
-            final Throwable root = ExceptionUtils.getRootCause(ex);
-            assertThat(root, instanceOf(KryoException.class));
-        }
-    }
-
-    @Test
-    public void shouldReturnAllBytesInRequest() throws Exception {
-        final UUID id = UUID.randomUUID();
-
-        final RequestMessage request = RequestMessage.build("try")
-                .overrideRequestId(id)
-                .processor("pro")
-                .addArg("test", "this")
-                .create();
-
-        final MessageSerializer binarySerializerWithSmallBuffer = new GryoMessageSerializerV1d0();
-        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
-            // set to bufferSize < total message size but still greater than any individual object requires
-            put("bufferSize", 50);
-        }};
-        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
-
-        ByteBuf buf = binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
-        assertTrue(buf.isReadable());
-        assertEquals(71, buf.readableBytes());
-    }
-
     private void assertCommon(final ResponseMessage response) {
         assertEquals(requestId, response.getRequestId());
         assertEquals(ResponseStatusCode.SUCCESS, response.getStatus().getCode());
@@ -546,57 +160,4 @@ public class GryoMessageSerializerV1d0Test {
         final ByteBuf bb = binarySerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
         return binarySerializer.deserializeResponse(bb);
     }
-
-    private ResponseMessage convertText(final Object toSerialize) throws SerializationException {
-        final ByteBuf bb = textSerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
-        return textSerializer.deserializeResponse(bb);
-    }
-
-    public static class ErrorOnlyClassResolverSupplierAsInstance implements Supplier<ClassResolver> {
-
-        private static final ErrorOnlyClassResolverSupplierAsInstance instance = new ErrorOnlyClassResolverSupplierAsInstance();
-
-        private ErrorOnlyClassResolverSupplierAsInstance() {}
-
-        public static ErrorOnlyClassResolverSupplierAsInstance getInstance() {
-            return instance;
-        }
-
-        @Override
-        public ClassResolver get() {
-            return new ErrorOnlyClassResolver();
-        }
-    }
-
-    public static class ErrorOnlyClassResolverSupplier implements Supplier<ClassResolver> {
-        @Override
-        public ClassResolver get() {
-            return new ErrorOnlyClassResolver();
-        }
-    }
-
-    public static class ErrorOnlyClassResolver extends GryoClassResolver {
-        @Override
-        public Registration getRegistration(Class clazz) {
-            throw new RuntimeException("Registration is not allowed with this ClassResolver - it is not a good implementation");
-        }
-    }
-
-    public static class ColorIoRegistry extends AbstractIoRegistry {
-        public ColorIoRegistry() {
-            register(GryoIo.class, Color.class, new ColorSerializer());
-        }
-    }
-
-    public static class ColorSerializer extends Serializer<Color> {
-        @Override
-        public void write(final Kryo kryo, final Output output, final Color color) {
-            output.write(color.equals(Color.RED) ? 1 : 0);
-        }
-
-        @Override
-        public Color read(final Kryo kryo, final Input input, final Class<Color> aClass) {
-            return input.read() == 1 ? Color.RED : Color.BLACK;
-        }
-    }
 }


[37/49] incubator-tinkerpop git commit: Added gryo "lite" serializer.

Posted by dk...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
index adb0fe3..86245b5 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/driver/remote/gremlin-server-integration.yaml
@@ -38,6 +38,7 @@ scriptEngines: {
       staticImports: [java.lang.Math.PI]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}}
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}}
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true}}
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }}
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
index fe674aa..c1a5214 100644
--- a/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
+++ b/gremlin-server/src/test/resources/org/apache/tinkerpop/gremlin/server/gremlin-server-integration.yaml
@@ -34,6 +34,7 @@ scriptEngines: {
       staticImports: [java.lang.Math.PI]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}}
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph, custom: [groovy.json.JsonBuilder;org.apache.tinkerpop.gremlin.driver.ser.JsonBuilderGryoSerializer]}}
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true}}
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }}
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}


[35/49] incubator-tinkerpop git commit: Allow calls to addCustom on GryoMapper to override.

Posted by dk...@apache.org.
Allow calls to addCustom on GryoMapper to override.

By allowing override, users get complete control over the gryo serialization process and open up more options for Gremlin Server to offer other optional serialization views over gryo.


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

Branch: refs/heads/TINKERPOP-1298
Commit: d7684757734732f39970265a425b921a48d8f0fb
Parents: 985170e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 20 08:33:59 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 27 10:59:46 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../upgrade/release-3.2.x-incubating.asciidoc   |  7 +++
 .../gremlin/structure/io/gryo/GryoMapper.java   | 44 +++++++++++---
 .../structure/io/gryo/GryoMapperTest.java       | 63 +++++++++++++++-----
 4 files changed, 92 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d7684757/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ca519b0..5aacd7b 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.2.1 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* `GryoMapper` allows overrides of existing serializers on calls to `addCustom` on the builder.
 * Fixed a `NullPointerException` bug around nested `group()`-steps in OLAP.
 * Fixed a severe bug around halted traversers in a multi-job OLAP traversal chain.
 * Ensure a separation of `GraphComputer` and `VertexProgram` configurations in `SparkGraphComputer` and `GiraphGraphComputer`.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d7684757/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 66e5f8c..dec022f 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -40,6 +40,13 @@ for Gremlin Console.
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1297[TINKERPOP-1297]
 
+GryoMapper Construction
+^^^^^^^^^^^^^^^^^^^^^^^
+
+It is now possible to override existing serializers with calls to `addCustom` on the `GryoMapper` builder. This option
+allows complete control over the serializers used by Gryo. Of course, this also makes it possible to produce completely
+non-compliant Gryo files. This feature should be used with caution.
+
 TraversalVertexProgram
 ^^^^^^^^^^^^^^^^^^^^^^
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d7684757/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
index d510706..9cae845 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
@@ -68,6 +68,7 @@ import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
 import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
 import org.apache.tinkerpop.gremlin.structure.util.star.StarGraphGryoSerializer;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.apache.tinkerpop.shaded.kryo.ClassResolver;
 import org.apache.tinkerpop.shaded.kryo.Kryo;
 import org.apache.tinkerpop.shaded.kryo.KryoSerializable;
@@ -104,12 +105,14 @@ import java.util.Date;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 import java.util.TimeZone;
 import java.util.TreeMap;
@@ -396,29 +399,43 @@ public final class GryoMapper implements Mapper<Kryo> {
         }
 
         /**
-         * Register custom classes to serializes with gryo using default serialization.
+         * Register custom classes to serializes with gryo using default serialization. Note that calling this method
+         * for a class that is already registered will override that registration.
          */
         public Builder addCustom(final Class... custom) {
-            if (custom != null && custom.length > 0)
-                serializationList.addAll(Arrays.asList(custom).stream()
-                        .map(c -> Triplet.<Class, Function<Kryo, Serializer>, Integer>with(c, null, currentSerializationId.getAndIncrement()))
-                        .collect(Collectors.<Triplet<Class, Function<Kryo, Serializer>, Integer>>toList()));
+            if (custom != null && custom.length > 0) {
+                for (Class clazz : custom) {
+                    addCustom(clazz, (Function<Kryo, Serializer>) null);
+                }
+            }
             return this;
         }
 
         /**
-         * Register custom class to serialize with a custom serialization class.
+         * Register custom class to serialize with a custom serialization class. Note that calling this method for
+         * a class that is already registered will override that registration.
          */
         public Builder addCustom(final Class clazz, final Serializer serializer) {
-            serializationList.add(Triplet.with(clazz, kryo -> serializer, currentSerializationId.getAndIncrement()));
+            if (null == serializer)
+                addCustom(clazz);
+            else
+                addCustom(clazz, kryo -> serializer);
             return this;
         }
 
         /**
-         * Register a custom class to serialize with a custom serializer as returned from a {@link Function}.
+         * Register a custom class to serialize with a custom serializer as returned from a {@link Function}. Note
+         * that calling this method for a class that is already registered will override that registration.
          */
         public Builder addCustom(final Class clazz, final Function<Kryo, Serializer> serializer) {
-            serializationList.add(Triplet.with(clazz, serializer, currentSerializationId.getAndIncrement()));
+            final Optional<Triplet<Class, Function<Kryo, Serializer>, Integer>> found = findSerializer(clazz);
+            if (found.isPresent()) {
+                final Triplet<Class, Function<Kryo, Serializer>, Integer> t = found.get();
+                serializationList.remove(t);
+                serializationList.add(t.setAt1(serializer));
+            } else
+                serializationList.add(Triplet.with(clazz, serializer, currentSerializationId.getAndIncrement()));
+
             return this;
         }
 
@@ -473,5 +490,14 @@ public final class GryoMapper implements Mapper<Kryo> {
 
             return new GryoMapper(this);
         }
+
+        private Optional<Triplet<Class, Function<Kryo, Serializer>, Integer>> findSerializer(final Class clazz) {
+            final Iterator<Triplet<Class, Function<Kryo, Serializer>, Integer>> itty = IteratorUtils.filter(
+                    serializationList, t -> t.getValue0().equals(clazz)).iterator();
+            if (itty.hasNext())
+                return Optional.of(itty.next());
+            else
+                return Optional.empty();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d7684757/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
index 861c6f6..29ddc57 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapperTest.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.shaded.kryo.ClassResolver;
 import org.apache.tinkerpop.shaded.kryo.Kryo;
 import org.apache.tinkerpop.shaded.kryo.Registration;
+import org.apache.tinkerpop.shaded.kryo.Serializer;
 import org.apache.tinkerpop.shaded.kryo.io.Input;
 import org.apache.tinkerpop.shaded.kryo.io.Output;
 import org.junit.Test;
@@ -57,9 +58,12 @@ import java.util.Map;
 import java.util.function.Supplier;
 
 import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.__;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -220,85 +224,100 @@ public class GryoMapperTest {
     }
 
     @Test
-    public void shouldHandleDuration()throws Exception  {
+    public void shouldOverrideExistingSerializer() throws Exception {
+        final GryoMapper mapper = GryoMapper.build()
+                .addCustom(Duration.class, new OverrideDurationSerializer()).create();
+
+        try (final OutputStream stream = new ByteArrayOutputStream()) {
+            final Output out = new Output(stream);
+            mapper.createMapper().writeObject(out, Duration.ZERO);
+            fail("The OverrideDurationSerializer throws exceptions so this should not have worked");
+        } catch (Exception ex) {
+            assertThat(ex, instanceOf(UnsupportedOperationException.class));
+            assertEquals("I don't do anything", ex.getMessage());
+        }
+    }
+
+    @Test
+    public void shouldHandleDuration() throws Exception  {
         final Duration o = Duration.ZERO;
         assertEquals(o, serializeDeserialize(o, Duration.class));
     }
 
     @Test
-    public void shouldHandleInstant()throws Exception  {
+    public void shouldHandleInstant() throws Exception  {
         final Instant o = Instant.ofEpochMilli(System.currentTimeMillis());
         assertEquals(o, serializeDeserialize(o, Instant.class));
     }
 
     @Test
-    public void shouldHandleLocalDate()throws Exception  {
+    public void shouldHandleLocalDate() throws Exception  {
         final LocalDate o = LocalDate.now();
         assertEquals(o, serializeDeserialize(o, LocalDate.class));
     }
 
     @Test
-    public void shouldHandleLocalDateTime()throws Exception  {
+    public void shouldHandleLocalDateTime() throws Exception  {
         final LocalDateTime o = LocalDateTime.now();
         assertEquals(o, serializeDeserialize(o, LocalDateTime.class));
     }
 
     @Test
-    public void shouldHandleLocalTime()throws Exception  {
+    public void shouldHandleLocalTime() throws Exception  {
         final LocalTime o = LocalTime.now();
         assertEquals(o, serializeDeserialize(o, LocalTime.class));
     }
 
     @Test
-    public void shouldHandleMonthDay()throws Exception  {
+    public void shouldHandleMonthDay() throws Exception  {
         final MonthDay o = MonthDay.now();
         assertEquals(o, serializeDeserialize(o, MonthDay.class));
     }
 
     @Test
-    public void shouldHandleOffsetDateTime()throws Exception  {
+    public void shouldHandleOffsetDateTime() throws Exception  {
         final OffsetDateTime o = OffsetDateTime.now();
         assertEquals(o, serializeDeserialize(o, OffsetDateTime.class));
     }
 
     @Test
-    public void shouldHandleOffsetTime()throws Exception  {
+    public void shouldHandleOffsetTime() throws Exception  {
         final OffsetTime o = OffsetTime.now();
         assertEquals(o, serializeDeserialize(o, OffsetTime.class));
     }
 
     @Test
-    public void shouldHandlePeriod()throws Exception  {
+    public void shouldHandlePeriod() throws Exception  {
         final Period o = Period.ofDays(3);
         assertEquals(o, serializeDeserialize(o, Period.class));
     }
 
     @Test
-    public void shouldHandleYear()throws Exception  {
+    public void shouldHandleYear() throws Exception  {
         final Year o = Year.now();
         assertEquals(o, serializeDeserialize(o, Year.class));
     }
 
     @Test
-    public void shouldHandleYearMonth()throws Exception  {
+    public void shouldHandleYearMonth() throws Exception  {
         final YearMonth o = YearMonth.now();
         assertEquals(o, serializeDeserialize(o, YearMonth.class));
     }
 
     @Test
-    public void shouldHandleZonedDateTime()throws Exception  {
+    public void shouldHandleZonedDateTime() throws Exception  {
         final ZonedDateTime o = ZonedDateTime.now();
         assertEquals(o, serializeDeserialize(o, ZonedDateTime.class));
     }
 
     @Test
-    public void shouldHandleZonedOffset()throws Exception  {
+    public void shouldHandleZonedOffset() throws Exception  {
         final ZoneOffset o  = ZonedDateTime.now().getOffset();
         assertEquals(o, serializeDeserialize(o, ZoneOffset.class));
     }
 
     @Test
-    public void shouldHandleTraversalExplanation()throws Exception  {
+    public void shouldHandleTraversalExplanation() throws Exception  {
         final TraversalExplanation te = __().out().outV().outE().explain();
         assertEquals(te.toString(), serializeDeserialize(te, TraversalExplanation.class).toString());
     }
@@ -349,4 +368,20 @@ public class GryoMapperTest {
             }
         }
     }
+
+    final static class OverrideDurationSerializer extends Serializer<Duration>
+    {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Duration duration)
+        {
+            throw new UnsupportedOperationException("I don't do anything");
+        }
+
+        @Override
+        public Duration read(final Kryo kryo, final Input input, final Class<Duration> durationClass)
+        {
+            throw new UnsupportedOperationException("I don't do anything");
+        }
+    }
+
 }


[24/49] incubator-tinkerpop git commit: Increase step offset by 2 if `foo.count().is(0)` was replaced by `not(foo)`.

Posted by dk...@apache.org.
Increase step offset by 2 if `foo.count().is(0)` was replaced by `not(foo)`.


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

Branch: refs/heads/TINKERPOP-1298
Commit: bffa77f22dda6831c32aa70cd2f1f32d9652993f
Parents: a73ec2f
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed May 25 21:33:44 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:36 2016 +0200

----------------------------------------------------------------------
 .../traversal/strategy/optimization/RangeByIsCountStrategy.java     | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bffa77f2/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 f3168a3..1b544c2 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
@@ -109,6 +109,7 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                         if (useNotStep) {
                             traversal.asAdmin().removeStep(next); // IsStep
                             traversal.asAdmin().removeStep(curr); // CountStep
+                            i += 2;
                             final Traversal.Admin inner = __.start().asAdmin();
                             TraversalHelper.insertAfterStep(prev, inner.getStartStep(), inner);
                             TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal);


[06/49] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/tp31'

Posted by dk...@apache.org.
Merge remote-tracking branch 'origin/tp31'

Conflicts:
	gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.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/192d5ec7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/192d5ec7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/192d5ec7

Branch: refs/heads/TINKERPOP-1298
Commit: 192d5ec7e9770d1c40d0d54605f8028f44ee5d1b
Parents: 44d40f6 55a509f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 24 16:20:18 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 24 16:20:18 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../traversal/step/sideEffect/SubgraphStep.java | 19 ++++++----
 .../step/sideEffect/GroovySubgraphTest.groovy   |  5 +++
 .../traversal/step/sideEffect/SubgraphTest.java | 40 ++++++++++++++++++--
 4 files changed, 53 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/192d5ec7/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
----------------------------------------------------------------------
diff --cc gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
index 12adbca,c3ae74a..7e3765a
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySubgraphTest.groovy
@@@ -39,7 -39,12 +39,12 @@@ public abstract class GroovySubgraphTes
          @Override
          public Traversal<Vertex, String> get_g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup(
                  final Graph subgraph) {
 -            TraversalScriptHelper.compute("g.withSideEffect('sg') { subgraph }.V.repeat(__.bothE('created').subgraph('sg').outV).times(5).name.dedup", g, "subgraph", subgraph)
 +            new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('sg') { subgraph }.V.repeat(__.bothE('created').subgraph('sg').outV).times(5).name.dedup", "subgraph", subgraph)
          }
+ 
+         @Override
+         public Traversal<Vertex, Vertex> get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(final Graph subgraph) {
 -            TraversalScriptHelper.compute("g.withSideEffect('sg') { subgraph }.V.has('name','daniel').outE.subgraph('sg').inV", g, "subgraph", subgraph);
++            new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('sg') { subgraph }.V.has('name','daniel').outE.subgraph('sg').inV", "subgraph", subgraph)
+         }
      }
  }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/192d5ec7/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
----------------------------------------------------------------------
diff --cc gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
index b01bcb5,dc55685..9f2a662
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphTest.java
@@@ -95,8 -100,30 +100,30 @@@ public abstract class SubgraphTest exte
          final Traversal<Vertex, String> traversal = get_g_V_withSideEffectXsgX_repeatXbothEXcreatedX_subgraphXsgX_outVX_timesX5X_name_dedup(subgraph);
          printTraversalForm(traversal);
          checkResults(Arrays.asList("marko", "josh", "peter"), traversal);
-         final Graph subGraph = traversal.asAdmin().getSideEffects().<Graph>get("sg");
-         assertVertexEdgeCounts(subGraph, 5, 4);
 -        subgraph = traversal.asAdmin().getSideEffects().<Graph>get("sg").get();
++        subgraph = traversal.asAdmin().getSideEffects().<Graph>get("sg");
+         assertVertexEdgeCounts(subgraph, 5, 4);
+ 
+         graphProvider.clear(subgraph, config);
+     }
+ 
+     @Test
+     @LoadGraphWith(CREW)
+     @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_ADD_VERTICES)
+     @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = FEATURE_ADD_EDGES)
+     @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+     @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+     public void g_withSideEffectXsgX_V_hasXname_danielXout_capXsgX() throws Exception {
+         final Configuration config = graphProvider.newGraphConfiguration("subgraph", this.getClass(), name.getMethodName(), CREW);
+         graphProvider.clear(config);
+         final Graph subgraph = graphProvider.openTestGraph(config);
+         /////
+         final Traversal<Vertex, Vertex> traversal = get_g_withSideEffectXsgX_V_hasXname_danielX_outE_subgraphXsgX_inV(subgraph);
+         printTraversalForm(traversal);
+         traversal.iterate();
+         assertVertexEdgeCounts(subgraph, 3, 2);
+ 
+         final List<String> locations = subgraph.traversal().V().has("name", "daniel").<String>values("location").toList();
+         assertThat(locations, contains("spremberg", "kaiserslautern", "aachen"));
  
          graphProvider.clear(subgraph, config);
      }


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

Posted by dk...@apache.org.
Merge branch 'tp31'


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

Branch: refs/heads/TINKERPOP-1298
Commit: 670bc69d6a1cc2ad7cfaef522952af65ed9063d5
Parents: 2c08928 96ee0ba
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Sun May 29 10:10:58 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Sun May 29 10:10:58 2016 +0200

----------------------------------------------------------------------
 bin/process-docs.sh                  |  2 +-
 docs/preprocessor/awk/prepare.awk    |  4 +++
 docs/preprocessor/preprocess-file.sh |  3 ++-
 docs/preprocessor/preprocess.sh      | 44 +++++++++++++------------------
 4 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------



[38/49] incubator-tinkerpop git commit: Added gryo "lite" serializer.

Posted by dk...@apache.org.
Added gryo "lite" serializer.

Serializes graph elements to "reference" rather than "detached". Altered all the configuration files that required the change. This serializer is just an option - the default configuration from the client side is to use the existing serializer.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 5b6394c5e5889acf4ddc8f297fa0aa14462a74c6
Parents: d768475
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 20 12:43:12 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 27 10:59:46 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   3 +-
 .../structure/io/gryo/GryoSerializers.java      |  12 -
 .../ser/AbstractGryoMessageSerializerV1d0.java  | 311 ++++++++++
 .../ser/GryoLiteMessageSerializerV1d0.java      | 156 +++++
 .../driver/ser/GryoMessageSerializerV1d0.java   | 290 +--------
 .../tinkerpop/gremlin/driver/ser/SerTokens.java |   1 +
 .../gremlin/driver/ser/Serializers.java         |   5 +-
 .../ser/GryoLiteMessageSerializerV1d0Test.java  | 589 +++++++++++++++++++
 .../ser/GryoMessageSerializerV1d0Test.java      |   2 +-
 gremlin-server/conf/gremlin-server-classic.yaml |   1 +
 .../conf/gremlin-server-modern-readonly.yaml    |   1 +
 gremlin-server/conf/gremlin-server-modern.yaml  |   1 +
 gremlin-server/conf/gremlin-server-neo4j.yaml   |   1 +
 .../conf/gremlin-server-rest-secure.yaml        |   2 -
 gremlin-server/conf/gremlin-server-secure.yaml  |   1 +
 gremlin-server/conf/gremlin-server-spark.yaml   |   1 +
 gremlin-server/conf/gremlin-server.yaml         |   1 +
 .../server/GremlinResultSetIntegrateTest.java   |  16 +
 .../remote/gremlin-server-integration.yaml      |   1 +
 .../server/gremlin-server-integration.yaml      |   1 +
 20 files changed, 1100 insertions(+), 296 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 5aacd7b..7705701 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,7 +26,6 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.2.1 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-* `GryoMapper` allows overrides of existing serializers on calls to `addCustom` on the builder.
 * Fixed a `NullPointerException` bug around nested `group()`-steps in OLAP.
 * Fixed a severe bug around halted traversers in a multi-job OLAP traversal chain.
 * Ensure a separation of `GraphComputer` and `VertexProgram` configurations in `SparkGraphComputer` and `GiraphGraphComputer`.
@@ -34,6 +33,8 @@ TinkerPop 3.2.1 (NOT OFFICIALLY RELEASED YET)
 * Added `EmptyMemory` for ease of use when no memory exists.
 * Updated `VertexComputing.generateProgram()` API to include `Memory`. (*breaking*)
 * `ImmutablePath.TailPath` is now serializable like `ImmutablePath`.
+* Intoduced the `application/vnd.gremlin-v1.0+gryo-lite` serialization type to Gremlin Server which users "reference" elements rather than "detached".
+* `GryoMapper` allows overrides of existing serializers on calls to `addCustom` on the builder.
 * Added a traversal style guide to the recipes cookbook.
 * Fixed a bug in master-traversal traverser propagation.
 * Added useful methods for custom `VertexPrograms` to be used with `program()`-step.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
index a38de03..ae99ac6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoSerializers.java
@@ -64,9 +64,6 @@ final class GryoSerializers {
      * Serializes any {@link Vertex} implementation encountered to an {@link DetachedVertex}.
      */
     final static class VertexSerializer extends Serializer<Vertex> {
-        public VertexSerializer() {
-        }
-
         @Override
         public void write(final Kryo kryo, final Output output, final Vertex vertex) {
             kryo.writeClassAndObject(output, DetachedFactory.detach(vertex, true));
@@ -82,9 +79,6 @@ final class GryoSerializers {
      * Serializes any {@link Property} implementation encountered to an {@link DetachedProperty}.
      */
     final static class PropertySerializer extends Serializer<Property> {
-        public PropertySerializer() {
-        }
-
         @Override
         public void write(final Kryo kryo, final Output output, final Property property) {
             kryo.writeClassAndObject(output, property instanceof VertexProperty ? DetachedFactory.detach((VertexProperty) property, true) : DetachedFactory.detach(property));
@@ -100,9 +94,6 @@ final class GryoSerializers {
      * Serializes any {@link VertexProperty} implementation encountered to an {@link DetachedVertexProperty}.
      */
     final static class VertexPropertySerializer extends Serializer<VertexProperty> {
-        public VertexPropertySerializer() {
-        }
-
         @Override
         public void write(final Kryo kryo, final Output output, final VertexProperty vertexProperty) {
             kryo.writeClassAndObject(output, DetachedFactory.detach(vertexProperty, true));
@@ -118,9 +109,6 @@ final class GryoSerializers {
      * Serializes any {@link Path} implementation encountered to an {@link DetachedPath}.
      */
     final static class PathSerializer extends Serializer<Path> {
-        public PathSerializer() {
-        }
-
         @Override
         public void write(final Kryo kryo, final Output output, final Path path) {
             kryo.writeClassAndObject(output, DetachedFactory.detach(path, false));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
new file mode 100644
index 0000000..4190d96
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
@@ -0,0 +1,311 @@
+/*
+ * 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.driver.ser;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.util.ReferenceCountUtil;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
+import org.apache.tinkerpop.shaded.kryo.ClassResolver;
+import org.apache.tinkerpop.shaded.kryo.Kryo;
+import org.apache.tinkerpop.shaded.kryo.Serializer;
+import org.apache.tinkerpop.shaded.kryo.io.Input;
+import org.apache.tinkerpop.shaded.kryo.io.Output;
+
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Method;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public abstract class AbstractGryoMessageSerializerV1d0 extends AbstractMessageSerializer {
+    private GryoMapper gryoMapper;
+    private ThreadLocal<Kryo> kryoThreadLocal = new ThreadLocal<Kryo>() {
+        @Override
+        protected Kryo initialValue() {
+            return gryoMapper.createMapper();
+        }
+    };
+
+    private static final Charset UTF8 = Charset.forName("UTF-8");
+
+    public static final String TOKEN_CUSTOM = "custom";
+    public static final String TOKEN_SERIALIZE_RESULT_TO_STRING = "serializeResultToString";
+    public static final String TOKEN_USE_MAPPER_FROM_GRAPH = "useMapperFromGraph";
+    public static final String TOKEN_BUFFER_SIZE = "bufferSize";
+    public static final String TOKEN_CLASS_RESOLVER_SUPPLIER = "classResolverSupplier";
+
+    protected boolean serializeToString = false;
+    private int bufferSize = 4096;
+
+    /**
+     * Creates an instance with a provided mapper configured {@link GryoMapper} instance. Note that this instance
+     * will be overridden by {@link #configure} is called.
+     */
+    public AbstractGryoMessageSerializerV1d0(final GryoMapper kryo) {
+        this.gryoMapper = kryo;
+    }
+
+    /**
+     * Called from the {@link #configure(Map, Map)} method right before the call to create the builder. Sub-classes
+     * can choose to alter the builder or completely replace it.
+     */
+    public GryoMapper.Builder beforeCreateMapper(final GryoMapper.Builder builder, final Map<String, Object> config,
+                                                 final Map<String, Graph> graphs) {
+        return builder;
+    }
+
+    @Override
+    public final void configure(final Map<String, Object> config, final Map<String, Graph> graphs) {
+        final GryoMapper.Builder builder;
+        final Object graphToUseForMapper = config.get(TOKEN_USE_MAPPER_FROM_GRAPH);
+        if (graphToUseForMapper != null) {
+            if (null == graphs) throw new IllegalStateException(String.format(
+                    "No graphs have been provided to the serializer and therefore %s is not a valid configuration", TOKEN_USE_MAPPER_FROM_GRAPH));
+
+            final Graph g = graphs.get(graphToUseForMapper.toString());
+            if (null == g) throw new IllegalStateException(String.format(
+                    "There is no graph named [%s] configured to be used in the %s setting",
+                    graphToUseForMapper, TOKEN_USE_MAPPER_FROM_GRAPH));
+
+            // a graph was found so use the mapper it constructs.  this allows gryo to be auto-configured with any
+            // custom classes that the implementation allows for
+            builder = g.io(GryoIo.build()).mapper();
+        } else {
+            // no graph was supplied so just use the default - this will likely be the case when using a graph
+            // with no custom classes or a situation where the user needs complete control like when using two
+            // distinct implementations each with their own custom classes.
+            builder = GryoMapper.build();
+        }
+
+        addIoRegistries(config, builder);
+        addClassResolverSupplier(config, builder);
+        addCustomClasses(config, builder);
+
+        this.serializeToString = Boolean.parseBoolean(config.getOrDefault(TOKEN_SERIALIZE_RESULT_TO_STRING, "false").toString());
+        this.bufferSize = Integer.parseInt(config.getOrDefault(TOKEN_BUFFER_SIZE, "4096").toString());
+
+        this.gryoMapper = beforeCreateMapper(builder, config, graphs).create();
+    }
+
+    private void addClassResolverSupplier(final Map<String, Object> config, final GryoMapper.Builder builder) {
+        final String className = (String) config.getOrDefault(TOKEN_CLASS_RESOLVER_SUPPLIER, null);
+        if (className != null && !className.isEmpty()) {
+            try {
+                final Class<?> clazz = Class.forName(className);
+                try {
+                    final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
+                    builder.classResolver((Supplier<ClassResolver>) instanceMethod.invoke(null));
+                } catch (Exception methodex) {
+                    // tried getInstance() and that failed so try newInstance() no-arg constructor
+                    builder.classResolver((Supplier<ClassResolver>) clazz.newInstance());
+                }
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            }
+        }
+    }
+
+    private void addCustomClasses(final Map<String, Object> config, final GryoMapper.Builder builder) {
+        final List<String> classNameList = getListStringFromConfig(TOKEN_CUSTOM, config);
+
+        classNameList.stream().forEach(serializerDefinition -> {
+            String className;
+            Optional<String> serializerName;
+            if (serializerDefinition.contains(";")) {
+                final String[] split = serializerDefinition.split(";");
+                if (split.length != 2)
+                    throw new IllegalStateException(String.format("Invalid format for serializer definition [%s] - expected <class>;<serializer-class>", serializerDefinition));
+
+                className = split[0];
+                serializerName = Optional.of(split[1]);
+            } else {
+                serializerName = Optional.empty();
+                className = serializerDefinition;
+            }
+
+            try {
+                final Class clazz = Class.forName(className);
+                final Serializer serializer;
+                if (serializerName.isPresent()) {
+                    final Class serializerClazz = Class.forName(serializerName.get());
+                    serializer = (Serializer) serializerClazz.newInstance();
+                    builder.addCustom(clazz, kryo -> serializer);
+                } else
+                    builder.addCustom(clazz);
+            } catch (Exception ex) {
+                throw new IllegalStateException("Class could not be found", ex);
+            }
+        });
+    }
+
+    @Override
+    public ResponseMessage deserializeResponse(final ByteBuf msg) throws SerializationException {
+        try {
+            final Kryo kryo = kryoThreadLocal.get();
+            final byte[] payload = new byte[msg.capacity()];
+            msg.readBytes(payload);
+            try (final Input input = new Input(payload)) {
+                final UUID requestId = kryo.readObjectOrNull(input, UUID.class);
+                final int status = input.readShort();
+                final String statusMsg = input.readString();
+                final Map<String,Object> statusAttributes = (Map<String,Object>) kryo.readClassAndObject(input);
+                final Object result = kryo.readClassAndObject(input);
+                final Map<String,Object> metaAttributes = (Map<String,Object>) kryo.readClassAndObject(input);
+
+                return ResponseMessage.build(requestId)
+                        .code(ResponseStatusCode.getFromValue(status))
+                        .statusMessage(statusMsg)
+                        .statusAttributes(statusAttributes)
+                        .result(result)
+                        .responseMetaData(metaAttributes)
+                        .create();
+            }
+        } catch (Exception ex) {
+            logger.warn("Response [{}] could not be deserialized by {}.", msg, GryoMessageSerializerV1d0.class.getName());
+            throw new SerializationException(ex);
+        }
+    }
+
+    @Override
+    public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException {
+        ByteBuf encodedMessage = null;
+        try {
+            final Kryo kryo = kryoThreadLocal.get();
+            try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+                final Output output = new Output(baos, bufferSize);
+
+                // request id - if present
+                kryo.writeObjectOrNull(output, responseMessage.getRequestId() != null ? responseMessage.getRequestId() : null, UUID.class);
+
+                // status
+                output.writeShort(responseMessage.getStatus().getCode().getValue());
+                output.writeString(responseMessage.getStatus().getMessage());
+                kryo.writeClassAndObject(output, responseMessage.getStatus().getAttributes());
+
+                // result
+                kryo.writeClassAndObject(output, serializeToString ? serializeResultToString(responseMessage) : responseMessage.getResult().getData());
+                kryo.writeClassAndObject(output, responseMessage.getResult().getMeta());
+
+                final long size = output.total();
+                if (size > Integer.MAX_VALUE)
+                    throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));
+
+                output.flush();
+                encodedMessage = allocator.buffer((int) size);
+                encodedMessage.writeBytes(baos.toByteArray());
+            }
+
+            return encodedMessage;
+        } catch (Exception ex) {
+            if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
+
+            logger.warn("Response [{}] could not be serialized by {}.", responseMessage.toString(), GryoMessageSerializerV1d0.class.getName());
+            throw new SerializationException(ex);
+        }
+    }
+
+    @Override
+    public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
+        try {
+            final Kryo kryo = kryoThreadLocal.get();
+            final byte[] payload = new byte[msg.readableBytes()];
+            msg.readBytes(payload);
+            try (final Input input = new Input(payload)) {
+                // by the time the message gets here, the mime length/type have been already read, so this part just
+                // needs to process the payload.
+                final UUID id = kryo.readObject(input, UUID.class);
+                final String processor = input.readString();
+                final String op = input.readString();
+
+                final RequestMessage.Builder builder = RequestMessage.build(op)
+                        .overrideRequestId(id)
+                        .processor(processor);
+
+                final Map<String, Object> args = kryo.readObject(input, HashMap.class);
+                args.forEach(builder::addArg);
+                return builder.create();
+            }
+        } catch (Exception ex) {
+            logger.warn("Request [{}] could not be deserialized by {}.", msg, GryoMessageSerializerV1d0.class.getName());
+            throw new SerializationException(ex);
+        }
+    }
+
+    @Override
+    public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, final ByteBufAllocator allocator) throws SerializationException {
+        ByteBuf encodedMessage = null;
+        try {
+            final Kryo kryo = kryoThreadLocal.get();
+            try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
+                final Output output = new Output(baos, bufferSize);
+                final String mimeType = mimeTypesSupported()[0];
+                output.writeByte(mimeType.length());
+                output.write(mimeType.getBytes(UTF8));
+
+                kryo.writeObject(output, requestMessage.getRequestId());
+                output.writeString(requestMessage.getProcessor());
+                output.writeString(requestMessage.getOp());
+                kryo.writeObject(output, requestMessage.getArgs());
+
+                final long size = output.total();
+                if (size > Integer.MAX_VALUE)
+                    throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));
+
+                output.flush();
+                encodedMessage = allocator.buffer((int) size);
+                encodedMessage.writeBytes(baos.toByteArray());
+            }
+
+            return encodedMessage;
+        } catch (Exception ex) {
+            if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
+
+            logger.warn("Request [{}] could not be serialized by {}.", requestMessage.toString(), GryoMessageSerializerV1d0.class.getName());
+            throw new SerializationException(ex);
+        }
+    }
+
+    private Object serializeResultToString(final ResponseMessage msg) {
+        if (msg.getResult() == null) return "null";
+        if (msg.getResult().getData() == null) return "null";
+
+        // the IteratorHandler should return a collection so keep it as such
+        final Object o = msg.getResult().getData();
+        if (o instanceof Collection) {
+            return ((Collection) o).stream().map(d -> null == d ? "null" : d.toString()).collect(Collectors.toList());
+        } else {
+            return o.toString();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
new file mode 100644
index 0000000..a4ff38b
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
@@ -0,0 +1,156 @@
+/*
+ * 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.driver.ser;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
+import org.apache.tinkerpop.shaded.kryo.Kryo;
+import org.apache.tinkerpop.shaded.kryo.Serializer;
+import org.apache.tinkerpop.shaded.kryo.io.Input;
+import org.apache.tinkerpop.shaded.kryo.io.Output;
+
+import java.util.Map;
+
+/**
+ * An alternative Gryo serializer that uses "referenced" graph elements during serialization. Referenced elements such
+ * as {@link ReferenceVertex} exclude the label and the properties associated with it and only return the identifier.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GryoLiteMessageSerializerV1d0 extends AbstractGryoMessageSerializerV1d0 {
+
+    private static final String MIME_TYPE = SerTokens.MIME_GRYO_LITE_V1D0;
+    private static final String MIME_TYPE_STRINGD = SerTokens.MIME_GRYO_LITE_V1D0 + "-stringd";
+
+    /**
+     * Creates an instance with a standard {@link GryoMapper} instance. Note that this instance
+     * will be overridden by {@link #configure} is called.
+     */
+    public GryoLiteMessageSerializerV1d0() {
+        super(overrideWithLite(GryoMapper.build()).create());
+    }
+
+    @Override
+    public String[] mimeTypesSupported() {
+        return new String[]{serializeToString ? MIME_TYPE_STRINGD : MIME_TYPE};
+    }
+
+    @Override
+    public GryoMapper.Builder beforeCreateMapper(final GryoMapper.Builder builder, final Map<String, Object> config,
+                                                 final Map<String, Graph> graphs) {
+        return overrideWithLite(builder);
+    }
+
+    private static GryoMapper.Builder overrideWithLite(final GryoMapper.Builder builder) {
+        // override the core graph Elements so as to serialize with "reference" as opposed to "detached"
+        builder.addCustom(Edge.class, new EdgeLiteSerializer());
+        builder.addCustom(Vertex.class, new VertexLiteSerializer());
+        builder.addCustom(VertexProperty.class, new VertexPropertyLiteSerializer());
+        builder.addCustom(Property.class, new PropertyLiteSerializer());
+        builder.addCustom(Path.class, new PathLiteSerializer());
+        return builder;
+    }
+
+    /**
+     * Serializes any {@link Edge} implementation encountered to a {@link ReferenceEdge}.
+     */
+    final static class EdgeLiteSerializer extends Serializer<Edge> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Edge edge) {
+            kryo.writeClassAndObject(output, ReferenceFactory.detach(edge));
+        }
+
+        @Override
+        public Edge read(final Kryo kryo, final Input input, final Class<Edge> edgeClass) {
+            final Object o = kryo.readClassAndObject(input);
+            return (Edge) o;
+        }
+    }
+
+    /**
+     * Serializes any {@link Vertex} implementation encountered to an {@link ReferenceVertex}.
+     */
+    final static class VertexLiteSerializer extends Serializer<Vertex> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Vertex vertex) {
+            kryo.writeClassAndObject(output, ReferenceFactory.detach(vertex));
+        }
+
+        @Override
+        public Vertex read(final Kryo kryo, final Input input, final Class<Vertex> vertexClass) {
+            return (Vertex) kryo.readClassAndObject(input);
+        }
+    }
+
+    /**
+     * Serializes any {@link Property} implementation encountered to an {@link ReferenceProperty}.
+     */
+    final static class PropertyLiteSerializer extends Serializer<Property> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Property property) {
+            kryo.writeClassAndObject(output, property instanceof VertexProperty ? ReferenceFactory.detach((VertexProperty) property) : ReferenceFactory.detach(property));
+        }
+
+        @Override
+        public Property read(final Kryo kryo, final Input input, final Class<Property> propertyClass) {
+            return (Property) kryo.readClassAndObject(input);
+        }
+    }
+
+    /**
+     * Serializes any {@link VertexProperty} implementation encountered to an {@link ReferenceVertexProperty}.
+     */
+    final static class VertexPropertyLiteSerializer extends Serializer<VertexProperty> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final VertexProperty vertexProperty) {
+            kryo.writeClassAndObject(output, ReferenceFactory.detach(vertexProperty));
+        }
+
+        @Override
+        public VertexProperty read(final Kryo kryo, final Input input, final Class<VertexProperty> vertexPropertyClass) {
+            return (VertexProperty) kryo.readClassAndObject(input);
+        }
+    }
+
+    /**
+     * Serializes any {@link Path} implementation encountered to an {@link ReferencePath}.
+     */
+    final static class PathLiteSerializer extends Serializer<Path> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Path path) {
+            kryo.writeClassAndObject(output, ReferenceFactory.detach(path));
+        }
+
+        @Override
+        public Path read(final Kryo kryo, final Input input, final Class<Path> pathClass) {
+            return (Path) kryo.readClassAndObject(input);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
index ce46dfc..e9b51d1 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0.java
@@ -18,301 +18,33 @@
  */
 package org.apache.tinkerpop.gremlin.driver.ser;
 
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.util.ReferenceCountUtil;
-import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
-import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
-import org.apache.tinkerpop.shaded.kryo.ClassResolver;
-import org.apache.tinkerpop.shaded.kryo.Kryo;
-import org.apache.tinkerpop.shaded.kryo.Serializer;
-import org.apache.tinkerpop.shaded.kryo.io.Input;
-import org.apache.tinkerpop.shaded.kryo.io.Output;
-
-import java.io.ByteArrayOutputStream;
-import java.lang.reflect.Method;
-import java.nio.charset.Charset;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 
 /**
+ * The standard Gryo serializer that uses "detached" graph elements during serialization. Detached elements such as
+ * {@link DetachedVertex} include the label and the properties associated with it which could be more costly for
+ * network serialization purposes.
+ *
+ * @see GryoLiteMessageSerializerV1d0
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public final class GryoMessageSerializerV1d0 extends AbstractMessageSerializer {
-    private GryoMapper gryoMapper;
-    private ThreadLocal<Kryo> kryoThreadLocal = new ThreadLocal<Kryo>() {
-        @Override
-        protected Kryo initialValue() {
-            return gryoMapper.createMapper();
-        }
-    };
-
-    private static final Charset UTF8 = Charset.forName("UTF-8");
+public final class GryoMessageSerializerV1d0 extends AbstractGryoMessageSerializerV1d0 {
 
     private static final String MIME_TYPE = SerTokens.MIME_GRYO_V1D0;
     private static final String MIME_TYPE_STRINGD = SerTokens.MIME_GRYO_V1D0 + "-stringd";
 
-    public static final String TOKEN_CUSTOM = "custom";
-    public static final String TOKEN_SERIALIZE_RESULT_TO_STRING = "serializeResultToString";
-    public static final String TOKEN_USE_MAPPER_FROM_GRAPH = "useMapperFromGraph";
-    public static final String TOKEN_BUFFER_SIZE = "bufferSize";
-    public static final String TOKEN_CLASS_RESOLVER_SUPPLIER = "classResolverSupplier";
-
-    private boolean serializeToString = false;
-    private int bufferSize = 4096;
-
     /**
      * Creates an instance with a standard {@link GryoMapper} instance. Note that this instance
-     * will be overriden by {@link #configure} is called.
-     */
-    public GryoMessageSerializerV1d0() {
-        gryoMapper = GryoMapper.build().create();
-    }
-
-    /**
-     * Creates an instance with a provided mapper configured {@link GryoMapper} instance. Note that this instance
      * will be overridden by {@link #configure} is called.
      */
-    public GryoMessageSerializerV1d0(final GryoMapper kryo) {
-        this.gryoMapper = kryo;
-    }
-
-    @Override
-    public void configure(final Map<String, Object> config, final Map<String, Graph> graphs) {
-        final GryoMapper.Builder builder;
-        final Object graphToUseForMapper = config.get(TOKEN_USE_MAPPER_FROM_GRAPH);
-        if (graphToUseForMapper != null) {
-            if (null == graphs) throw new IllegalStateException(String.format(
-                    "No graphs have been provided to the serializer and therefore %s is not a valid configuration", TOKEN_USE_MAPPER_FROM_GRAPH));
-
-            final Graph g = graphs.get(graphToUseForMapper.toString());
-            if (null == g) throw new IllegalStateException(String.format(
-                    "There is no graph named [%s] configured to be used in the %s setting",
-                    graphToUseForMapper, TOKEN_USE_MAPPER_FROM_GRAPH));
-
-            // a graph was found so use the mapper it constructs.  this allows gryo to be auto-configured with any
-            // custom classes that the implementation allows for
-            builder = g.io(GryoIo.build()).mapper();
-        } else {
-            // no graph was supplied so just use the default - this will likely be the case when using a graph
-            // with no custom classes or a situation where the user needs complete control like when using two
-            // distinct implementations each with their own custom classes.
-            builder = GryoMapper.build();
-        }
-
-        addIoRegistries(config, builder);
-        addClassResolverSupplier(config, builder);
-        addCustomClasses(config, builder);
-
-        this.serializeToString = Boolean.parseBoolean(config.getOrDefault(TOKEN_SERIALIZE_RESULT_TO_STRING, "false").toString());
-        this.bufferSize = Integer.parseInt(config.getOrDefault(TOKEN_BUFFER_SIZE, "4096").toString());
-
-        this.gryoMapper = builder.create();
-    }
-
-    private void addClassResolverSupplier(final Map<String, Object> config, final GryoMapper.Builder builder) {
-        final String className = (String) config.getOrDefault(TOKEN_CLASS_RESOLVER_SUPPLIER, null);
-        if (className != null && !className.isEmpty()) {
-            try {
-                final Class<?> clazz = Class.forName(className);
-                try {
-                    final Method instanceMethod = clazz.getDeclaredMethod("getInstance");
-                    builder.classResolver((Supplier<ClassResolver>) instanceMethod.invoke(null));
-                } catch (Exception methodex) {
-                    // tried getInstance() and that failed so try newInstance() no-arg constructor
-                    builder.classResolver((Supplier<ClassResolver>) clazz.newInstance());
-                }
-            } catch (Exception ex) {
-                throw new IllegalStateException(ex);
-            }
-        }
-    }
-
-    private void addCustomClasses(final Map<String, Object> config, final GryoMapper.Builder builder) {
-        final List<String> classNameList = getListStringFromConfig(TOKEN_CUSTOM, config);
-
-        classNameList.stream().forEach(serializerDefinition -> {
-            String className;
-            Optional<String> serializerName;
-            if (serializerDefinition.contains(";")) {
-                final String[] split = serializerDefinition.split(";");
-                if (split.length != 2)
-                    throw new IllegalStateException(String.format("Invalid format for serializer definition [%s] - expected <class>;<serializer-class>", serializerDefinition));
-
-                className = split[0];
-                serializerName = Optional.of(split[1]);
-            } else {
-                serializerName = Optional.empty();
-                className = serializerDefinition;
-            }
-
-            try {
-                final Class clazz = Class.forName(className);
-                final Serializer serializer;
-                if (serializerName.isPresent()) {
-                    final Class serializerClazz = Class.forName(serializerName.get());
-                    serializer = (Serializer) serializerClazz.newInstance();
-                    builder.addCustom(clazz, kryo -> serializer);
-                } else
-                    builder.addCustom(clazz);
-            } catch (Exception ex) {
-                throw new IllegalStateException("Class could not be found", ex);
-            }
-        });
+    public GryoMessageSerializerV1d0() {
+        super(GryoMapper.build().create());
     }
 
     @Override
     public String[] mimeTypesSupported() {
-        return new String[]{this.serializeToString ? MIME_TYPE_STRINGD : MIME_TYPE};
-    }
-
-    @Override
-    public ResponseMessage deserializeResponse(final ByteBuf msg) throws SerializationException {
-        try {
-            final Kryo kryo = kryoThreadLocal.get();
-            final byte[] payload = new byte[msg.capacity()];
-            msg.readBytes(payload);
-            try (final Input input = new Input(payload)) {
-                final UUID requestId = kryo.readObjectOrNull(input, UUID.class);
-                final int status = input.readShort();
-                final String statusMsg = input.readString();
-                final Map<String,Object> statusAttributes = (Map<String,Object>) kryo.readClassAndObject(input);
-                final Object result = kryo.readClassAndObject(input);
-                final Map<String,Object> metaAttributes = (Map<String,Object>) kryo.readClassAndObject(input);
-
-                return ResponseMessage.build(requestId)
-                        .code(ResponseStatusCode.getFromValue(status))
-                        .statusMessage(statusMsg)
-                        .statusAttributes(statusAttributes)
-                        .result(result)
-                        .responseMetaData(metaAttributes)
-                        .create();
-            }
-        } catch (Exception ex) {
-            logger.warn("Response [{}] could not be deserialized by {}.", msg, GryoMessageSerializerV1d0.class.getName());
-            throw new SerializationException(ex);
-        }
-    }
-
-    @Override
-    public ByteBuf serializeResponseAsBinary(final ResponseMessage responseMessage, final ByteBufAllocator allocator) throws SerializationException {
-        ByteBuf encodedMessage = null;
-        try {
-            final Kryo kryo = kryoThreadLocal.get();
-            try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
-                final Output output = new Output(baos, bufferSize);
-
-                // request id - if present
-                kryo.writeObjectOrNull(output, responseMessage.getRequestId() != null ? responseMessage.getRequestId() : null, UUID.class);
-
-                // status
-                output.writeShort(responseMessage.getStatus().getCode().getValue());
-                output.writeString(responseMessage.getStatus().getMessage());
-                kryo.writeClassAndObject(output, responseMessage.getStatus().getAttributes());
-
-                // result
-                kryo.writeClassAndObject(output, serializeToString ? serializeResultToString(responseMessage) : responseMessage.getResult().getData());
-                kryo.writeClassAndObject(output, responseMessage.getResult().getMeta());
-
-                final long size = output.total();
-                if (size > Integer.MAX_VALUE)
-                    throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));
-
-                output.flush();
-                encodedMessage = allocator.buffer((int) size);
-                encodedMessage.writeBytes(baos.toByteArray());
-            }
-
-            return encodedMessage;
-        } catch (Exception ex) {
-            if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
-
-            logger.warn("Response [{}] could not be serialized by {}.", responseMessage.toString(), GryoMessageSerializerV1d0.class.getName());
-            throw new SerializationException(ex);
-        }
-    }
-
-    @Override
-    public RequestMessage deserializeRequest(final ByteBuf msg) throws SerializationException {
-        try {
-            final Kryo kryo = kryoThreadLocal.get();
-            final byte[] payload = new byte[msg.readableBytes()];
-            msg.readBytes(payload);
-            try (final Input input = new Input(payload)) {
-                // by the time the message gets here, the mime length/type have been already read, so this part just
-                // needs to process the payload.
-                final UUID id = kryo.readObject(input, UUID.class);
-                final String processor = input.readString();
-                final String op = input.readString();
-
-                final RequestMessage.Builder builder = RequestMessage.build(op)
-                        .overrideRequestId(id)
-                        .processor(processor);
-
-                final Map<String, Object> args = kryo.readObject(input, HashMap.class);
-                args.forEach(builder::addArg);
-                return builder.create();
-            }
-        } catch (Exception ex) {
-            logger.warn("Request [{}] could not be deserialized by {}.", msg, GryoMessageSerializerV1d0.class.getName());
-            throw new SerializationException(ex);
-        }
-    }
-
-    @Override
-    public ByteBuf serializeRequestAsBinary(final RequestMessage requestMessage, final ByteBufAllocator allocator) throws SerializationException {
-        ByteBuf encodedMessage = null;
-        try {
-            final Kryo kryo = kryoThreadLocal.get();
-            try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
-                final Output output = new Output(baos, bufferSize);
-                final String mimeType = serializeToString ? MIME_TYPE_STRINGD : MIME_TYPE;
-                output.writeByte(mimeType.length());
-                output.write(mimeType.getBytes(UTF8));
-
-                kryo.writeObject(output, requestMessage.getRequestId());
-                output.writeString(requestMessage.getProcessor());
-                output.writeString(requestMessage.getOp());
-                kryo.writeObject(output, requestMessage.getArgs());
-
-                final long size = output.total();
-                if (size > Integer.MAX_VALUE)
-                    throw new SerializationException(String.format("Message size of %s exceeds allocatable space", size));
-
-                output.flush();
-                encodedMessage = allocator.buffer((int) size);
-                encodedMessage.writeBytes(baos.toByteArray());
-            }
-
-            return encodedMessage;
-        } catch (Exception ex) {
-            if (encodedMessage != null) ReferenceCountUtil.release(encodedMessage);
-
-            logger.warn("Request [{}] could not be serialized by {}.", requestMessage.toString(), GryoMessageSerializerV1d0.class.getName());
-            throw new SerializationException(ex);
-        }
-    }
-
-    private Object serializeResultToString(final ResponseMessage msg) {
-        if (msg.getResult() == null) return "null";
-        if (msg.getResult().getData() == null) return "null";
-
-        // the IteratorHandler should return a collection so keep it as such
-        final Object o = msg.getResult().getData();
-        if (o instanceof Collection) {
-            return ((Collection) o).stream().map(d -> null == d ? "null" : d.toString()).collect(Collectors.toList());
-        } else {
-            return o.toString();
-        }
+        return new String[]{serializeToString ? MIME_TYPE_STRINGD : MIME_TYPE};
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/SerTokens.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/SerTokens.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/SerTokens.java
index 779355a..c857116 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/SerTokens.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/SerTokens.java
@@ -39,4 +39,5 @@ public final  class SerTokens {
     public static final String MIME_JSON = "application/json";
     public static final String MIME_GRAPHSON_V1D0 = "application/vnd.gremlin-v1.0+json";
     public static final String MIME_GRYO_V1D0 = "application/vnd.gremlin-v1.0+gryo";
+    public static final String MIME_GRYO_LITE_V1D0 = "application/vnd.gremlin-v1.0+gryo-lite";
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
index 11a180e..45ae301 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/Serializers.java
@@ -28,7 +28,8 @@ import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
 public enum Serializers {
     GRAPHSON(SerTokens.MIME_JSON),
     GRAPHSON_V1D0(SerTokens.MIME_GRAPHSON_V1D0),
-    GRYO_V1D0(SerTokens.MIME_GRYO_V1D0);
+    GRYO_V1D0(SerTokens.MIME_GRYO_V1D0),
+    GRYO_LITE_V1D0(SerTokens.MIME_GRYO_LITE_V1D0);
 
     private String value;
 
@@ -62,6 +63,8 @@ public enum Serializers {
                 return new GraphSONMessageSerializerGremlinV1d0();
             case SerTokens.MIME_GRYO_V1D0:
                 return new GryoMessageSerializerV1d0();
+            case SerTokens.MIME_GRYO_LITE_V1D0:
+                return new GryoLiteMessageSerializerV1d0();
             default:
                 throw new RuntimeException("Could not create a simple MessageSerializer instance of " + value);
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
new file mode 100644
index 0000000..0880f5f
--- /dev/null
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0Test.java
@@ -0,0 +1,589 @@
+/*
+ * 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.driver.ser;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoClassResolver;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.apache.tinkerpop.shaded.kryo.ClassResolver;
+import org.apache.tinkerpop.shaded.kryo.Kryo;
+import org.apache.tinkerpop.shaded.kryo.KryoException;
+import org.apache.tinkerpop.shaded.kryo.Registration;
+import org.apache.tinkerpop.shaded.kryo.Serializer;
+import org.apache.tinkerpop.shaded.kryo.io.Input;
+import org.apache.tinkerpop.shaded.kryo.io.Output;
+import org.junit.Test;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Supplier;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Serializer tests that cover non-lossy serialization/deserialization methods.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GryoLiteMessageSerializerV1d0Test {
+    private static final Map<String, Object> config = new HashMap<String, Object>() {{
+        put(AbstractGryoMessageSerializerV1d0.TOKEN_SERIALIZE_RESULT_TO_STRING, true);
+    }};
+
+    private UUID requestId = UUID.fromString("6457272A-4018-4538-B9AE-08DD5DDC0AA1");
+    private ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(requestId);
+    private static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
+
+    public MessageSerializer binarySerializer = new GryoLiteMessageSerializerV1d0();
+
+    public MessageSerializer textSerializer = new GryoLiteMessageSerializerV1d0();
+
+    public GryoLiteMessageSerializerV1d0Test() {
+        textSerializer.configure(config, null);
+    }
+
+    @Test
+    public void shouldConfigureIoRegistry() throws Exception {
+        final MessageSerializer serializer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(AbstractGryoMessageSerializerV1d0.TOKEN_IO_REGISTRIES, Arrays.asList(ColorIoRegistry.class.getName()));
+        }};
+
+        serializer.configure(config, null);
+
+        final ResponseMessage toSerialize = ResponseMessage.build(requestId).result(Color.RED).create();
+        final ByteBuf bb = serializer.serializeResponseAsBinary(toSerialize, allocator);
+        final ResponseMessage deserialized = serializer.deserializeResponse(bb);
+
+        assertCommon(deserialized);
+        assertEquals(Color.RED, deserialized.getResult().getData());
+    }
+
+    @Test
+    public void shouldConfigureCustomClassResolver() {
+        final MessageSerializer serializer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(AbstractGryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplier.class.getName());
+        }};
+
+        serializer.configure(config, null);
+
+        try {
+            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
+            fail("Should fail because the ClassResolver used here always generates an error");
+        } catch (Exception ex) {
+            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
+        }
+    }
+
+    @Test
+    public void shouldConfigureCustomClassResolverFromInstance() {
+        final MessageSerializer serializer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> config = new HashMap<String, Object>() {{
+            put(AbstractGryoMessageSerializerV1d0.TOKEN_CLASS_RESOLVER_SUPPLIER, ErrorOnlyClassResolverSupplierAsInstance.class.getName());
+        }};
+
+        serializer.configure(config, null);
+
+        try {
+            serializer.serializeResponseAsBinary(responseMessageBuilder.create(), allocator);
+            fail("Should fail because the ClassResolver used here always generates an error");
+        } catch (Exception ex) {
+            assertEquals("java.lang.RuntimeException: Registration is not allowed with this ClassResolver - it is not a good implementation", ex.getMessage());
+        }
+    }
+
+    @Test
+    public void shouldSerializeIterable() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(100);
+
+        final ResponseMessage response = convertBinary(list);
+        assertCommon(response);
+
+        final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
+        assertEquals(2, deserializedFunList.size());
+        assertEquals(new Integer(1), deserializedFunList.get(0));
+        assertEquals(new Integer(100), deserializedFunList.get(1));
+    }
+
+    @Test
+    public void shouldSerializeIterableToString() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(100);
+
+        final ResponseMessage response = convertText(list);
+        assertCommon(response);
+
+        final List deserializedFunList = (List) response.getResult().getData();
+        assertEquals(2, deserializedFunList.size());
+        assertEquals("1", deserializedFunList.get(0));
+        assertEquals("100", deserializedFunList.get(1));
+    }
+
+    @Test
+    public void shouldSerializeIterableToStringWithNull() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(null);
+        list.add(100);
+
+        final ResponseMessage response = convertText(list);
+        assertCommon(response);
+
+        final List deserializedFunList = (List) response.getResult().getData();
+        assertEquals(3, deserializedFunList.size());
+        assertEquals("1", deserializedFunList.get(0).toString());
+        assertEquals("null", deserializedFunList.get(1).toString());
+        assertEquals("100", deserializedFunList.get(2).toString());
+    }
+
+    @Test
+    public void shouldSerializeIterableWithNull() throws Exception {
+        final ArrayList<Integer> list = new ArrayList<>();
+        list.add(1);
+        list.add(null);
+        list.add(100);
+
+        final ResponseMessage response = convertBinary(list);
+        assertCommon(response);
+
+        final List<Integer> deserializedFunList = (List<Integer>) response.getResult().getData();
+        assertEquals(3, deserializedFunList.size());
+        assertEquals(new Integer(1), deserializedFunList.get(0));
+        assertNull(deserializedFunList.get(1));
+        assertEquals(new Integer(100), deserializedFunList.get(2));
+    }
+
+    @Test
+    public void shouldSerializeMap() throws Exception {
+        final Map<String, Object> map = new HashMap<>();
+        final Map<String, String> innerMap = new HashMap<>();
+        innerMap.put("a", "b");
+
+        map.put("x", 1);
+        map.put("y", "some");
+        map.put("z", innerMap);
+
+        final ResponseMessage response = convertBinary(map);
+        assertCommon(response);
+
+        final Map<String, Object> deserializedMap = (Map<String, Object>) response.getResult().getData();
+        assertEquals(3, deserializedMap.size());
+        assertEquals(1, deserializedMap.get("x"));
+        assertEquals("some", deserializedMap.get("y"));
+
+        final Map<String, String> deserializedInnerMap = (Map<String, String>) deserializedMap.get("z");
+        assertEquals(1, deserializedInnerMap.size());
+        assertEquals("b", deserializedInnerMap.get("a"));
+    }
+
+    @Test
+    public void shouldSerializeMapEntry() throws Exception {
+        final Graph graph = TinkerGraph.open();
+        final Vertex v1 = graph.addVertex();
+        final Date d = new Date();
+
+        final Map<Object, Object> map = new HashMap<>();
+        map.put("x", 1);
+        map.put(v1, 100);
+        map.put(d, "test");
+
+        final ResponseMessage response = convertBinary(IteratorUtils.asList(map.entrySet()));
+        assertCommon(response);
+
+        final List<Map.Entry<Object, Object>> deserializedEntries = (List<Map.Entry<Object, Object>>) response.getResult().getData();
+        assertEquals(3, deserializedEntries.size());
+        deserializedEntries.forEach(e -> {
+            if (e.getKey().equals("x"))
+                assertEquals(1, e.getValue());
+            else if (e.getKey().equals(v1))
+                assertEquals(100, e.getValue());
+            else if (e.getKey().equals(d))
+                assertEquals("test", e.getValue());
+            else
+                fail("Map entries contains a key that is not part of what was serialized");
+        });
+    }
+
+    @Test
+    public void shouldSerializeEdge() throws Exception {
+        final Graph g = TinkerGraph.open();
+        final Vertex v1 = g.addVertex();
+        final Vertex v2 = g.addVertex();
+        final Edge e = v1.addEdge("test", v2);
+        e.property("abc", 123);
+
+        final Iterable<Edge> iterable = IteratorUtils.list(g.edges());
+
+        final ResponseMessage response = convertBinary(iterable);
+        assertCommon(response);
+
+        final List<ReferenceEdge> edgeList = (List<ReferenceEdge>) response.getResult().getData();
+        assertEquals(1, edgeList.size());
+
+        final ReferenceEdge deserializedEdge = edgeList.get(0);
+        assertEquals(e.id(), deserializedEdge.id());
+        assertEquals("test", deserializedEdge.label());
+
+        assertEquals(0, IteratorUtils.count(deserializedEdge.properties()));
+        assertEquals(v1.id(), deserializedEdge.outVertex().id());
+        assertEquals("", deserializedEdge.outVertex().label());
+        assertEquals(v2.id(), deserializedEdge.inVertex().id());
+        assertEquals("", deserializedEdge.inVertex().label());
+    }
+
+    @Test
+    public void shouldSerializeTree() throws Exception {
+        final Graph g = TinkerFactory.createModern();
+        final Tree t = g.traversal().V().out().out().tree().by("name").next();
+
+        final ResponseMessage response = convertBinary(t);
+        assertCommon(response);
+
+        final Tree deserialized = (Tree) response.getResult().getData();
+        assertEquals(t, deserialized);
+
+        assertThat(deserialized.containsKey("marko"), is(true));
+        assertEquals(1, deserialized.size());
+
+        final Tree markoChildren = (Tree) deserialized.get("marko");
+        assertThat(markoChildren.containsKey("josh"), is(true));
+        assertEquals(1, markoChildren.size());
+
+        final Tree joshChildren = (Tree) markoChildren.get("josh");
+        assertThat(joshChildren.containsKey("lop"), is(true));
+        assertThat(joshChildren.containsKey("ripple"), is(true));
+        assertEquals(2, joshChildren.size());
+    }
+
+    @Test
+    public void shouldSerializeVertexWithEmbeddedMap() throws Exception {
+        final Graph g = TinkerGraph.open();
+        final Vertex v = g.addVertex();
+        final Map<String, Object> map = new HashMap<>();
+        map.put("x", 500);
+        map.put("y", "some");
+
+        final ArrayList<Object> friends = new ArrayList<>();
+        friends.add("x");
+        friends.add(5);
+        friends.add(map);
+
+        v.property(VertexProperty.Cardinality.single, "friends", friends);
+
+        final List list = IteratorUtils.list(g.vertices());
+
+        final ResponseMessage response = convertBinary(list);
+        assertCommon(response);
+
+        final List<ReferenceVertex> vertexList = (List<ReferenceVertex>) response.getResult().getData();
+        assertEquals(1, vertexList.size());
+
+        final ReferenceVertex deserializedVertex = vertexList.get(0);
+        assertEquals(0L, deserializedVertex.id());
+        assertEquals("", deserializedVertex.label());
+
+        assertEquals(0, IteratorUtils.count(deserializedVertex.properties()));
+    }
+
+    @Test
+    public void shouldSerializeToMapWithElementForKey() throws Exception {
+        final TinkerGraph graph = TinkerFactory.createClassic();
+        final GraphTraversalSource g = graph.traversal();
+        final Map<Vertex, Integer> map = new HashMap<>();
+        map.put(g.V().has("name", "marko").next(), 1000);
+
+        final ResponseMessage response = convertBinary(map);
+        assertCommon(response);
+
+        final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>) response.getResult().getData();
+        assertEquals(1, deserializedMap.size());
+
+        final Vertex deserializedMarko = deserializedMap.keySet().iterator().next();
+        assertEquals(0, IteratorUtils.count(deserializedMarko.properties()));
+        assertEquals(1, deserializedMarko.id());
+        assertEquals("", deserializedMarko.label());
+
+        assertEquals(new Integer(1000), deserializedMap.values().iterator().next());
+    }
+
+    @Test
+    public void shouldSerializeFullResponseMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put("test", "this");
+        metaData.put("one", 1);
+
+        final Map<String, Object> attributes = new HashMap<>();
+        attributes.put("test", "that");
+        attributes.put("two", 2);
+
+        final ResponseMessage response = ResponseMessage.build(id)
+                .responseMetaData(metaData)
+                .code(ResponseStatusCode.SUCCESS)
+                .result("some-result")
+                .statusAttributes(attributes)
+                .statusMessage("worked")
+                .create();
+
+        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(response, allocator);
+        final ResponseMessage deserialized = binarySerializer.deserializeResponse(bb);
+
+        assertEquals(id, deserialized.getRequestId());
+        assertEquals("this", deserialized.getResult().getMeta().get("test"));
+        assertEquals(1, deserialized.getResult().getMeta().get("one"));
+        assertEquals("some-result", deserialized.getResult().getData());
+        assertEquals("that", deserialized.getStatus().getAttributes().get("test"));
+        assertEquals(2, deserialized.getStatus().getAttributes().get("two"));
+        assertEquals(ResponseStatusCode.SUCCESS.getValue(), deserialized.getStatus().getCode().getValue());
+        assertEquals("worked", deserialized.getStatus().getMessage());
+    }
+
+    @Test
+    public void shouldHaveTooSmallBufferToSerializeResponseMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put("test", "this");
+        metaData.put("one", 1);
+
+        final Map<String, Object> attributes = new HashMap<>();
+        attributes.put("test", "that");
+        attributes.put("two", 2);
+
+        final ResponseMessage response = ResponseMessage.build(id)
+                .responseMetaData(metaData)
+                .code(ResponseStatusCode.SUCCESS)
+                .result("some-result")
+                .statusAttributes(attributes)
+                .statusMessage("worked")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            put("bufferSize", 1);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        try {
+            binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
+            fail("Should have a buffer size that is too small");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(KryoException.class));
+        }
+    }
+
+    @Test
+    public void shouldReturnAllBytesInResponse() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final Map<String, Object> metaData = new HashMap<>();
+        metaData.put("test", "this");
+        metaData.put("one", 1);
+
+        final Map<String, Object> attributes = new HashMap<>();
+        attributes.put("test", "that");
+        attributes.put("two", 2);
+
+        final ResponseMessage response = ResponseMessage.build(id)
+                .responseMetaData(metaData)
+                .code(ResponseStatusCode.SUCCESS)
+                .result("some-result")
+                .statusAttributes(attributes)
+                .statusMessage("worked")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            // set to bufferSize < total message size but still greater than any individual object requires
+            put("bufferSize", 50);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        ByteBuf buf = binarySerializerWithSmallBuffer.serializeResponseAsBinary(response, allocator);
+        assertTrue(buf.isReadable());
+        assertEquals(82, buf.readableBytes());
+    }
+
+    @Test
+    public void shouldSerializeFullRequestMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final RequestMessage request = RequestMessage.build("try")
+                .overrideRequestId(id)
+                .processor("pro")
+                .addArg("test", "this")
+                .create();
+        final ByteBuf bb = binarySerializer.serializeRequestAsBinary(request, allocator);
+        final int mimeLen = bb.readByte();
+        bb.readBytes(new byte[mimeLen]);
+        final RequestMessage deserialized = binarySerializer.deserializeRequest(bb);
+
+        assertEquals(id, deserialized.getRequestId());
+        assertEquals("pro", deserialized.getProcessor());
+        assertEquals("try", deserialized.getOp());
+        assertEquals("this", deserialized.getArgs().get("test"));
+    }
+
+    @Test
+    public void shouldHaveTooSmallBufferToSerializeRequestMessage() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final RequestMessage request = RequestMessage.build("try")
+                .overrideRequestId(id)
+                .processor("pro")
+                .addArg("test", "this")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            put("bufferSize", 1);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        try {
+            binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
+            fail("Should have a buffer size that is too small");
+        } catch (Exception ex) {
+            final Throwable root = ExceptionUtils.getRootCause(ex);
+            assertThat(root, instanceOf(KryoException.class));
+        }
+    }
+
+    @Test
+    public void shouldReturnAllBytesInRequest() throws Exception {
+        final UUID id = UUID.randomUUID();
+
+        final RequestMessage request = RequestMessage.build("try")
+                .overrideRequestId(id)
+                .processor("pro")
+                .addArg("test", "this")
+                .create();
+
+        final MessageSerializer binarySerializerWithSmallBuffer = new GryoLiteMessageSerializerV1d0();
+        final Map<String, Object> configWithSmallBuffer = new HashMap<String, Object>() {{
+            // set to bufferSize < total message size but still greater than any individual object requires
+            put("bufferSize", 50);
+        }};
+        binarySerializerWithSmallBuffer.configure(configWithSmallBuffer, null);
+
+        ByteBuf buf = binarySerializerWithSmallBuffer.serializeRequestAsBinary(request, allocator);
+        assertTrue(buf.isReadable());
+        assertEquals(76, buf.readableBytes());
+    }
+
+    private void assertCommon(final ResponseMessage response) {
+        assertEquals(requestId, response.getRequestId());
+        assertEquals(ResponseStatusCode.SUCCESS, response.getStatus().getCode());
+    }
+
+    private ResponseMessage convertBinary(final Object toSerialize) throws SerializationException {
+        final ByteBuf bb = binarySerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
+        return binarySerializer.deserializeResponse(bb);
+    }
+
+    private ResponseMessage convertText(final Object toSerialize) throws SerializationException {
+        final ByteBuf bb = textSerializer.serializeResponseAsBinary(responseMessageBuilder.result(toSerialize).create(), allocator);
+        return textSerializer.deserializeResponse(bb);
+    }
+
+    public static class ErrorOnlyClassResolverSupplierAsInstance implements Supplier<ClassResolver> {
+
+        private static final ErrorOnlyClassResolverSupplierAsInstance instance = new ErrorOnlyClassResolverSupplierAsInstance();
+
+        private ErrorOnlyClassResolverSupplierAsInstance() {}
+
+        public static ErrorOnlyClassResolverSupplierAsInstance getInstance() {
+            return instance;
+        }
+
+        @Override
+        public ClassResolver get() {
+            return new ErrorOnlyClassResolver();
+        }
+    }
+
+    public static class ErrorOnlyClassResolverSupplier implements Supplier<ClassResolver> {
+        @Override
+        public ClassResolver get() {
+            return new ErrorOnlyClassResolver();
+        }
+    }
+
+    public static class ErrorOnlyClassResolver extends GryoClassResolver {
+        @Override
+        public Registration getRegistration(Class clazz) {
+            throw new RuntimeException("Registration is not allowed with this ClassResolver - it is not a good implementation");
+        }
+    }
+
+    public static class ColorIoRegistry extends AbstractIoRegistry {
+        public ColorIoRegistry() {
+            register(GryoIo.class, Color.class, new ColorSerializer());
+        }
+    }
+
+    public static class ColorSerializer extends Serializer<Color> {
+        @Override
+        public void write(final Kryo kryo, final Output output, final Color color) {
+            output.write(color.equals(Color.RED) ? 1 : 0);
+        }
+
+        @Override
+        public Color read(final Kryo kryo, final Input input, final Class<Color> aClass) {
+            return input.read() == 1 ? Color.RED : Color.BLACK;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
index bb731a9..4064f49 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GryoMessageSerializerV1d0Test.java
@@ -49,7 +49,7 @@ import org.apache.tinkerpop.shaded.kryo.io.Input;
 import org.apache.tinkerpop.shaded.kryo.io.Output;
 import org.junit.Test;
 
-import java.awt.*;
+import java.awt.Color;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-classic.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-classic.yaml b/gremlin-server/conf/gremlin-server-classic.yaml
index 0ac4a58..388a27e 100644
--- a/gremlin-server/conf/gremlin-server-classic.yaml
+++ b/gremlin-server/conf/gremlin-server-classic.yaml
@@ -31,6 +31,7 @@ scriptEngines: {
     scripts: [scripts/complex-lifecycle.groovy]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
 metrics: {
   slf4jReporter: {enabled: true, interval: 180000}}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-modern-readonly.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-modern-readonly.yaml b/gremlin-server/conf/gremlin-server-modern-readonly.yaml
index cc0b0ad..5214b50 100644
--- a/gremlin-server/conf/gremlin-server-modern-readonly.yaml
+++ b/gremlin-server/conf/gremlin-server-modern-readonly.yaml
@@ -31,6 +31,7 @@ scriptEngines: {
     scripts: [scripts/generate-modern-readonly.groovy]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}   # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
 metrics: {
   slf4jReporter: {enabled: true, interval: 180000}}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-modern.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-modern.yaml b/gremlin-server/conf/gremlin-server-modern.yaml
index c97ae14..cec7f81 100644
--- a/gremlin-server/conf/gremlin-server-modern.yaml
+++ b/gremlin-server/conf/gremlin-server-modern.yaml
@@ -31,6 +31,7 @@ scriptEngines: {
     scripts: [scripts/generate-modern.groovy]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}       # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}   # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
 metrics: {
   slf4jReporter: {enabled: true, interval: 180000}}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-neo4j.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-neo4j.yaml b/gremlin-server/conf/gremlin-server-neo4j.yaml
index d32ce8c..55aa170 100644
--- a/gremlin-server/conf/gremlin-server-neo4j.yaml
+++ b/gremlin-server/conf/gremlin-server-neo4j.yaml
@@ -45,6 +45,7 @@ scriptEngines: {
       staticImports: [java.lang.Math.PI]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-rest-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-rest-secure.yaml b/gremlin-server/conf/gremlin-server-rest-secure.yaml
index ff5c550..fd04855 100644
--- a/gremlin-server/conf/gremlin-server-rest-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-rest-secure.yaml
@@ -44,8 +44,6 @@ scriptEngines: {
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TimedInterruptCustomizerProvider":[10000],
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}}
 serializers:
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
-  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json
 processors:

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-secure.yaml b/gremlin-server/conf/gremlin-server-secure.yaml
index 8189fef..4597187 100644
--- a/gremlin-server/conf/gremlin-server-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-secure.yaml
@@ -45,6 +45,7 @@ scriptEngines: {
               "org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider":["org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.SimpleSandboxExtension"]}}}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server-spark.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-spark.yaml b/gremlin-server/conf/gremlin-server-spark.yaml
index a0467fc..9340611 100644
--- a/gremlin-server/conf/gremlin-server-spark.yaml
+++ b/gremlin-server/conf/gremlin-server-spark.yaml
@@ -58,6 +58,7 @@ scriptEngines: {
       staticImports: [java.lang.Math.PI]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/conf/gremlin-server.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server.yaml b/gremlin-server/conf/gremlin-server.yaml
index 0723553..c05ac27 100644
--- a/gremlin-server/conf/gremlin-server.yaml
+++ b/gremlin-server/conf/gremlin-server.yaml
@@ -35,6 +35,7 @@ scriptEngines: {
       staticImports: [java.lang.Math.PI]}}
 serializers:
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}            # application/vnd.gremlin-v1.0+gryo
+  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/vnd.gremlin-v1.0+gryo-lite
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}        # application/vnd.gremlin-v1.0+gryo-stringd
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }} # application/vnd.gremlin-v1.0+json
   - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}        # application/json

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5b6394c5/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
index 129f1a0..3a4ab27 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinResultSetIntegrateTest.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.driver.MessageSerializer;
 import org.apache.tinkerpop.gremlin.driver.Result;
 import org.apache.tinkerpop.gremlin.driver.ResultSet;
 import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0;
+import org.apache.tinkerpop.gremlin.driver.ser.Serializers;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -38,8 +39,10 @@ import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistry;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.hamcrest.CoreMatchers;
 import org.junit.After;
 import org.junit.Before;
@@ -164,6 +167,19 @@ public class GremlinResultSetIntegrateTest extends AbstractGremlinServerIntegrat
     }
 
     @Test
+    public void shouldHandleVertexResultWithLiteSerialization() throws Exception {
+        final Cluster cluster = Cluster.build().serializer(Serializers.GRYO_LITE_V1D0).create();
+        final Client clientLite = cluster.connect();
+        final ResultSet results = clientLite.submit("g.V(1).next()");
+        final Vertex v = results.all().get().get(0).getVertex();
+        assertThat(v, instanceOf(ReferenceVertex.class));
+
+        assertEquals(1L, v.id());
+        assertEquals("", v.label());
+        assertEquals(0, IteratorUtils.count(v.properties()));
+    }
+
+    @Test
     public void shouldHandleVertexPropertyResult() throws Exception {
         final ResultSet results = client.submit("g.V().properties('name').next()");
         final VertexProperty<String> v = results.all().get().get(0).getVertexProperty();


[05/49] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/TINKERPOP-1088' into tp31

Posted by dk...@apache.org.
Merge remote-tracking branch 'origin/TINKERPOP-1088' into tp31


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

Branch: refs/heads/TINKERPOP-1298
Commit: 55a509f2b1fb9d9f1787940197f99c95beb4d0d0
Parents: aa447eb 636b2e5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 24 14:47:54 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 24 14:47:54 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../traversal/step/sideEffect/SubgraphStep.java | 19 +++++-----
 .../step/sideEffect/GroovySubgraphTest.groovy   |  5 +++
 .../traversal/step/sideEffect/SubgraphTest.java | 38 ++++++++++++++++++--
 4 files changed, 52 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


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


[02/49] incubator-tinkerpop git commit: fixed the NPE that occurs in OLAP when you have a local/OLTP group() nested within an OLAP group(). The solution is elegant, but the problem, its not as efficient as the code when we had the NPE.... dar. Going to f

Posted by dk...@apache.org.
fixed the NPE that occurs in OLAP when you have a local/OLTP group() nested within an OLAP group(). The solution is elegant, but the problem, its not as efficient as the code when we had the NPE.... dar. Going to fiddle some more tomorrow to see if I can get it faster --- 600ms vs 400ms differences.


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

Branch: refs/heads/TINKERPOP-1298
Commit: c890cebad5231cdab8744878bebb4ea363689a3a
Parents: 44d40f6
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon May 23 16:24:58 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon May 23 16:24:58 2016 -0600

----------------------------------------------------------------------
 .../process/traversal/step/map/GroupStep.java   | 210 ++++++++++---------
 .../step/sideEffect/GroupSideEffectStep.java    |  59 ++----
 .../step/sideEffect/GroovyGroupTest.groovy      |   5 +
 .../traversal/step/sideEffect/GroupTest.java    |  42 ++++
 .../SparkStarBarrierInterceptor.java            |   1 -
 .../structure/TinkerGraphPlayTest.java          |   4 +-
 6 files changed, 176 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c890ceba/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
index 4f5df35..b430d8f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
@@ -29,7 +29,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.lambda.IdentityTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.lambda.TokenTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating;
-import org.apache.tinkerpop.gremlin.process.traversal.step.GraphComputing;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
@@ -39,6 +38,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 import org.apache.tinkerpop.gremlin.util.function.HashMapSupplier;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
+import org.javatuples.Pair;
 
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -46,25 +46,24 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Set;
 import java.util.function.BinaryOperator;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>> implements ByModulating, TraversalParent, GraphComputing {
+public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>> implements ByModulating, TraversalParent {
 
     private char state = 'k';
     private Traversal.Admin<S, K> keyTraversal = null;
-    private Traversal.Admin<S, V> valueTraversal = this.integrateChild(__.fold().asAdmin());
-    private Traversal.Admin<S, ?> preTraversal = null;      // used in OLAP
-    private ReducingBarrierStep reducingBarrierStep = null; // used in OLAP
-    private boolean onGraphComputer = false;
+    private Traversal.Admin<S, ?> preTraversal;
+    private Traversal.Admin<S, V> valueTraversal;
 
     public GroupStep(final Traversal.Admin traversal) {
         super(traversal);
-        this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal, this.onGraphComputer));
+        this.valueTraversal = this.integrateChild(__.fold().asAdmin());
+        this.preTraversal = this.integrateChild(splitOnBarrierStep(this.valueTraversal).get(0));
+        this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal));
         this.setSeedSupplier(HashMapSupplier.instance());
     }
 
@@ -75,7 +74,8 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
             this.state = 'v';
         } else if ('v' == this.state) {
             this.valueTraversal = this.integrateChild(convertValueTraversal(kvTraversal));
-            this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal, this.onGraphComputer));
+            this.preTraversal = this.integrateChild(splitOnBarrierStep(this.valueTraversal).get(0));
+            this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal));
             this.state = 'x';
         } else {
             throw new IllegalStateException("The key and value traversals for group()-step have already been set: " + this);
@@ -85,21 +85,11 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
     @Override
     public Map<K, V> projectTraverser(final Traverser.Admin<S> traverser) {
         final Map<K, V> map = new HashMap<>(1);
-        final K key = TraversalUtil.applyNullable(traverser, this.keyTraversal);
-        if (this.onGraphComputer) {
-            if (null == this.reducingBarrierStep) {
-                final TraverserSet traverserSet = new TraverserSet();
-                this.preTraversal.reset();
-                this.preTraversal.addStart(traverser.split());
-                this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
-                map.put(key, (V) traverserSet);
-            } else {
-                this.valueTraversal.reset();
-                this.valueTraversal.addStart(traverser.split());
-                map.put(key, (V) this.reducingBarrierStep.nextBarrier());
-            }
-        } else
-            map.put(key, (V) traverser);
+        final TraverserSet traverserSet = new TraverserSet<>();
+        this.preTraversal.reset();
+        this.preTraversal.addStart(traverser.split());
+        this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
+        map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverserSet);
         return map;
     }
 
@@ -128,11 +118,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
         if (null != this.keyTraversal)
             clone.keyTraversal = this.keyTraversal.clone();
         clone.valueTraversal = this.valueTraversal.clone();
-        if (null != this.preTraversal)
-            clone.preTraversal = this.preTraversal.clone();
-        final Optional<Barrier> optional = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, clone.valueTraversal);
-        if (optional.isPresent() && optional.get() instanceof ReducingBarrierStep)
-            clone.reducingBarrierStep = (ReducingBarrierStep) optional.get();
+        clone.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(clone.valueTraversal).get(0));
         return clone;
     }
 
@@ -154,37 +140,19 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
 
     @Override
     public Map<K, V> generateFinalResult(final Map<K, V> object) {
-        return GroupStep.doFinalReduction((Map<K, Object>) object, this.valueTraversal, this.onGraphComputer);
-    }
-
-    @Override
-    public void onGraphComputer() {
-        this.preTraversal = this.integrateChild(splitOnBarrierStep(this.valueTraversal).get(0));
-        final Optional<Barrier> optional = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal);
-        if (optional.isPresent() && optional.get() instanceof ReducingBarrierStep)
-            this.reducingBarrierStep = (ReducingBarrierStep) optional.get();
-        this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal, this.onGraphComputer = true));
+        return GroupStep.doFinalReduction((Map<K, Object>) object, this.valueTraversal);
     }
 
     ///////////////////////
 
     public static final class GroupBiOperator<K, V> implements BinaryOperator<Map<K, V>>, Serializable {
 
-        private boolean onGraphComputer;
-        private BinaryOperator reducingBinaryOperator;          // OLAP (w/ reducer)
-        private transient Traversal.Admin<?, V> valueTraversal; // OLTP
-        private transient Map<K, Integer> counters;             // OLTP
+        private Traversal.Admin<?, V> valueTraversal;
+        private ReducingBarrierStep reducingBarrierStep = null;
 
-        public GroupBiOperator(final Traversal.Admin<?, V> valueTraversal, final boolean onGraphComputer) {
-            this.onGraphComputer = onGraphComputer;
-            if (this.onGraphComputer) {
-                final Optional<Barrier> optional = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal);
-                if (optional.isPresent() && optional.get() instanceof ReducingBarrierStep)
-                    this.reducingBinaryOperator = ((ReducingBarrierStep) optional.get()).getBiOperator();
-            } else {
-                this.valueTraversal = valueTraversal;
-                this.counters = new HashMap<>();
-            }
+        public GroupBiOperator(final Traversal.Admin<?, V> valueTraversal) {
+            this.valueTraversal = valueTraversal.clone();
+            this.reducingBarrierStep = TraversalHelper.getFirstStepOfAssignableClass(ReducingBarrierStep.class, this.valueTraversal).orElse(null);
         }
 
         public GroupBiOperator() {
@@ -194,43 +162,84 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
         @Override
         public Map<K, V> apply(final Map<K, V> mapA, final Map<K, V> mapB) {
             for (final K key : mapB.keySet()) {
-                if (this.onGraphComputer) {
-                    final Object objectB = mapB.get(key);
-                    if (null != this.reducingBinaryOperator) {
-                        // OLAP -- if there is a mid-traversal, apply the binary reducer and propagate the mutating barrier
-                        final Object objectA = mapA.get(key);
-                        mapA.put(key, (V) (null == objectA ? objectB : this.reducingBinaryOperator.apply(objectA, objectB)));
-                    } else {
-                        // OLAP -- if there is no mid-traversal reducer, aggregate pre-barrier traversers into a traverser set (expensive, but that's that)
-                        final Object objectA = mapA.get(key);
-                        final TraverserSet traverserSet;
-                        if (null == objectA) {
-                            traverserSet = new TraverserSet();
-                            mapA.put(key, (V) traverserSet);
-                        } else
-                            traverserSet = (TraverserSet) objectA;
-                        traverserSet.addAll((TraverserSet) objectB);
-                    }
+                Object objectA = mapA.get(key);
+                final Object objectB = mapB.get(key);
+                assert null != objectB;
+                if (null == objectA) {
+                    objectA = objectB;
                 } else {
-                    // OLTP -- do mid-barrier reductions if they exist, else don't. Bulking is also available here because of addStart() prior to barrier.
-                    final Traverser.Admin traverser = (Traverser.Admin) mapB.get(key);
-                    Traversal.Admin valueTraversalClone = (Traversal.Admin) mapA.get(key);
-                    if (null == valueTraversalClone) {
-                        this.counters.put(key, 0);
-                        valueTraversalClone = this.valueTraversal.clone();
-                        mapA.put(key, (V) valueTraversalClone);
-                    }
-                    valueTraversalClone.addStart(traverser);
-                    if (this.counters.compute(key, (k, i) -> ++i) > 1000) {
-                        this.counters.put(key, 0);
-                        TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversalClone).ifPresent(Barrier::processAllStarts);
+                    if (objectA instanceof TraverserSet) {
+                        if (objectB instanceof TraverserSet) {
+                            final TraverserSet set = (TraverserSet) objectA;
+                            set.addAll((TraverserSet) objectB);
+                            if (null != this.reducingBarrierStep && set.size() > 1000) {
+                                this.valueTraversal.reset();
+                                this.reducingBarrierStep.addStarts(set.iterator());
+                                objectA = this.reducingBarrierStep.nextBarrier();
+                            }
+                        } else if (objectB instanceof Pair) {
+                            final TraverserSet set = (TraverserSet) objectA;
+                            set.addAll((TraverserSet) ((Pair) objectB).getValue0());
+                            if (set.size() > 1000) {
+                                this.valueTraversal.reset();
+                                this.reducingBarrierStep.addStarts(set.iterator());
+                                this.reducingBarrierStep.addBarrier(((Pair) objectB).getValue1());
+                                objectA = this.reducingBarrierStep.nextBarrier();
+                            } else {
+                                objectA = Pair.with(set, ((Pair) objectB).getValue1());
+                            }
+                        } else {
+                            objectA = Pair.with(objectA, objectB);
+                        }
+                    } else if (objectA instanceof Pair) {
+                        if (objectB instanceof TraverserSet) {
+                            final TraverserSet set = (TraverserSet) ((Pair) objectA).getValue0();
+                            set.addAll((TraverserSet) objectB);
+                            if (null != this.reducingBarrierStep &&set.size() > 1000) {
+                                this.valueTraversal.reset();
+                                this.reducingBarrierStep.addStarts(set.iterator());
+                                this.reducingBarrierStep.addBarrier(((Pair) objectA).getValue1());
+                                objectA = this.reducingBarrierStep.nextBarrier();
+                            }
+                        } else if (objectB instanceof Pair) {
+                            this.valueTraversal.reset();
+                            this.reducingBarrierStep.addBarrier(((Pair) objectA).getValue1());
+                            this.reducingBarrierStep.addBarrier(((Pair) objectB).getValue1());
+                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
+                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectB).getValue0()).iterator());
+                            objectA = this.reducingBarrierStep.nextBarrier();
+                        } else {
+                            this.valueTraversal.reset();
+                            this.reducingBarrierStep.addBarrier(((Pair) objectA).getValue1());
+                            this.reducingBarrierStep.addBarrier(objectB);
+                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
+                            objectA = this.reducingBarrierStep.nextBarrier();
+                        }
+                    } else {
+                        if (objectB instanceof TraverserSet) {
+                            objectA = Pair.with(objectB, objectA);
+                        } else if (objectB instanceof Pair) {
+                            this.valueTraversal.reset();
+                            this.reducingBarrierStep.addBarrier(objectA);
+                            this.reducingBarrierStep.addBarrier(((Pair) objectB).getValue1());
+                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectB).getValue0()).iterator());
+                            objectA = this.reducingBarrierStep.nextBarrier();
+                        } else {
+                            this.valueTraversal.reset();
+                            this.reducingBarrierStep.addBarrier(objectA);
+                            this.reducingBarrierStep.addBarrier(objectB);
+                            objectA = this.reducingBarrierStep.nextBarrier();
+                        }
                     }
                 }
+                mapA.put(key, (V) objectA);
             }
             return mapA;
+
         }
     }
 
+
     ///////////////////////
 
     public static <S, E> Traversal.Admin<S, E> convertValueTraversal(final Traversal.Admin<S, E> valueTraversal) {
@@ -263,26 +272,25 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
         }
     }
 
-    public static <K, V> Map<K, V> doFinalReduction(final Map<K, Object> map, final Traversal.Admin<?, V> valueTraversal, final boolean onGraphComputer) {
+    public static <K, V> Map<K, V> doFinalReduction(final Map<K, Object> map, final Traversal.Admin<?, V> valueTraversal) {
         final Map<K, V> reducedMap = new HashMap<>(map.size());
-        // if not on OLAP, who cares --- don't waste time computing barriers
-        final boolean hasReducingBarrier = onGraphComputer &&
-                TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal).isPresent() &&
-                TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal).get() instanceof ReducingBarrierStep;
-        final Traversal.Admin<?, ?> postTraversal = (onGraphComputer & !hasReducingBarrier) ? splitOnBarrierStep(valueTraversal.clone()).get(1) : null;
+        final ReducingBarrierStep reducingBarrierStep = TraversalHelper.getFirstStepOfAssignableClass(ReducingBarrierStep.class, valueTraversal).orElse(null);
         IteratorUtils.removeOnNext(map.entrySet().iterator()).forEachRemaining(entry -> {
-            if (onGraphComputer) {
-                if (hasReducingBarrier) {   // OLAP with reduction (barrier)
-                    valueTraversal.reset();
-                    TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal).get().addBarrier(entry.getValue());
-                    reducedMap.put(entry.getKey(), valueTraversal.next());
-                } else {                    // OLAP without reduction (traverser set)
-                    postTraversal.reset();
-                    postTraversal.addStarts(((TraverserSet) entry.getValue()).iterator());
-                    reducedMap.put(entry.getKey(), (V) postTraversal.next());
-                }
-            } else                          // OLTP is just a traversal
-                reducedMap.put(entry.getKey(), ((Traversal.Admin<?, V>) entry.getValue()).next());
+            valueTraversal.reset();
+            if (null == reducingBarrierStep) {
+                reducedMap.put(entry.getKey(), entry.getValue() instanceof TraverserSet ?
+                        ((TraverserSet<V>) entry.getValue()).iterator().next().get() :
+                        (V) entry.getValue());
+            } else {
+                if (entry.getValue() instanceof TraverserSet)
+                    reducingBarrierStep.addStarts(((TraverserSet) entry.getValue()).iterator());
+                else if (entry.getValue() instanceof Pair) {
+                    reducingBarrierStep.addStarts(((TraverserSet) (((Pair) entry.getValue()).getValue0())).iterator());
+                    reducingBarrierStep.addBarrier((((Pair) entry.getValue()).getValue1()));
+                } else
+                    reducingBarrierStep.addBarrier(entry.getValue());
+                reducedMap.put(entry.getKey(), valueTraversal.next());
+            }
         });
         assert map.isEmpty();
         map.clear();
@@ -290,3 +298,5 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
         return (Map<K, V>) map;
     }
 }
+
+

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c890ceba/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
index a906312..4fc4ffa 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
@@ -21,16 +21,12 @@ package org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 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.Barrier;
 import org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating;
-import org.apache.tinkerpop.gremlin.process.traversal.step.GraphComputing;
 import org.apache.tinkerpop.gremlin.process.traversal.step.SideEffectCapable;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.GroupStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 import org.apache.tinkerpop.gremlin.util.function.HashMapSupplier;
@@ -39,27 +35,26 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Set;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implements SideEffectCapable<Map<K, ?>, Map<K, V>>, TraversalParent, ByModulating, GraphComputing {
+public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implements SideEffectCapable<Map<K, ?>, Map<K, V>>, TraversalParent, ByModulating {
 
     private char state = 'k';
     private Traversal.Admin<S, K> keyTraversal = null;
+    private Traversal.Admin<S, ?> preTraversal = null;
     private Traversal.Admin<S, V> valueTraversal = this.integrateChild(__.fold().asAdmin());
-    private Traversal.Admin<S, ?> preTraversal = null;      // used in OLAP
-    private ReducingBarrierStep reducingBarrierStep = null; // used in OLAP
-    private boolean onGraphComputer = false;
     ///
     private String sideEffectKey;
 
     public GroupSideEffectStep(final Traversal.Admin traversal, final String sideEffectKey) {
         super(traversal);
         this.sideEffectKey = sideEffectKey;
-        this.getTraversal().getSideEffects().registerIfAbsent(this.sideEffectKey, HashMapSupplier.instance(), new GroupStep.GroupBiOperator<>(this.valueTraversal, this.onGraphComputer));
+        this.valueTraversal = this.integrateChild(__.fold().asAdmin());
+        this.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(this.valueTraversal).get(0));
+        this.getTraversal().getSideEffects().registerIfAbsent(this.sideEffectKey, HashMapSupplier.instance(), new GroupStep.GroupBiOperator<>(this.valueTraversal));
     }
 
     @Override
@@ -69,7 +64,8 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
             this.state = 'v';
         } else if ('v' == this.state) {
             this.valueTraversal = this.integrateChild(GroupStep.convertValueTraversal(kvTraversal));
-            this.getTraversal().getSideEffects().register(this.sideEffectKey, null, new GroupStep.GroupBiOperator<>(this.valueTraversal, this.onGraphComputer));
+            this.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(this.valueTraversal).get(0));
+            this.getTraversal().getSideEffects().register(this.sideEffectKey, null, new GroupStep.GroupBiOperator<>(this.valueTraversal));
             this.state = 'x';
         } else {
             throw new IllegalStateException("The key and value traversals for group()-step have already been set: " + this);
@@ -78,22 +74,14 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
 
     @Override
     protected void sideEffect(final Traverser.Admin<S> traverser) {
-        final Map<K, Object> map = new HashMap<>(1);
-        final K key = TraversalUtil.applyNullable(traverser, this.keyTraversal);
-        if (this.onGraphComputer) {
-            if (null == this.reducingBarrierStep) {
-                final TraverserSet traverserSet = new TraverserSet<>();
-                this.preTraversal.reset();
-                this.preTraversal.addStart(traverser.split());
-                this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
-                map.put(key, traverserSet);
-            } else {
-                this.valueTraversal.reset();
-                this.valueTraversal.addStart(traverser.split());
-                map.put(key, (V) this.reducingBarrierStep.nextBarrier());
-            }
-        } else
-            map.put(key, traverser.split());
+        final Map<K, V> map = new HashMap<>(1);
+        final TraverserSet midTraversers = new TraverserSet<>();
+        this.preTraversal.reset();
+        this.preTraversal.addStart(traverser.split());
+        while (this.preTraversal.hasNext()) {
+            midTraversers.add(this.preTraversal.getEndStep().next());
+        }
+        map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) midTraversers);
         this.getTraversal().getSideEffects().add(this.sideEffectKey, map);
     }
 
@@ -127,11 +115,7 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
         if (null != this.keyTraversal)
             clone.keyTraversal = this.keyTraversal.clone();
         clone.valueTraversal = this.valueTraversal.clone();
-        if (null != this.preTraversal)
-            clone.preTraversal = this.preTraversal.clone();
-        final Optional<Barrier> optional = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, clone.valueTraversal);
-        if (optional.isPresent() && optional.get() instanceof ReducingBarrierStep)
-            clone.reducingBarrierStep = (ReducingBarrierStep) optional.get();
+        clone.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(clone.valueTraversal).get(0));
         return clone;
     }
 
@@ -153,15 +137,6 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
 
     @Override
     public Map<K, V> generateFinalResult(final Map<K, ?> object) {
-        return GroupStep.doFinalReduction((Map<K, Object>) object, this.valueTraversal, this.onGraphComputer);
-    }
-
-    @Override
-    public void onGraphComputer() {
-        this.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(this.valueTraversal).get(0));
-        final Optional<Barrier> optional = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal);
-        if (optional.isPresent() && optional.get() instanceof ReducingBarrierStep)
-            this.reducingBarrierStep = (ReducingBarrierStep) optional.get();
-        this.getTraversal().getSideEffects().register(this.sideEffectKey, null, new GroupStep.GroupBiOperator<>(this.valueTraversal, this.onGraphComputer = true));
+        return GroupStep.doFinalReduction((Map<K, Object>) object, this.valueTraversal);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c890ceba/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
index 619815f..ddfb94a 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
@@ -108,5 +108,10 @@ public abstract class GroovyGroupTest {
         public Traversal<Vertex, Map<String, Map<Object, Object>>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX() {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(union(out('knows').group('a').by('age'), out('created').group('b').by('name').by(count())).group('a').by('name')).times(2).cap('a', 'b')")
         }
+
+        @Override
+        public Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group().by(bothE().count).by(group.by(label))")
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c890ceba/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
index d844ba7..d4c4d74 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
@@ -84,6 +84,8 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Map<String, Map<Object, Object>>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX();
 
+    public abstract Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_group_byXnameX() {
@@ -356,6 +358,41 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
         checkSideEffects(traversal.asAdmin().getSideEffects(), "a", HashMap.class, "b", HashMap.class);
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_group_byXbothE_countX_byXgroup_byXlabelXX() {
+        final Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> traversal = get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX();
+        final Map<Long, Map<String, List<Vertex>>> map = traversal.next();
+        assertFalse(traversal.hasNext());
+        assertEquals(2, map.size());
+        assertTrue(map.containsKey(1l));
+        assertTrue(map.containsKey(3l));
+        //
+        Map<String, List<Vertex>> submap = map.get(1l);
+        assertEquals(2, submap.size());
+        assertTrue(submap.containsKey("software"));
+        assertTrue(submap.containsKey("person"));
+        List<Vertex> list = submap.get("software");
+        assertEquals(1, list.size());
+        assertEquals(convertToVertex(graph, "ripple"), list.get(0));
+        list = submap.get("person");
+        assertEquals(2, list.size());
+        assertTrue(list.contains(convertToVertex(graph, "vadas")));
+        assertTrue(list.contains(convertToVertex(graph, "peter")));
+        //
+        submap = map.get(3l);
+        assertEquals(2, submap.size());
+        assertTrue(submap.containsKey("software"));
+        assertTrue(submap.containsKey("person"));
+        list = submap.get("software");
+        assertEquals(1, list.size());
+        assertEquals(convertToVertex(graph, "lop"), list.get(0));
+        list = submap.get("person");
+        assertEquals(2, list.size());
+        assertTrue(list.contains(convertToVertex(graph, "marko")));
+        assertTrue(list.contains(convertToVertex(graph, "josh")));
+    }
+
     public static class Traversals extends GroupTest {
 
         @Override
@@ -437,5 +474,10 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Map<String, Map<Object, Object>>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX() {
             return g.V().repeat(__.union(__.out("knows").group("a").by("age"), __.out("created").group("b").by("name").by(count())).group("a").by("name")).times(2).cap("a", "b");
         }
+
+        @Override
+        public Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX() {
+            return g.V().<Long, Map<String, List<Vertex>>>group().by(__.bothE().count()).by(__.group().by(T.label));
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c890ceba/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/process/computer/traversal/strategy/optimization/interceptor/SparkStarBarrierInterceptor.java
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/process/computer/traversal/strategy/optimization/interceptor/SparkStarBarrierInterceptor.java b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/process/computer/traversal/strategy/optimization/interceptor/SparkStarBarrierInterceptor.java
index 768d10a..5c6d729 100644
--- a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/process/computer/traversal/strategy/optimization/interceptor/SparkStarBarrierInterceptor.java
+++ b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/process/computer/traversal/strategy/optimization/interceptor/SparkStarBarrierInterceptor.java
@@ -126,7 +126,6 @@ public final class SparkStarBarrierInterceptor implements SparkVertexProgramInte
                 }
             }).fold(endStep.getSeedSupplier().get(), biOperator::apply);
         } else if (endStep instanceof GroupStep) {
-            ((GroupStep) endStep).onGraphComputer();
             final GroupStep.GroupBiOperator<Object, Object> biOperator = (GroupStep.GroupBiOperator) endStep.getBiOperator();
             result = ((GroupStep) endStep).generateFinalResult(nextRDD.
                     mapPartitions(partitions -> {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c890ceba/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git 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
index e339519..5557716 100644
--- 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
@@ -86,11 +86,11 @@ public class TinkerGraphPlayTest {
     @Ignore
     public void benchmarkGroup() throws Exception {
         Graph graph = TinkerGraph.open();
-        GraphTraversalSource g = graph.traversal().withComputer();
+        GraphTraversalSource g = graph.traversal();
         graph.io(GraphMLIo.build()).readGraph("../data/grateful-dead.xml");
         /////////
 
-        g.V().group().by(T.label).by(values("name")).forEachRemaining(x -> logger.info(x.toString()));
+        //g.V().group().by(T.label).by(values("name")).forEachRemaining(x -> logger.info(x.toString()));
 
         System.out.println("group: " + g.V().both("followedBy").both("followedBy").group().by("songType").by(count()).next());
         System.out.println("groupV3d0: " + g.V().both("followedBy").both("followedBy").groupV3d0().by("songType").by().by(__.count(Scope.local)).next());


[48/49] incubator-tinkerpop git commit: Don't let users mess with halted traversers. Instead simply provide all preformatted values.

Posted by dk...@apache.org.
Don't let users mess with halted traversers. Instead simply provide all preformatted values.


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

Branch: refs/heads/TINKERPOP-1298
Commit: d3292fb8940fb29d07dbf619032b3b6321a59896
Parents: f4cccc0
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Fri May 27 20:32:27 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue May 31 14:47:26 2016 +0200

----------------------------------------------------------------------
 data/script-csv-export.groovy                   | 15 +++-----
 .../bulkdumping/BulkExportVertexProgram.java    | 38 ++++++++++++++++----
 2 files changed, 36 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d3292fb8/data/script-csv-export.groovy
----------------------------------------------------------------------
diff --git a/data/script-csv-export.groovy b/data/script-csv-export.groovy
index 7a6da22..4e6d5b1 100644
--- a/data/script-csv-export.groovy
+++ b/data/script-csv-export.groovy
@@ -23,21 +23,14 @@ import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkExportVerte
 
 def stringify(vertex) {
   def result = null
-  def haltedTraversers = vertex.property(TraversalVertexProgram.HALTED_TRAVERSERS)
-  if (haltedTraversers.isPresent()) {
-    def properties = vertex.value(BulkExportVertexProgram.BULK_EXPORT_PROPERTIES).split("\1")*.split("\2", 2)*.toList()
+  def rows = vertex.property(BulkExportVertexProgram.BULK_EXPORT_PROPERTIES)
+  if (rows.isPresent()) {
     def writer = new StringWriter()
     def w = new CSVWriter(writer)
-    haltedTraversers.value().each { def t ->
-      def values = []
-      properties.each { def property, def format ->
-        def value = t.path(property)
-        values << (format.isEmpty() ? value.toString() : String.format(format, value))
-      }
-      w.writeNext((String[]) values, false)
+    rows.value().each { def row ->
+      w.writeNext((String[]) row, false)
     }
     result = writer.toString().trim()
-    writer.close()
   }
   return result
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d3292fb8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
index cdd6b28..8f65c11 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
@@ -29,6 +29,8 @@ import org.apache.tinkerpop.gremlin.process.computer.VertexComputeKey;
 import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.util.AbstractVertexProgramBuilder;
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -37,9 +39,13 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 import org.javatuples.Tuple;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @author Daniel Kuppitz (http://gremlin.guru)
@@ -50,7 +56,8 @@ public class BulkExportVertexProgram implements VertexProgram<Tuple> {
     public static final String BULK_EXPORT_PROPERTIES = String.join(".", BULK_EXPORT_VERTEX_PROGRAM_CFG_PREFIX, "properties");
 
     private Configuration configuration;
-    private String properties;
+    private Map<String, String> properties;
+    private List<String> sortedProperties;
     private Set<VertexComputeKey> vertexComputeKeys;
 
     private BulkExportVertexProgram() {
@@ -62,7 +69,13 @@ public class BulkExportVertexProgram implements VertexProgram<Tuple> {
         if (config != null) {
             ConfigurationUtils.copy(config, configuration);
         }
-        properties = configuration.getString(BULK_EXPORT_PROPERTIES);
+        properties = new HashMap<>();
+        sortedProperties = new ArrayList<>();
+        for (final String tuple : configuration.getString(BULK_EXPORT_PROPERTIES, "").split("\1")) {
+            final String[] parts = tuple.split("\2", -1);
+            properties.put(parts[0], parts[1]);
+            sortedProperties.add(parts[0]);
+        }
         vertexComputeKeys = Collections.singleton(VertexComputeKey.of(BULK_EXPORT_PROPERTIES, false));
     }
 
@@ -81,9 +94,23 @@ public class BulkExportVertexProgram implements VertexProgram<Tuple> {
     @Override
     public void execute(final Vertex sourceVertex, final Messenger<Tuple> messenger, final Memory memory) {
         final VertexProperty<TraverserSet> haltedTraversers = sourceVertex.property(TraversalVertexProgram.HALTED_TRAVERSERS);
-        if (haltedTraversers.isPresent()) {
-            sourceVertex.property(BULK_EXPORT_PROPERTIES, properties);
-        }
+        haltedTraversers.ifPresent(traverserSet -> {
+            final List<List<String>> rows = new ArrayList<>();
+            for (final Traverser t : (Iterable<Traverser>) traverserSet) {
+                final List<String> columns = new ArrayList<>();
+                final Path path = t.path();
+                final Iterable<String> keys = properties.isEmpty()
+                        ? t.path().labels().stream().flatMap(Collection::stream).sorted().collect(Collectors.toSet())
+                        : sortedProperties;
+                for (final String key : keys) {
+                    final String format = properties.getOrDefault(key, "");
+                    final Object value = path.get(key);
+                    columns.add("".equals(format) ? value.toString() : String.format(format, value));
+                }
+                rows.add(columns);
+            }
+            sourceVertex.property(BULK_EXPORT_PROPERTIES, rows);
+        });
     }
 
     @Override
@@ -139,7 +166,6 @@ public class BulkExportVertexProgram implements VertexProgram<Tuple> {
         @Override
         public BulkExportVertexProgram create(final Graph graph) {
             configuration.setProperty(BULK_EXPORT_PROPERTIES, String.join("\1", properties));
-            graph.configuration().setProperty("gremlin.hadoop.graphWriter", "org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptOutputFormat");
             return (BulkExportVertexProgram) VertexProgram.createVertexProgram(graph, configuration);
         }
 


[47/49] incubator-tinkerpop git commit: Added script and configuration file that can be used for OLAP CSV exports.

Posted by dk...@apache.org.
Added script and configuration file that can be used for OLAP CSV exports.


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

Branch: refs/heads/TINKERPOP-1298
Commit: f4cccc0942f5e98bf3fbacf65bac09c11aeb7269
Parents: df6cfd6
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Mon May 23 18:24:22 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue May 31 14:47:26 2016 +0200

----------------------------------------------------------------------
 data/script-csv-export.groovy                   | 43 +++++++++++++++
 .../conf/hadoop-csv-export.properties           | 56 ++++++++++++++++++++
 2 files changed, 99 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f4cccc09/data/script-csv-export.groovy
----------------------------------------------------------------------
diff --git a/data/script-csv-export.groovy b/data/script-csv-export.groovy
new file mode 100644
index 0000000..7a6da22
--- /dev/null
+++ b/data/script-csv-export.groovy
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+@Grab(group = 'com.opencsv', module = 'opencsv', version = '3.7')
+import com.opencsv.*
+
+import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkExportVertexProgram
+
+def stringify(vertex) {
+  def result = null
+  def haltedTraversers = vertex.property(TraversalVertexProgram.HALTED_TRAVERSERS)
+  if (haltedTraversers.isPresent()) {
+    def properties = vertex.value(BulkExportVertexProgram.BULK_EXPORT_PROPERTIES).split("\1")*.split("\2", 2)*.toList()
+    def writer = new StringWriter()
+    def w = new CSVWriter(writer)
+    haltedTraversers.value().each { def t ->
+      def values = []
+      properties.each { def property, def format ->
+        def value = t.path(property)
+        values << (format.isEmpty() ? value.toString() : String.format(format, value))
+      }
+      w.writeNext((String[]) values, false)
+    }
+    result = writer.toString().trim()
+    writer.close()
+  }
+  return result
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f4cccc09/hadoop-gremlin/conf/hadoop-csv-export.properties
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/conf/hadoop-csv-export.properties b/hadoop-gremlin/conf/hadoop-csv-export.properties
new file mode 100644
index 0000000..3e1f8da
--- /dev/null
+++ b/hadoop-gremlin/conf/hadoop-csv-export.properties
@@ -0,0 +1,56 @@
+# 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.
+gremlin.graph=org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph
+gremlin.hadoop.graphReader=org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat
+gremlin.hadoop.graphWriter=org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptOutputFormat
+gremlin.hadoop.jarsInDistributedCache=true
+gremlin.hadoop.defaultGraphComputer=org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer
+
+gremlin.hadoop.inputLocation=output
+gremlin.hadoop.scriptOutputFormat.script=script-csv-export.groovy
+gremlin.hadoop.outputLocation=export
+
+####################################
+# SparkGraphComputer Configuration #
+####################################
+spark.master=local[4]
+spark.executor.memory=1g
+spark.serializer=org.apache.tinkerpop.gremlin.spark.structure.io.gryo.GryoSerializer
+# spark.kryo.registrationRequired=true
+# spark.storage.memoryFraction=0.2
+# spark.eventLog.enabled=true
+# spark.eventLog.dir=/tmp/spark-event-logs
+# spark.ui.killEnabled=true
+
+#####################################
+# GiraphGraphComputer Configuration #
+#####################################
+giraph.minWorkers=2
+giraph.maxWorkers=2
+giraph.useOutOfCoreGraph=true
+giraph.useOutOfCoreMessages=true
+mapreduce.map.java.opts=-Xmx1024m
+mapreduce.reduce.java.opts=-Xmx1024m
+giraph.numInputThreads=2
+giraph.numComputeThreads=2
+# giraph.maxPartitionsInMemory=1
+# giraph.userPartitionCount=2
+## MapReduce of GiraphGraphComputer ##
+# mapreduce.job.maps=2
+# mapreduce.job.reduces=1
+
+


[34/49] incubator-tinkerpop git commit: Convert DOS to Unix. CTR.

Posted by dk...@apache.org.
Convert DOS to Unix. CTR.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 985170ecb5346008510ddd34a2c272a8faac390b
Parents: 0397f25
Author: Jason Plurad <pl...@apache.org>
Authored: Fri May 27 10:45:49 2016 -0400
Committer: Jason Plurad <pl...@apache.org>
Committed: Fri May 27 10:45:49 2016 -0400

----------------------------------------------------------------------
 gremlin-groovy/pom.xml | 276 ++++++++++++++++++++++----------------------
 gremlin-test/pom.xml   | 184 ++++++++++++++---------------
 2 files changed, 230 insertions(+), 230 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/985170ec/gremlin-groovy/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-groovy/pom.xml b/gremlin-groovy/pom.xml
index d94c35f..266962f 100644
--- a/gremlin-groovy/pom.xml
+++ b/gremlin-groovy/pom.xml
@@ -1,138 +1,138 @@
-<!--
-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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.tinkerpop</groupId>
-        <artifactId>tinkerpop</artifactId>
-        <version>3.2.1-SNAPSHOT</version>
-    </parent>
-    <artifactId>gremlin-groovy</artifactId>
-    <name>Apache TinkerPop :: Gremlin Groovy</name>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ivy</groupId>
-            <artifactId>ivy</artifactId>
-            <version>2.3.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-groovysh</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-json</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-jsr223</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.3.1</version>
-        </dependency>
-        <dependency>
-            <groupId>com.github.jeremyh</groupId>
-            <artifactId>jBCrypt</artifactId>
-            <version>jbcrypt-0.4</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-test</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-    <repositories>
-        <repository>
-            <id>hyracks-releases</id>
-            <url>http://obelix.ics.uci.edu/nexus/content/groups/hyracks-public-releases/</url>
-        </repository>
-        <repository>
-            <id>jitpack.io</id>
-            <url>https://jitpack.io</url>
-        </repository>
-    </repositories>
-    <build>
-        <directory>${basedir}/target</directory>
-        <finalName>${project.artifactId}-${project.version}</finalName>
-        <resources>
-            <resource>
-                <directory>${basedir}/src/main/resources
-                </directory>
-            </resource>
-        </resources>
-        <testResources>
-            <testResource>
-                <directory>${basedir}/src/test/resources
-                </directory>
-            </testResource>
-        </testResources>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.gmavenplus</groupId>
-                <artifactId>gmavenplus-plugin</artifactId>
-                <version>1.2</version>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>addSources</goal>
-                            <goal>addTestSources</goal>
-                            <goal>generateStubs</goal>
-                            <goal>compile</goal>
-                            <goal>testGenerateStubs</goal>
-                            <goal>testCompile</goal>
-                            <goal>removeStubs</goal>
-                            <goal>removeTestStubs</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <invokeDynamic>true</invokeDynamic>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-failsafe-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-</project>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tinkerpop</groupId>
+        <artifactId>tinkerpop</artifactId>
+        <version>3.2.1-SNAPSHOT</version>
+    </parent>
+    <artifactId>gremlin-groovy</artifactId>
+    <name>Apache TinkerPop :: Gremlin Groovy</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ivy</groupId>
+            <artifactId>ivy</artifactId>
+            <version>2.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-groovysh</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-json</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-jsr223</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.jeremyh</groupId>
+            <artifactId>jBCrypt</artifactId>
+            <version>jbcrypt-0.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-test</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <repositories>
+        <repository>
+            <id>hyracks-releases</id>
+            <url>http://obelix.ics.uci.edu/nexus/content/groups/hyracks-public-releases/</url>
+        </repository>
+        <repository>
+            <id>jitpack.io</id>
+            <url>https://jitpack.io</url>
+        </repository>
+    </repositories>
+    <build>
+        <directory>${basedir}/target</directory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <resources>
+            <resource>
+                <directory>${basedir}/src/main/resources
+                </directory>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>${basedir}/src/test/resources
+                </directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.gmavenplus</groupId>
+                <artifactId>gmavenplus-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>addSources</goal>
+                            <goal>addTestSources</goal>
+                            <goal>generateStubs</goal>
+                            <goal>compile</goal>
+                            <goal>testGenerateStubs</goal>
+                            <goal>testCompile</goal>
+                            <goal>removeStubs</goal>
+                            <goal>removeTestStubs</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <invokeDynamic>true</invokeDynamic>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/985170ec/gremlin-test/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-test/pom.xml b/gremlin-test/pom.xml
index 2293463..ee362b3 100644
--- a/gremlin-test/pom.xml
+++ b/gremlin-test/pom.xml
@@ -1,92 +1,92 @@
-<!--
-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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.tinkerpop</groupId>
-        <artifactId>tinkerpop</artifactId>
-        <version>3.2.1-SNAPSHOT</version>
-    </parent>
-    <artifactId>gremlin-test</artifactId>
-    <name>Apache TinkerPop :: Gremlin Test</name>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>com.carrotsearch</groupId>
-            <artifactId>junit-benchmarks</artifactId>
-            <version>0.7.2</version>
-        </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <version>1.3.171</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.4</version>
-        </dependency>
-        <!-- TESTING -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <version>1.9.5</version>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-all</artifactId>
-            <version>1.3</version>
-        </dependency>
-    </dependencies>
-    <build>
-        <directory>${basedir}/target</directory>
-        <finalName>${project.artifactId}-${project.version}</finalName>
-        <resources>
-            <resource>
-                <directory>${basedir}/src/main/resources
-                </directory>
-            </resource>
-        </resources>
-        <testResources>
-            <testResource>
-                <directory>${basedir}/src/test/resources
-                </directory>
-            </testResource>
-        </testResources>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-failsafe-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-</project>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tinkerpop</groupId>
+        <artifactId>tinkerpop</artifactId>
+        <version>3.2.1-SNAPSHOT</version>
+    </parent>
+    <artifactId>gremlin-test</artifactId>
+    <name>Apache TinkerPop :: Gremlin Test</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.carrotsearch</groupId>
+            <artifactId>junit-benchmarks</artifactId>
+            <version>0.7.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <version>1.3.171</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <!-- TESTING -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <version>1.3</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <directory>${basedir}/target</directory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <resources>
+            <resource>
+                <directory>${basedir}/src/main/resources
+                </directory>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>${basedir}/src/test/resources
+                </directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>


[28/49] incubator-tinkerpop git commit: Covered a lot more query pattens in `RangeByIsCountStrategy`.

Posted by dk...@apache.org.
Covered a lot more query pattens in `RangeByIsCountStrategy`.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 498585b5311f45fbda97b4fa863fd08090df8965
Parents: d55897a
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 14:58:12 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:37 2016 +0200

----------------------------------------------------------------------
 .../optimization/RangeByIsCountStrategy.java       | 17 ++++++++++++++---
 .../optimization/RangeByIsCountStrategyTest.java   | 16 ++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/498585b5/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 2994085..09aa730 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
@@ -25,10 +25,13 @@ 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.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 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.sideEffect.SideEffectStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
@@ -70,6 +73,7 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
+        final TraversalParent parent = traversal.getParent();
         int size = traversal.getSteps().size();
         Step prev = null;
         for (int i = 0; i < size; i++) {
@@ -89,8 +93,11 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             final Long highRangeCandidate = ((Number) value).longValue() + highRangeOffset;
                             final boolean update = highRange == null || highRangeCandidate > highRange;
                             if (update) {
+                                final boolean isNested = !(parent instanceof EmptyStep);
                                 highRange = highRangeCandidate;
                                 useNotStep = curr.getLabels().isEmpty() && next.getLabels().isEmpty()
+                                        && (!isNested || parent instanceof SideEffectStep)
+                                        && next.getNextStep() instanceof EmptyStep
                                         && ((highRange <= 1L && predicate.equals(Compare.lt))
                                         || (highRange == 1L && (predicate.equals(Compare.eq) || predicate.equals(Compare.lte))));
                             }
@@ -111,9 +118,13 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             traversal.asAdmin().removeStep(next); // IsStep
                             traversal.asAdmin().removeStep(curr); // CountStep
                             size -= 2;
-                            final Traversal.Admin inner = __.start().asAdmin();
-                            TraversalHelper.insertAfterStep(prev, inner.getStartStep(), inner);
-                            TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal);
+                            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()));
+                            }
                         } else {
                             TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal, 0L, highRange), curr, traversal);
                         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/498585b5/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 f07c267..e62c3a6 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
@@ -124,10 +124,12 @@ public class RangeByIsCountStrategyTest {
         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())},
-                    {__.out().count().is(lt(1)), __.not(__.out())},
-                    {__.out().count().is(lte(0)), __.not(__.out())},
-                    {__.out().count().is(0).as("a"), __.out().limit(1).count().is(0).as("a")},
+                    {__.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))},
@@ -137,7 +139,13 @@ public class RangeByIsCountStrategyTest {
                     {__.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))}});
+                    {__.out().count().is(without(2, 6, 4)), __.out().limit(6).count().is(without(2, 6, 4))},
+                    {__.map(__.count().is(0)), __.map(__.count().limit(1).is(0))},
+                    {__.flatMap(__.count().is(0)), __.flatMap(__.count().limit(1).is(0))},
+                    {__.sideEffect(__.count().is(0)), __.sideEffect(__.not(__.identity()))},
+                    {__.branch(__.count().is(0)), __.branch(__.count().limit(1).is(0))},
+                    {__.count().is(0).store("x"), __.limit(1).count().is(0).store("x")},
+            });
         }
     }
 }


[20/49] incubator-tinkerpop git commit: Merge remote-tracking branch 'origin/tp31'

Posted by dk...@apache.org.
Merge remote-tracking branch 'origin/tp31'

Conflicts:
	gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy


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

Branch: refs/heads/TINKERPOP-1298
Commit: 67fd4ee96c9ff399a3ee0abdde64b9a31a6c19c5
Parents: 6113c92 63e849c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 26 15:44:08 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 26 15:44:08 2016 -0400

----------------------------------------------------------------------
 .../process/traversal/step/sideEffect/GroovySackTest.groovy        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/67fd4ee9/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
----------------------------------------------------------------------
diff --cc gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
index 4c63351,828f664..d48416a
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
@@@ -62,7 -62,7 +62,7 @@@ public abstract class GroovySackTest 
          @Override
          public Traversal<Vertex, Double> get_g_withSackX1_sumX_VX1X_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack(
                  final Object v1Id) {
-             new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(1.0d,sum).V(${v1Id}).local(out('knows').barrier(normSack)).in('knows').barrier.sack", "v1Id", v1Id)
 -            TraversalScriptHelper.compute("g.withSack(1.0d,sum).V(v1Id).local(out('knows').barrier(normSack)).in('knows').barrier.sack", g, "v1Id", v1Id)
++            new ScriptTraversal<>(g, "gremlin-groovy", "g.withSack(1.0d,sum).V(v1Id).local(out('knows').barrier(normSack)).in('knows').barrier.sack", "v1Id", v1Id)
          }
  
          @Override


[33/49] incubator-tinkerpop git commit: Convert DOS to Unix. CTR.

Posted by dk...@apache.org.
Convert DOS to Unix. CTR.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 7a1fd4b6a5dcc8a859fe2c322dfa2dd9fcfefbf2
Parents: 5d38bbe
Author: Jason Plurad <pl...@apache.org>
Authored: Fri May 27 10:41:34 2016 -0400
Committer: Jason Plurad <pl...@apache.org>
Committed: Fri May 27 10:41:34 2016 -0400

----------------------------------------------------------------------
 gremlin-groovy/pom.xml | 276 ++++++++++++++++++++++----------------------
 gremlin-test/pom.xml   | 184 ++++++++++++++---------------
 2 files changed, 230 insertions(+), 230 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7a1fd4b6/gremlin-groovy/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-groovy/pom.xml b/gremlin-groovy/pom.xml
index 23b3791..aebc9a8 100644
--- a/gremlin-groovy/pom.xml
+++ b/gremlin-groovy/pom.xml
@@ -1,138 +1,138 @@
-<!--
-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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.tinkerpop</groupId>
-        <artifactId>tinkerpop</artifactId>
-        <version>3.1.3-SNAPSHOT</version>
-    </parent>
-    <artifactId>gremlin-groovy</artifactId>
-    <name>Apache TinkerPop :: Gremlin Groovy</name>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.ivy</groupId>
-            <artifactId>ivy</artifactId>
-            <version>2.3.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-groovysh</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-json</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.codehaus.groovy</groupId>
-            <artifactId>groovy-jsr223</artifactId>
-            <version>${groovy.version}</version>
-            <classifier>indy</classifier>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.3.1</version>
-        </dependency>
-        <dependency>
-            <groupId>com.github.jeremyh</groupId>
-            <artifactId>jBCrypt</artifactId>
-            <version>jbcrypt-0.4</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-test</artifactId>
-            <version>${project.version}</version>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
-    <repositories>
-        <repository>
-            <id>hyracks-releases</id>
-            <url>http://obelix.ics.uci.edu/nexus/content/groups/hyracks-public-releases/</url>
-        </repository>
-        <repository>
-            <id>jitpack.io</id>
-            <url>https://jitpack.io</url>
-        </repository>
-    </repositories>
-    <build>
-        <directory>${basedir}/target</directory>
-        <finalName>${project.artifactId}-${project.version}</finalName>
-        <resources>
-            <resource>
-                <directory>${basedir}/src/main/resources
-                </directory>
-            </resource>
-        </resources>
-        <testResources>
-            <testResource>
-                <directory>${basedir}/src/test/resources
-                </directory>
-            </testResource>
-        </testResources>
-        <plugins>
-            <plugin>
-                <groupId>org.codehaus.gmavenplus</groupId>
-                <artifactId>gmavenplus-plugin</artifactId>
-                <version>1.2</version>
-                <executions>
-                    <execution>
-                        <goals>
-                            <goal>addSources</goal>
-                            <goal>addTestSources</goal>
-                            <goal>generateStubs</goal>
-                            <goal>compile</goal>
-                            <goal>testGenerateStubs</goal>
-                            <goal>testCompile</goal>
-                            <goal>removeStubs</goal>
-                            <goal>removeTestStubs</goal>
-                        </goals>
-                    </execution>
-                </executions>
-                <configuration>
-                    <invokeDynamic>true</invokeDynamic>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-failsafe-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-</project>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tinkerpop</groupId>
+        <artifactId>tinkerpop</artifactId>
+        <version>3.1.3-SNAPSHOT</version>
+    </parent>
+    <artifactId>gremlin-groovy</artifactId>
+    <name>Apache TinkerPop :: Gremlin Groovy</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ivy</groupId>
+            <artifactId>ivy</artifactId>
+            <version>2.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-groovysh</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-json</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-jsr223</artifactId>
+            <version>${groovy.version}</version>
+            <classifier>indy</classifier>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.jeremyh</groupId>
+            <artifactId>jBCrypt</artifactId>
+            <version>jbcrypt-0.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-test</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    <repositories>
+        <repository>
+            <id>hyracks-releases</id>
+            <url>http://obelix.ics.uci.edu/nexus/content/groups/hyracks-public-releases/</url>
+        </repository>
+        <repository>
+            <id>jitpack.io</id>
+            <url>https://jitpack.io</url>
+        </repository>
+    </repositories>
+    <build>
+        <directory>${basedir}/target</directory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <resources>
+            <resource>
+                <directory>${basedir}/src/main/resources
+                </directory>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>${basedir}/src/test/resources
+                </directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.gmavenplus</groupId>
+                <artifactId>gmavenplus-plugin</artifactId>
+                <version>1.2</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>addSources</goal>
+                            <goal>addTestSources</goal>
+                            <goal>generateStubs</goal>
+                            <goal>compile</goal>
+                            <goal>testGenerateStubs</goal>
+                            <goal>testCompile</goal>
+                            <goal>removeStubs</goal>
+                            <goal>removeTestStubs</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <invokeDynamic>true</invokeDynamic>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/7a1fd4b6/gremlin-test/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-test/pom.xml b/gremlin-test/pom.xml
index ae1b61f..f3de2ed 100644
--- a/gremlin-test/pom.xml
+++ b/gremlin-test/pom.xml
@@ -1,92 +1,92 @@
-<!--
-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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.tinkerpop</groupId>
-        <artifactId>tinkerpop</artifactId>
-        <version>3.1.3-SNAPSHOT</version>
-    </parent>
-    <artifactId>gremlin-test</artifactId>
-    <name>Apache TinkerPop :: Gremlin Test</name>
-    <dependencies>
-        <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-core</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>com.carrotsearch</groupId>
-            <artifactId>junit-benchmarks</artifactId>
-            <version>0.7.2</version>
-        </dependency>
-        <dependency>
-            <groupId>com.h2database</groupId>
-            <artifactId>h2</artifactId>
-            <version>1.3.171</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.4</version>
-        </dependency>
-        <!-- TESTING -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>${junit.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-all</artifactId>
-            <version>1.9.5</version>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-all</artifactId>
-            <version>1.3</version>
-        </dependency>
-    </dependencies>
-    <build>
-        <directory>${basedir}/target</directory>
-        <finalName>${project.artifactId}-${project.version}</finalName>
-        <resources>
-            <resource>
-                <directory>${basedir}/src/main/resources
-                </directory>
-            </resource>
-        </resources>
-        <testResources>
-            <testResource>
-                <directory>${basedir}/src/test/resources
-                </directory>
-            </testResource>
-        </testResources>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-failsafe-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
-</project>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tinkerpop</groupId>
+        <artifactId>tinkerpop</artifactId>
+        <version>3.1.3-SNAPSHOT</version>
+    </parent>
+    <artifactId>gremlin-test</artifactId>
+    <name>Apache TinkerPop :: Gremlin Test</name>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.carrotsearch</groupId>
+            <artifactId>junit-benchmarks</artifactId>
+            <version>0.7.2</version>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <version>1.3.171</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <!-- TESTING -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
+            <version>1.3</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <directory>${basedir}/target</directory>
+        <finalName>${project.artifactId}-${project.version}</finalName>
+        <resources>
+            <resource>
+                <directory>${basedir}/src/main/resources
+                </directory>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>${basedir}/src/test/resources
+                </directory>
+            </testResource>
+        </testResources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>


[03/49] incubator-tinkerpop git commit: came up with a nifty trick and now OLD and NEW group() are much closer in time. 432ms vs 456ms. Given that the solution is no longer an NPE in nested groups in OLAP -- this minor time hit is worth it. :). Running i

Posted by dk...@apache.org.
came up with a nifty trick and now OLD and NEW group() are much closer in time. 432ms vs 456ms. Given that the solution is no longer an NPE in nested groups in OLAP -- this minor time hit is worth it. :). Running integration tests over night.


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

Branch: refs/heads/TINKERPOP-1298
Commit: e087123ca9bf513a555b3666a201905df43d8f7c
Parents: c890ceb
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon May 23 17:26:35 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon May 23 17:26:35 2016 -0600

----------------------------------------------------------------------
 .../process/traversal/step/map/GroupStep.java   | 168 ++++++++++++-------
 .../step/sideEffect/GroupSideEffectStep.java    |  20 ++-
 .../step/sideEffect/GroovyGroupTest.groovy      |   2 +-
 3 files changed, 116 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e087123c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
index b430d8f..7a93796 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
@@ -42,7 +42,6 @@ import org.javatuples.Pair;
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -62,7 +61,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
     public GroupStep(final Traversal.Admin traversal) {
         super(traversal);
         this.valueTraversal = this.integrateChild(__.fold().asAdmin());
-        this.preTraversal = this.integrateChild(splitOnBarrierStep(this.valueTraversal).get(0));
+        this.preTraversal = this.integrateChild(generatePreTraversal(this.valueTraversal));
         this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal));
         this.setSeedSupplier(HashMapSupplier.instance());
     }
@@ -74,7 +73,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
             this.state = 'v';
         } else if ('v' == this.state) {
             this.valueTraversal = this.integrateChild(convertValueTraversal(kvTraversal));
-            this.preTraversal = this.integrateChild(splitOnBarrierStep(this.valueTraversal).get(0));
+            this.preTraversal = this.integrateChild(generatePreTraversal(this.valueTraversal));
             this.setReducingBiOperator(new GroupBiOperator<>(this.valueTraversal));
             this.state = 'x';
         } else {
@@ -85,11 +84,15 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
     @Override
     public Map<K, V> projectTraverser(final Traverser.Admin<S> traverser) {
         final Map<K, V> map = new HashMap<>(1);
-        final TraverserSet traverserSet = new TraverserSet<>();
-        this.preTraversal.reset();
-        this.preTraversal.addStart(traverser.split());
-        this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
-        map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverserSet);
+        if (null == this.preTraversal) {
+            map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverser.split());
+        } else {
+            final TraverserSet traverserSet = new TraverserSet<>();
+            this.preTraversal.reset();
+            this.preTraversal.addStart(traverser.split());
+            this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
+            map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverserSet);
+        }
         return map;
     }
 
@@ -100,7 +103,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
 
     @Override
     public List<Traversal.Admin<?, ?>> getLocalChildren() {
-        final List<Traversal.Admin<?, ?>> children = new ArrayList<>(4);
+        final List<Traversal.Admin<?, ?>> children = new ArrayList<>(2);
         if (null != this.keyTraversal)
             children.add((Traversal.Admin) this.keyTraversal);
         children.add(this.valueTraversal);
@@ -118,7 +121,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
         if (null != this.keyTraversal)
             clone.keyTraversal = this.keyTraversal.clone();
         clone.valueTraversal = this.valueTraversal.clone();
-        clone.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(clone.valueTraversal).get(0));
+        clone.preTraversal = this.integrateChild(GroupStep.generatePreTraversal(clone.valueTraversal));
         return clone;
     }
 
@@ -147,12 +150,14 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
 
     public static final class GroupBiOperator<K, V> implements BinaryOperator<Map<K, V>>, Serializable {
 
+        private static final int SIZE_LIMIT = 1000;
+
         private Traversal.Admin<?, V> valueTraversal;
-        private ReducingBarrierStep reducingBarrierStep = null;
+        private Barrier barrierStep;
 
         public GroupBiOperator(final Traversal.Admin<?, V> valueTraversal) {
             this.valueTraversal = valueTraversal.clone();
-            this.reducingBarrierStep = TraversalHelper.getFirstStepOfAssignableClass(ReducingBarrierStep.class, this.valueTraversal).orElse(null);
+            this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
         }
 
         public GroupBiOperator() {
@@ -168,23 +173,60 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                 if (null == objectA) {
                     objectA = objectB;
                 } else {
-                    if (objectA instanceof TraverserSet) {
-                        if (objectB instanceof TraverserSet) {
+                    if (objectA instanceof Traverser.Admin) {
+                        if (objectB instanceof Traverser.Admin) {
+                            final TraverserSet set = new TraverserSet();
+                            set.add((Traverser.Admin) objectA);
+                            set.add((Traverser.Admin) objectB);
+                            objectA = set;
+                        } else if (objectB instanceof TraverserSet) {
+                            final TraverserSet set = (TraverserSet) objectB;
+                            set.add((Traverser.Admin) objectA);
+                            if (null != this.barrierStep && set.size() > SIZE_LIMIT) {
+                                this.valueTraversal.reset();
+                                ((Step) this.barrierStep).addStarts(set.iterator());
+                                objectA = this.barrierStep.nextBarrier();
+                            } else {
+                                objectA = objectB;
+                            }
+                        } else if (objectB instanceof Pair) {
+                            final TraverserSet set = (TraverserSet) ((Pair) objectB).getValue0();
+                            set.add((Traverser.Admin) objectA);
+                            if (set.size() > SIZE_LIMIT) {
+                                this.valueTraversal.reset();
+                                ((Step) this.barrierStep).addStarts(set.iterator());
+                                this.barrierStep.addBarrier(((Pair) objectB).getValue1());
+                                objectA = this.barrierStep.nextBarrier();
+                            } else {
+                                objectA = Pair.with(set, ((Pair) objectB).getValue1());
+                            }
+                        } else {
+                            objectA = Pair.with(new TraverserSet((Traverser.Admin) objectA), objectB);
+                        }
+                    } else if (objectA instanceof TraverserSet) {
+                        if (objectB instanceof Traverser.Admin) {
+                            ((TraverserSet) objectA).add((Traverser.Admin) objectB);
+                            if (null != this.barrierStep && ((TraverserSet) objectA).size() > SIZE_LIMIT) {
+                                this.valueTraversal.reset();
+                                ((Step) this.barrierStep).addStarts(((TraverserSet) objectA).iterator());
+                                objectA = this.barrierStep.nextBarrier();
+                            }
+                        } else if (objectB instanceof TraverserSet) {
                             final TraverserSet set = (TraverserSet) objectA;
                             set.addAll((TraverserSet) objectB);
-                            if (null != this.reducingBarrierStep && set.size() > 1000) {
+                            if (null != this.barrierStep && set.size() > SIZE_LIMIT) {
                                 this.valueTraversal.reset();
-                                this.reducingBarrierStep.addStarts(set.iterator());
-                                objectA = this.reducingBarrierStep.nextBarrier();
+                                ((Step) this.barrierStep).addStarts(set.iterator());
+                                objectA = this.barrierStep.nextBarrier();
                             }
                         } else if (objectB instanceof Pair) {
                             final TraverserSet set = (TraverserSet) objectA;
                             set.addAll((TraverserSet) ((Pair) objectB).getValue0());
-                            if (set.size() > 1000) {
+                            if (set.size() > SIZE_LIMIT) {
                                 this.valueTraversal.reset();
-                                this.reducingBarrierStep.addStarts(set.iterator());
-                                this.reducingBarrierStep.addBarrier(((Pair) objectB).getValue1());
-                                objectA = this.reducingBarrierStep.nextBarrier();
+                                ((Step) this.barrierStep).addStarts(set.iterator());
+                                this.barrierStep.addBarrier(((Pair) objectB).getValue1());
+                                objectA = this.barrierStep.nextBarrier();
                             } else {
                                 objectA = Pair.with(set, ((Pair) objectB).getValue1());
                             }
@@ -192,50 +234,53 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                             objectA = Pair.with(objectA, objectB);
                         }
                     } else if (objectA instanceof Pair) {
-                        if (objectB instanceof TraverserSet) {
+                        if (objectB instanceof Traverser.Admin) {
+                            ((TraverserSet) ((Pair) objectA).getValue0()).add((Traverser.Admin) objectB);
+                        } else if (objectB instanceof TraverserSet) {
                             final TraverserSet set = (TraverserSet) ((Pair) objectA).getValue0();
                             set.addAll((TraverserSet) objectB);
-                            if (null != this.reducingBarrierStep &&set.size() > 1000) {
+                            if (null != this.barrierStep && set.size() > SIZE_LIMIT) {
                                 this.valueTraversal.reset();
-                                this.reducingBarrierStep.addStarts(set.iterator());
-                                this.reducingBarrierStep.addBarrier(((Pair) objectA).getValue1());
-                                objectA = this.reducingBarrierStep.nextBarrier();
+                                ((Step) this.barrierStep).addStarts(set.iterator());
+                                this.barrierStep.addBarrier(((Pair) objectA).getValue1());
+                                objectA = this.barrierStep.nextBarrier();
                             }
                         } else if (objectB instanceof Pair) {
                             this.valueTraversal.reset();
-                            this.reducingBarrierStep.addBarrier(((Pair) objectA).getValue1());
-                            this.reducingBarrierStep.addBarrier(((Pair) objectB).getValue1());
-                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
-                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectB).getValue0()).iterator());
-                            objectA = this.reducingBarrierStep.nextBarrier();
+                            this.barrierStep.addBarrier(((Pair) objectA).getValue1());
+                            this.barrierStep.addBarrier(((Pair) objectB).getValue1());
+                            ((Step) this.barrierStep).addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
+                            ((Step) this.barrierStep).addStarts(((TraverserSet) ((Pair) objectB).getValue0()).iterator());
+                            objectA = this.barrierStep.nextBarrier();
                         } else {
                             this.valueTraversal.reset();
-                            this.reducingBarrierStep.addBarrier(((Pair) objectA).getValue1());
-                            this.reducingBarrierStep.addBarrier(objectB);
-                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
-                            objectA = this.reducingBarrierStep.nextBarrier();
+                            this.barrierStep.addBarrier(((Pair) objectA).getValue1());
+                            this.barrierStep.addBarrier(objectB);
+                            ((Step) this.barrierStep).addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
+                            objectA = this.barrierStep.nextBarrier();
                         }
                     } else {
-                        if (objectB instanceof TraverserSet) {
+                        if (objectB instanceof Traverser.Admin) {
+                            objectA = Pair.with(new TraverserSet<>((Traverser.Admin) objectB), objectA);
+                        } else if (objectB instanceof TraverserSet) {
                             objectA = Pair.with(objectB, objectA);
                         } else if (objectB instanceof Pair) {
                             this.valueTraversal.reset();
-                            this.reducingBarrierStep.addBarrier(objectA);
-                            this.reducingBarrierStep.addBarrier(((Pair) objectB).getValue1());
-                            this.reducingBarrierStep.addStarts(((TraverserSet) ((Pair) objectB).getValue0()).iterator());
-                            objectA = this.reducingBarrierStep.nextBarrier();
+                            this.barrierStep.addBarrier(objectA);
+                            this.barrierStep.addBarrier(((Pair) objectB).getValue1());
+                            ((Step) this.barrierStep).addStarts(((TraverserSet) ((Pair) objectB).getValue0()).iterator());
+                            objectA = this.barrierStep.nextBarrier();
                         } else {
                             this.valueTraversal.reset();
-                            this.reducingBarrierStep.addBarrier(objectA);
-                            this.reducingBarrierStep.addBarrier(objectB);
-                            objectA = this.reducingBarrierStep.nextBarrier();
+                            this.barrierStep.addBarrier(objectA);
+                            this.barrierStep.addBarrier(objectB);
+                            objectA = this.barrierStep.nextBarrier();
                         }
                     }
                 }
                 mapA.put(key, (V) objectA);
             }
             return mapA;
-
         }
     }
 
@@ -253,28 +298,21 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
         }
     }
 
-    public static List<Traversal.Admin<?, ?>> splitOnBarrierStep(final Traversal.Admin<?, ?> valueTraversal) {
-        if (TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal).isPresent()) {
-            final Traversal.Admin<?, ?> first = __.identity().asAdmin();
-            final Traversal.Admin<?, ?> second = __.identity().asAdmin();
-            boolean onSecond = false;
-            for (final Step step : valueTraversal.getSteps()) {
-                if (step instanceof Barrier)
-                    onSecond = true;
-                if (onSecond)
-                    second.addStep(step.clone());
-                else
-                    first.addStep(step.clone());
-            }
-            return Arrays.asList(first, second);
-        } else {
-            return Arrays.asList(valueTraversal.clone(), __.identity().asAdmin());
+    public static Traversal.Admin<?, ?> generatePreTraversal(final Traversal.Admin<?, ?> valueTraversal) {
+        if (!TraversalHelper.hasStepOfAssignableClass(Barrier.class, valueTraversal))
+            return valueTraversal;
+        final Traversal.Admin<?, ?> first = __.identity().asAdmin();
+        for (final Step step : valueTraversal.getSteps()) {
+            if (step instanceof Barrier)
+                break;
+            first.addStep(step.clone());
         }
+        return first.getSteps().size() == 1 ? null : first;
     }
 
     public static <K, V> Map<K, V> doFinalReduction(final Map<K, Object> map, final Traversal.Admin<?, V> valueTraversal) {
         final Map<K, V> reducedMap = new HashMap<>(map.size());
-        final ReducingBarrierStep reducingBarrierStep = TraversalHelper.getFirstStepOfAssignableClass(ReducingBarrierStep.class, valueTraversal).orElse(null);
+        final Barrier reducingBarrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, valueTraversal).orElse(null);
         IteratorUtils.removeOnNext(map.entrySet().iterator()).forEachRemaining(entry -> {
             valueTraversal.reset();
             if (null == reducingBarrierStep) {
@@ -282,10 +320,12 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                         ((TraverserSet<V>) entry.getValue()).iterator().next().get() :
                         (V) entry.getValue());
             } else {
-                if (entry.getValue() instanceof TraverserSet)
-                    reducingBarrierStep.addStarts(((TraverserSet) entry.getValue()).iterator());
+                if (entry.getValue() instanceof Traverser.Admin)
+                    ((Step) reducingBarrierStep).addStart((Traverser.Admin) entry.getValue());
+                else if (entry.getValue() instanceof TraverserSet)
+                    ((Step) reducingBarrierStep).addStarts(((TraverserSet) entry.getValue()).iterator());
                 else if (entry.getValue() instanceof Pair) {
-                    reducingBarrierStep.addStarts(((TraverserSet) (((Pair) entry.getValue()).getValue0())).iterator());
+                    ((Step) reducingBarrierStep).addStarts(((TraverserSet) (((Pair) entry.getValue()).getValue0())).iterator());
                     reducingBarrierStep.addBarrier((((Pair) entry.getValue()).getValue1()));
                 } else
                     reducingBarrierStep.addBarrier(entry.getValue());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e087123c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
index 4fc4ffa..b5deb02 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupSideEffectStep.java
@@ -53,7 +53,7 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
         super(traversal);
         this.sideEffectKey = sideEffectKey;
         this.valueTraversal = this.integrateChild(__.fold().asAdmin());
-        this.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(this.valueTraversal).get(0));
+        this.preTraversal = this.integrateChild(GroupStep.generatePreTraversal(this.valueTraversal));
         this.getTraversal().getSideEffects().registerIfAbsent(this.sideEffectKey, HashMapSupplier.instance(), new GroupStep.GroupBiOperator<>(this.valueTraversal));
     }
 
@@ -64,7 +64,7 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
             this.state = 'v';
         } else if ('v' == this.state) {
             this.valueTraversal = this.integrateChild(GroupStep.convertValueTraversal(kvTraversal));
-            this.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(this.valueTraversal).get(0));
+            this.preTraversal = this.integrateChild(GroupStep.generatePreTraversal(this.valueTraversal));
             this.getTraversal().getSideEffects().register(this.sideEffectKey, null, new GroupStep.GroupBiOperator<>(this.valueTraversal));
             this.state = 'x';
         } else {
@@ -75,13 +75,15 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
     @Override
     protected void sideEffect(final Traverser.Admin<S> traverser) {
         final Map<K, V> map = new HashMap<>(1);
-        final TraverserSet midTraversers = new TraverserSet<>();
-        this.preTraversal.reset();
-        this.preTraversal.addStart(traverser.split());
-        while (this.preTraversal.hasNext()) {
-            midTraversers.add(this.preTraversal.getEndStep().next());
+        if (null == this.preTraversal) {
+            map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverser.split());
+        } else {
+            final TraverserSet traverserSet = new TraverserSet<>();
+            this.preTraversal.reset();
+            this.preTraversal.addStart(traverser.split());
+            this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
+            map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverserSet);
         }
-        map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) midTraversers);
         this.getTraversal().getSideEffects().add(this.sideEffectKey, map);
     }
 
@@ -115,7 +117,7 @@ public final class GroupSideEffectStep<S, K, V> extends SideEffectStep<S> implem
         if (null != this.keyTraversal)
             clone.keyTraversal = this.keyTraversal.clone();
         clone.valueTraversal = this.valueTraversal.clone();
-        clone.preTraversal = this.integrateChild(GroupStep.splitOnBarrierStep(clone.valueTraversal).get(0));
+        clone.preTraversal = this.integrateChild(GroupStep.generatePreTraversal(clone.valueTraversal));
         return clone;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e087123c/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
index ddfb94a..156b350 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
@@ -111,7 +111,7 @@ public abstract class GroovyGroupTest {
 
         @Override
         public Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX() {
-            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group().by(bothE().count).by(group.by(label))")
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group().by(bothE().count).by(group().by(label))")
         }
     }
 }


[43/49] incubator-tinkerpop git commit: updated CHANGELOG.

Posted by dk...@apache.org.
updated CHANGELOG.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 2c089280a20c48464a76eaa083c5aadcf5951d6e
Parents: aa34888
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri May 27 09:55:10 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri May 27 09:55:10 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2c089280/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7705701..8f00e2f 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.2.1 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Added `HaltedTraverserStrategy` to allow users to get back different element detachments in OLAP.
 * Fixed a `NullPointerException` bug around nested `group()`-steps in OLAP.
 * Fixed a severe bug around halted traversers in a multi-job OLAP traversal chain.
 * Ensure a separation of `GraphComputer` and `VertexProgram` configurations in `SparkGraphComputer` and `GiraphGraphComputer`.


[19/49] incubator-tinkerpop git commit: TINKERPOP-1257 Fixed bad sack test string in groovy tests CTR

Posted by dk...@apache.org.
TINKERPOP-1257 Fixed bad sack test string in groovy tests CTR


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

Branch: refs/heads/TINKERPOP-1298
Commit: 63e849c0057a7c313eb2bd33938e1a260c206bf7
Parents: 55a509f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 26 15:14:21 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 26 15:14:21 2016 -0400

----------------------------------------------------------------------
 .../process/traversal/step/sideEffect/GroovySackTest.groovy        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/63e849c0/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
index a9fd808..828f664 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
@@ -62,7 +62,7 @@ public abstract class GroovySackTest {
         @Override
         public Traversal<Vertex, Double> get_g_withSackX1_sumX_VX1X_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack(
                 final Object v1Id) {
-            TraversalScriptHelper.compute("g.withSack(1.0d,sum).V(${v1Id}).local(out('knows').barrier(normSack)).in('knows').barrier.sack", g, "v1Id", v1Id)
+            TraversalScriptHelper.compute("g.withSack(1.0d,sum).V(v1Id).local(out('knows').barrier(normSack)).in('knows').barrier.sack", g, "v1Id", v1Id)
         }
 
         @Override


[11/49] incubator-tinkerpop git commit: Merge branch 'master' into TINKERPOP-1307

Posted by dk...@apache.org.
Merge branch 'master' into TINKERPOP-1307


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

Branch: refs/heads/TINKERPOP-1298
Commit: 4318b6c4c8a005117590cfc1e861d1a88ad4c068
Parents: 085be94 afd4048
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 08:43:24 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 08:43:24 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../traversal/step/sideEffect/SubgraphStep.java | 19 ++++++----
 .../step/sideEffect/GroovySubgraphTest.groovy   |  5 +++
 .../traversal/step/sideEffect/SubgraphTest.java | 40 ++++++++++++++++++--
 4 files changed, 53 insertions(+), 12 deletions(-)
----------------------------------------------------------------------



[07/49] incubator-tinkerpop git commit: This closes #233

Posted by dk...@apache.org.
This closes #233


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

Branch: refs/heads/TINKERPOP-1298
Commit: 366edb3bb395df0545ce0dda1fefd02d714a2865
Parents: 192d5ec
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 24 16:36:35 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 24 16:36:35 2016 -0400

----------------------------------------------------------------------

----------------------------------------------------------------------



[21/49] incubator-tinkerpop git commit: Updated CHANGELOG

Posted by dk...@apache.org.
Updated CHANGELOG


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

Branch: refs/heads/TINKERPOP-1298
Commit: a73ec2ff82697439a0f684045228a854ba2ef374
Parents: 572736d
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed May 25 21:24:58 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:34 2016 +0200

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a73ec2ff/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 3d1f51f..9cd6998 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Optimized a few special cases in `RangeByIsCountStrategy`.
 * Named the thread pool used by Gremlin Server sessions: "gremlin-server-session-$n".
 * Fixed a bug in `BulkSet.equals()` which made itself apparent when using `store()` and `aggregate()` with labeled `cap()`.
 * Ensured that all asserts of vertex and edge counts were being applied properly in the test suite.


[30/49] incubator-tinkerpop git commit: Fixed `DefaultTraversal`'s hash code calculation.

Posted by dk...@apache.org.
Fixed `DefaultTraversal`'s hash code calculation.


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

Branch: refs/heads/TINKERPOP-1298
Commit: ef53888c9e5bcd16445c129d0692ec7c73d5343a
Parents: 05ab599
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 15:55:02 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:38 2016 +0200

----------------------------------------------------------------------
 .../gremlin/process/traversal/util/DefaultTraversal.java          | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ef53888c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversal.java
----------------------------------------------------------------------
diff --git 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
index 43fc692..977e4ac 100644
--- 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
@@ -303,9 +303,10 @@ public class DefaultTraversal<S, E> implements Traversal.Admin<S, E> {
 
     @Override
     public int hashCode() {
+        int index = 0;
         int result = this.getClass().hashCode();
         for (final Step step : this.asAdmin().getSteps()) {
-            result ^= step.hashCode();
+            result ^= Integer.rotateLeft(step.hashCode(), index++);
         }
         return result;
     }


[09/49] incubator-tinkerpop git commit: TraversalVertexProgram can use DetachFactory or ReferenceFactory when sending halted traversers to the master traversal. The default is to use ReferenceFactory (more efficient), but if someone wants to use Deatched

Posted by dk...@apache.org.
TraversalVertexProgram can use DetachFactory or ReferenceFactory when sending halted traversers to the master traversal. The default is to use ReferenceFactory (more efficient), but if someone wants to use DeatchedFactory, then they do g.withComputer().withStrategies(HaltedTraverserFactoryStrategy.detached()). Easy peasy lemon squeezy. Still need to write specific test cases, but manual testing shows things workings.


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

Branch: refs/heads/TINKERPOP-1298
Commit: b72ea666ce18920a8dd7d1d4c30bbe029fe4ae80
Parents: afd4048
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue May 24 16:50:19 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue May 24 16:50:19 2016 -0600

----------------------------------------------------------------------
 .../computer/traversal/MasterExecutor.java      | 32 +++++++-----
 .../traversal/TraversalVertexProgram.java       | 30 +++++++----
 .../computer/traversal/WorkerExecutor.java      | 44 +++++++++-------
 .../step/map/TraversalVertexProgramStep.java    | 10 +++-
 .../HaltedTraverserFactoryStrategy.java         | 53 ++++++++++++++++++++
 5 files changed, 126 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b72ea666/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
index 88570fe..b5ec12b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
@@ -42,6 +42,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMatrix;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.HashSet;
@@ -57,6 +58,16 @@ final class MasterExecutor {
 
     }
 
+    protected static <R> Traverser.Admin<R> detach(final Traverser.Admin<R> traverser, final Class haltedTraverserFactory) {
+        if (haltedTraverserFactory.equals(DetachedFactory.class))
+            traverser.set(DetachedFactory.detach(traverser.get(), true));
+        else if (haltedTraverserFactory.equals(ReferenceFactory.class))
+            traverser.set(ReferenceFactory.detach(traverser.get()));
+        else
+            throw new IllegalArgumentException("The following detaching factory is unknown: " + haltedTraverserFactory);
+        return traverser;
+    }
+
     protected static void processMemory(final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final TraverserSet<Object> traverserSet, final Set<String> completedBarriers) {
         if (memory.exists(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
             for (final String key : memory.<Set<String>>get(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
@@ -82,7 +93,8 @@ final class MasterExecutor {
                                             final TraversalMatrix<?, ?> traversalMatrix,
                                             TraverserSet<Object> toProcessTraversers,
                                             final TraverserSet<Object> remoteActiveTraversers,
-                                            final TraverserSet<Object> haltedTraversers) {
+                                            final TraverserSet<Object> haltedTraversers,
+                                            final Class haltedTraverserFactory) {
 
 
         while (!toProcessTraversers.isEmpty()) {
@@ -96,23 +108,19 @@ final class MasterExecutor {
                 traverser.set(DetachedFactory.detach(traverser.get(), true));
                 traverser.setSideEffects(traversal.get().getSideEffects());
                 if (traverser.isHalted()) {
-                    traverser.detach();
-                    haltedTraversers.add(traverser);
+                    haltedTraversers.add(MasterExecutor.detach(traverser, haltedTraverserFactory));
                 } else if (isRemoteTraverser(traverser, traversalMatrix)) {  // this is so that patterns like order().name work as expected.
-                    traverser.detach();
-                    remoteActiveTraversers.add(traverser);
+                    remoteActiveTraversers.add(traverser.detach());
                 } else {
                     currentStep = traversalMatrix.getStepById(traverser.getStepId());
                     if (!currentStep.getId().equals(previousStep.getId()) && !(previousStep instanceof EmptyStep)) {
                         while (previousStep.hasNext()) {
                             final Traverser.Admin<Object> result = previousStep.next();
                             if (result.isHalted()) {
-                                result.detach();
-                                haltedTraversers.add(result);
+                                haltedTraversers.add(MasterExecutor.detach(result, haltedTraverserFactory));
                             } else {
                                 if (isRemoteTraverser(result, traversalMatrix)) {
-                                    result.detach();
-                                    remoteActiveTraversers.add(result);
+                                    remoteActiveTraversers.add(result.detach());
                                 } else
                                     localActiveTraversers.add(result);
                             }
@@ -126,12 +134,10 @@ final class MasterExecutor {
                 while (currentStep.hasNext()) {
                     final Traverser.Admin<Object> traverser = currentStep.next();
                     if (traverser.isHalted()) {
-                        traverser.detach();
-                        haltedTraversers.add(traverser);
+                        haltedTraversers.add(MasterExecutor.detach(traverser, haltedTraverserFactory));
                     } else {
                         if (isRemoteTraverser(traverser, traversalMatrix)) {
-                            traverser.detach();
-                            remoteActiveTraversers.add(traverser);
+                            remoteActiveTraversers.add(traverser.detach());
                         } else
                             localActiveTraversers.add(traverser);
                     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b72ea666/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
index 266426f..d4daaac 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
@@ -64,6 +64,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.function.MutableMetricsSupplier;
 import org.apache.tinkerpop.gremlin.util.iterator.EmptyIterator;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
@@ -93,6 +94,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     public static final String TRAVERSAL = "gremlin.traversalVertexProgram.traversal";
     public static final String HALTED_TRAVERSERS = "gremlin.traversalVertexProgram.haltedTraversers";
     public static final String ACTIVE_TRAVERSERS = "gremlin.traversalVertexProgram.activeTraversers";
+    public static final String HALTED_TRAVERSER_FACTORY = "gremlin.traversalVertexProgram.haltedTraverserFactory";
     protected static final String MUTATED_MEMORY_KEYS = "gremlin.traversalVertexProgram.mutatedMemoryKeys";
     private static final String VOTE_TO_HALT = "gremlin.traversalVertexProgram.voteToHalt";
     private static final String COMPLETED_BARRIERS = "gremlin.traversalVertexProgram.completedBarriers";
@@ -108,6 +110,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     private final Set<MapReduce> mapReducers = new HashSet<>();
     private TraverserSet<Object> haltedTraversers;
     private boolean returnHaltedTraversers = false;
+    private Class haltedTraverserDetachFactory;
 
     private TraversalVertexProgram() {
     }
@@ -164,6 +167,8 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                         this.traversal.get().getParent().asStep().getNextStep() instanceof EmptyStep ||  // same as above, but if using TraversalVertexProgramStep directly
                         (this.traversal.get().getParent().asStep().getNextStep() instanceof ProfileStep && // same as above, but needed for profiling
                                 this.traversal.get().getParent().asStep().getNextStep().getNextStep() instanceof ComputerResultStep));
+        // determine how to store halted traversers
+        this.haltedTraverserDetachFactory = configuration.containsKey(HALTED_TRAVERSER_FACTORY) ? (Class) configuration.getProperty(HALTED_TRAVERSER_FACTORY) : ReferenceFactory.class;
         // register traversal side-effects in memory
         this.memoryComputeKeys.addAll(MemoryTraversalSideEffects.getMemoryComputeKeys(this.traversal.get()));
         // register MapReducer memory compute keys
@@ -191,6 +196,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     public void storeState(final Configuration configuration) {
         VertexProgram.super.storeState(configuration);
         this.traversal.storeState(configuration, TRAVERSAL);
+        configuration.setProperty(HALTED_TRAVERSER_FACTORY, this.haltedTraverserDetachFactory);
         TraversalVertexProgram.storeHaltedTraversers(configuration, this.haltedTraversers);
     }
 
@@ -211,7 +217,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
             });
             assert haltedTraversers.isEmpty();
             final TraverserSet<Object> remoteActiveTraversers = new TraverserSet<>();
-            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, this.haltedTraversers);
+            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, this.haltedTraversers, this.haltedTraverserDetachFactory);
             memory.set(HALTED_TRAVERSERS, this.haltedTraversers);
             memory.set(ACTIVE_TRAVERSERS, remoteActiveTraversers);
         } else {
@@ -265,18 +271,17 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                     graphStep.setIteratorSupplier(() -> (Iterator) IteratorUtils.filter(vertex.edges(Direction.OUT), edge -> ElementHelper.idExists(edge.id(), graphStep.getIds())));
                 graphStep.forEachRemaining(traverser -> {
                     if (traverser.isHalted()) {
-                        traverser.detach();
                         if (this.returnHaltedTraversers)
-                            memory.add(HALTED_TRAVERSERS, new TraverserSet<>(traverser));
+                            memory.add(HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, this.haltedTraverserDetachFactory)));
                         else
-                            haltedTraversers.add((Traverser.Admin) traverser);
+                            haltedTraversers.add((Traverser.Admin) traverser.detach());
                     } else
                         activeTraversers.add((Traverser.Admin) traverser);
                 });
             }
-            memory.add(VOTE_TO_HALT, activeTraversers.isEmpty() || WorkerExecutor.execute(vertex, new SingleMessenger<>(messenger, activeTraversers), this.traversalMatrix, memory, this.returnHaltedTraversers));
+            memory.add(VOTE_TO_HALT, activeTraversers.isEmpty() || WorkerExecutor.execute(vertex, new SingleMessenger<>(messenger, activeTraversers), this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserDetachFactory));
         } else {  // ITERATION 1+
-            memory.add(VOTE_TO_HALT, WorkerExecutor.execute(vertex, messenger, this.traversalMatrix, memory, this.returnHaltedTraversers));
+            memory.add(VOTE_TO_HALT, WorkerExecutor.execute(vertex, messenger, this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserDetachFactory));
         }
         if (this.returnHaltedTraversers || haltedTraversers.isEmpty())
             vertex.<TraverserSet>property(HALTED_TRAVERSERS).remove();
@@ -298,7 +303,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
             final Set<String> completedBarriers = new HashSet<>();
             MasterExecutor.processMemory(this.traversalMatrix, memory, toProcessTraversers, completedBarriers);
             // process all results from barriers locally and when elements are touched, put them in remoteActiveTraversers
-            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, haltedTraversers);
+            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, haltedTraversers, this.haltedTraverserDetachFactory);
             // tell parallel barriers that might not have been active in the last round that they are no longer active
             memory.set(COMPLETED_BARRIERS, completedBarriers);
             if (!remoteActiveTraversers.isEmpty() ||
@@ -308,11 +313,9 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                 return false;
             } else {
                 // finalize locally with any last traversers dangling in the local traversal
-                final Step<?, ?> endStep = this.traversal.get().getEndStep();
+                final Step<?, Object> endStep = (Step<?, Object>) this.traversal.get().getEndStep();
                 while (endStep.hasNext()) {
-                    final Traverser.Admin traverser = endStep.next();
-                    traverser.detach();
-                    haltedTraversers.add(traverser);
+                    haltedTraversers.add(MasterExecutor.detach(endStep.next(), this.haltedTraverserDetachFactory));
                 }
                 // the result of a TraversalVertexProgram are the halted traversers
                 memory.set(HALTED_TRAVERSERS, haltedTraversers);
@@ -409,6 +412,11 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
             return this;
         }
 
+        public Builder haltedTraverserFactory(final Class detachFactory) {
+            this.configuration.setProperty(HALTED_TRAVERSER_FACTORY, detachFactory);
+            return this;
+        }
+
         public Builder traversal(final TraversalSource traversalSource, final String scriptEngine, final String traversalScript, final Object... bindings) {
             return this.traversal(new ScriptTraversal<>(traversalSource, scriptEngine, traversalScript, bindings));
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b72ea666/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
index c4bd659..5bc3da9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
@@ -35,6 +35,7 @@ import org.apache.tinkerpop.gremlin.structure.Element;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.Collections;
@@ -51,7 +52,12 @@ final class WorkerExecutor {
 
     }
 
-    protected static boolean execute(final Vertex vertex, final Messenger<TraverserSet<Object>> messenger, final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final boolean returnHaltedTraversers) {
+    protected static boolean execute(final Vertex vertex,
+                                     final Messenger<TraverserSet<Object>> messenger,
+                                     final TraversalMatrix<?, ?> traversalMatrix,
+                                     final Memory memory,
+                                     final boolean returnHaltedTraversers,
+                                     final Class haltedTraverserFactory) {
 
         final TraversalSideEffects traversalSideEffects = traversalMatrix.getTraversal().getSideEffects();
         final AtomicBoolean voteToHalt = new AtomicBoolean(true);
@@ -93,7 +99,7 @@ final class WorkerExecutor {
                 traversers.remove();
                 if (traverser.isHalted()) {
                     if (returnHaltedTraversers)
-                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(traverser));
+                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
                     else
                         haltedTraversers.add(traverser);
                 } else {
@@ -118,11 +124,11 @@ final class WorkerExecutor {
                 traversers.remove();
                 final Step<Object, Object> currentStep = traversalMatrix.getStepById(traverser.getStepId());
                 if (!currentStep.getId().equals(previousStep.getId()) && !(previousStep instanceof EmptyStep))
-                    WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers);
+                    WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserFactory);
                 currentStep.addStart(traverser);
                 previousStep = currentStep;
             }
-            WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers);
+            WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserFactory);
             assert toProcessTraversers.isEmpty();
             // process all the local objects and send messages or store locally again
             if (!activeTraversers.isEmpty()) {
@@ -135,8 +141,7 @@ final class WorkerExecutor {
                         final Vertex hostingVertex = WorkerExecutor.getHostingVertex(traverser.get());
                         if (!vertex.equals(hostingVertex)) { // necessary for path access
                             voteToHalt.set(false);
-                            traverser.detach();
-                            messenger.sendMessage(MessageScope.Global.of(hostingVertex), new TraverserSet<>(traverser));
+                            messenger.sendMessage(MessageScope.Global.of(hostingVertex), new TraverserSet<>(traverser.detach()));
                         } else {
                             if (traverser.get() instanceof Attachable)   // necessary for path access to local object
                                 traverser.attach(Attachable.Method.get(vertex));
@@ -151,7 +156,13 @@ final class WorkerExecutor {
         return voteToHalt.get();
     }
 
-    private static void drainStep(final Vertex vertex, final Step<Object, Object> step, final TraverserSet<Object> activeTraversers, final TraverserSet<Object> haltedTraversers, final Memory memory, final boolean returnHaltedTraversers) {
+    private static void drainStep(final Vertex vertex,
+                                  final Step<Object, Object> step,
+                                  final TraverserSet<Object> activeTraversers,
+                                  final TraverserSet<Object> haltedTraversers,
+                                  final Memory memory,
+                                  final boolean returnHaltedTraversers,
+                                  final Class haltedTraverserFactory) {
         if (step instanceof Barrier) {
             if (step instanceof Bypassing)
                 ((Bypassing) step).setBypass(true);
@@ -167,15 +178,12 @@ final class WorkerExecutor {
                                 (returnHaltedTraversers ||
                                         (!(traverser.get() instanceof Element) && !(traverser.get() instanceof Property)) ||
                                         getHostingVertex(traverser.get()).equals(vertex))) {
-                            traverser.detach();
                             if (returnHaltedTraversers)
-                                memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(traverser));
+                                memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
                             else
-                                haltedTraversers.add(traverser);
-                        } else {
-                            traverser.detach();
-                            traverserSet.add(traverser);
-                        }
+                                haltedTraversers.add(traverser.detach());
+                        } else
+                            traverserSet.add(traverser.detach());
                     });
                 }
                 memory.add(TraversalVertexProgram.MUTATED_MEMORY_KEYS, new HashSet<>(Collections.singleton(step.getId())));
@@ -189,14 +197,14 @@ final class WorkerExecutor {
         } else { // LOCAL PROCESSING
             step.forEachRemaining(traverser -> {
                 if (traverser.isHalted() &&
-                        (returnHaltedTraversers ||
+                        // if its a ReferenceFactory (one less iteration)
+                        ((returnHaltedTraversers || haltedTraverserFactory == ReferenceFactory.class) &&
                                 (!(traverser.get() instanceof Element) && !(traverser.get() instanceof Property)) ||
                                 getHostingVertex(traverser.get()).equals(vertex))) {
-                    traverser.detach();
                     if (returnHaltedTraversers)
-                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(traverser));
+                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
                     else
-                        haltedTraversers.add(traverser);
+                        haltedTraversers.add(traverser.detach());
                 } else {
                     activeTraversers.add(traverser);
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b72ea666/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
index 58e44a2..2b2498b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
@@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequire
 import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 
 import java.util.Collections;
 import java.util.List;
@@ -41,6 +42,7 @@ import java.util.Set;
 public final class TraversalVertexProgramStep extends VertexProgramStep implements TraversalParent {
 
     public PureTraversal<?, ?> computerTraversal;
+    private Class haltedTraverserFactory = ReferenceFactory.class;
 
     public TraversalVertexProgramStep(final Traversal.Admin traversal, final Traversal.Admin<?, ?> computerTraversal) {
         super(traversal);
@@ -69,7 +71,9 @@ public final class TraversalVertexProgramStep extends VertexProgramStep implemen
         this.getTraversal().getStrategies().toList().forEach(computerSpecificTraversal.getStrategies()::addStrategies);
         computerSpecificTraversal.setSideEffects(new MemoryTraversalSideEffects(this.getTraversal().getSideEffects()));
         computerSpecificTraversal.setParent(this);
-        final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build().traversal(computerSpecificTraversal);
+        final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build()
+                .traversal(computerSpecificTraversal)
+                .haltedTraverserFactory(this.haltedTraverserFactory);
         if (memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS))
             builder.haltedTraversers(memory.get(TraversalVertexProgram.HALTED_TRAVERSERS));
         return builder.create(graph);
@@ -96,6 +100,10 @@ public final class TraversalVertexProgramStep extends VertexProgramStep implemen
         this.integrateChild(this.computerTraversal.get());
     }
 
+    public void setHaltedTraverserFactory(final Class haltedTraverserDetachFactory) {
+        this.haltedTraverserFactory = haltedTraverserDetachFactory;
+    }
+
     /*@Override
     public int hashCode() {
         return super.hashCode() ^ this.computerTraversal.hashCode();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/b72ea666/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
new file mode 100644
index 0000000..44542c7
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
@@ -0,0 +1,53 @@
+/*
+ * 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.computer.traversal.strategy.decoration;
+
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HaltedTraverserFactoryStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy> implements TraversalStrategy.DecorationStrategy {
+
+    private final Class haltedTraverserFactory;
+
+    private HaltedTraverserFactoryStrategy(final Class haltedTraverserFactory) {
+        this.haltedTraverserFactory = haltedTraverserFactory;
+    }
+
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        TraversalHelper.getStepsOfAssignableClass(TraversalVertexProgramStep.class, traversal)
+                .forEach(step -> step.setHaltedTraverserFactory(this.haltedTraverserFactory));
+    }
+
+    public static HaltedTraverserFactoryStrategy detach() {
+        return new HaltedTraverserFactoryStrategy(DetachedFactory.class);
+    }
+
+    public static HaltedTraverserFactoryStrategy reference() {
+        return new HaltedTraverserFactoryStrategy(ReferenceFactory.class);
+    }
+}


[29/49] incubator-tinkerpop git commit: Fixed some typos.

Posted by dk...@apache.org.
Fixed some typos.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 05ab5992cbf40d1e1e1908089d3fb62f8578ea44
Parents: 70e8c2a
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 15:44:23 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:38 2016 +0200

----------------------------------------------------------------------
 .../strategy/optimization/RangeByIsCountStrategyTest.java | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/05ab5992/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 820d4cc..8b42e7f 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
@@ -107,7 +107,7 @@ public class RangeByIsCountStrategyTest {
 
         protected TraversalEngine traversalEngine;
 
-        void applyAdjacentToIncidentStrategy(final Traversal traversal) {
+        void applyRangeByIsCountStrategy(final Traversal traversal) {
             final TraversalStrategies strategies = new DefaultTraversalStrategies();
             strategies.addStrategies(RangeByIsCountStrategy.instance());
 
@@ -117,7 +117,7 @@ public class RangeByIsCountStrategyTest {
         }
 
         public void doTest(final Traversal traversal, final Traversal optimized) {
-            applyAdjacentToIncidentStrategy(traversal);
+            applyRangeByIsCountStrategy(traversal);
             assertEquals(optimized, traversal);
         }
 
@@ -140,10 +140,10 @@ public class RangeByIsCountStrategyTest {
                     {__.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(__.count().limit(1).is(0))},
-                    {__.flatMap(__.count().is(0)), __.flatMap(__.count().limit(1).is(0))},
+                    {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))},
+                    {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))},
                     {__.sideEffect(__.count().is(0)), __.sideEffect(__.not(__.identity()))},
-                    {__.branch(__.count().is(0)), __.branch(__.count().limit(1).is(0))},
+                    {__.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()))},


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

Posted by dk...@apache.org.
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/TINKERPOP-1298
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;


[22/49] incubator-tinkerpop git commit: Tweaked `RangeByIsCountStrategy`. The pattern `outE().count().is(0)` is now replaced by `not(outE())`

Posted by dk...@apache.org.
Tweaked `RangeByIsCountStrategy`. The pattern `outE().count().is(0)` is now replaced by `not(outE())`


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

Branch: refs/heads/TINKERPOP-1298
Commit: 572736dacfde461e4310a36734c5186e8bcff151
Parents: 63e849c
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed May 25 21:13:48 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:34 2016 +0200

----------------------------------------------------------------------
 .../optimization/RangeByIsCountStrategy.java    |  27 +++--
 .../RangeByIsCountStrategyTest.java             | 105 ++++++++++++++++++-
 .../structure/TinkerGraphPlayTest.java          |  43 ++++----
 3 files changed, 144 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/572736da/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 f2d60b1..f3168a3 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
@@ -18,18 +18,20 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
 
+import org.apache.tinkerpop.gremlin.process.traversal.Compare;
+import org.apache.tinkerpop.gremlin.process.traversal.Contains;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 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.dsl.graph.__;
 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.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.ConnectiveP;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
-import org.apache.tinkerpop.gremlin.process.traversal.Compare;
-import org.apache.tinkerpop.gremlin.process.traversal.Contains;
-import org.apache.tinkerpop.gremlin.process.traversal.P;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -47,7 +49,7 @@ import java.util.function.BiPredicate;
  *
  * @author Daniel Kuppitz (http://gremlin.guru)
  * @example <pre>
- * __.outE().count().is(0)      // is replaced by __.outE().limit(1).count().is(0)
+ * __.outE().count().is(0)      // is replaced by __.not(outE())
  * __.outE().count().is(lt(3))  // is replaced by __.outE().limit(3).count().is(lt(3))
  * __.outE().count().is(gt(3))  // is replaced by __.outE().limit(4).count().is(gt(3))
  * </pre>
@@ -78,6 +80,7 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                     final IsStep isStep = (IsStep) next;
                     final P isStepPredicate = isStep.getPredicate();
                     Long highRange = null;
+                    boolean useNotStep = false;
                     for (P p : isStepPredicate instanceof ConnectiveP ? ((ConnectiveP<?>) isStepPredicate).getPredicates() : Collections.singletonList(isStepPredicate)) {
                         final Object value = p.getValue();
                         final BiPredicate predicate = p.getBiPredicate();
@@ -85,7 +88,11 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             final long highRangeOffset = INCREASED_OFFSET_SCALAR_PREDICATES.contains(predicate) ? 1L : 0L;
                             final Long highRangeCandidate = ((Number) value).longValue() + highRangeOffset;
                             final boolean update = highRange == null || highRangeCandidate > highRange;
-                            if (update) highRange = highRangeCandidate;
+                            if (update) {
+                                highRange = highRangeCandidate;
+                                useNotStep = (highRange <= 1L && predicate.equals(Compare.lt)) ||
+                                        (highRange == 1L && (predicate.equals(Compare.eq) || predicate.equals(Compare.lte)));
+                            }
                         } else {
                             final Long highRangeOffset = RANGE_PREDICATES.get(predicate);
                             if (value instanceof Collection && highRangeOffset != null) {
@@ -99,7 +106,15 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                         }
                     }
                     if (highRange != null) {
-                        TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal, 0L, highRange), curr, traversal);
+                        if (useNotStep) {
+                            traversal.asAdmin().removeStep(next); // IsStep
+                            traversal.asAdmin().removeStep(curr); // CountStep
+                            final Traversal.Admin inner = __.start().asAdmin();
+                            TraversalHelper.insertAfterStep(prev, inner.getStartStep(), inner);
+                            TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal);
+                        } else {
+                            TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal, 0L, highRange), curr, traversal);
+                        }
                         i++;
                     }
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/572736da/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 1642b41..a72df8e 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
@@ -22,6 +22,7 @@ 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.NotStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep;
 import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalStrategies;
@@ -36,7 +37,16 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import static org.apache.tinkerpop.gremlin.process.traversal.P.*;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.eq;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.gt;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.gte;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.inside;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.lt;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.lte;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.neq;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.outside;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.within;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.without;
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -78,6 +88,32 @@ public class RangeByIsCountStrategyTest {
     }
 
     @RunWith(Parameterized.class)
+    public static class StandardNotTest extends AbstractRangeByIsCountStrategyTest {
+
+        @Parameterized.Parameters(name = "{0}")
+        public static Iterable<Object[]> data() {
+            return generateNotTestParameters();
+        }
+
+        @Parameterized.Parameter(value = 0)
+        public String name;
+
+        @Parameterized.Parameter(value = 1)
+        public Object predicate;
+
+        @Before
+        public void setup() {
+            this.traversalEngine = mock(TraversalEngine.class);
+            when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.STANDARD);
+        }
+
+        @Test
+        public void shouldApplyStrategy() {
+            doTest(predicate);
+        }
+    }
+
+    @RunWith(Parameterized.class)
     public static class ComputerTest extends AbstractRangeByIsCountStrategyTest {
 
         @Parameterized.Parameters(name = "{0}")
@@ -106,6 +142,32 @@ public class RangeByIsCountStrategyTest {
         }
     }
 
+    @RunWith(Parameterized.class)
+    public static class ComputerNotTest extends AbstractRangeByIsCountStrategyTest {
+
+        @Parameterized.Parameters(name = "{0}")
+        public static Iterable<Object[]> data() {
+            return generateNotTestParameters();
+        }
+
+        @Parameterized.Parameter(value = 0)
+        public String name;
+
+        @Parameterized.Parameter(value = 1)
+        public Object predicate;
+
+        @Before
+        public void setup() {
+            this.traversalEngine = mock(TraversalEngine.class);
+            when(this.traversalEngine.getType()).thenReturn(TraversalEngine.Type.COMPUTER);
+        }
+
+        @Test
+        public void shouldApplyStrategy() {
+            doTest(predicate);
+        }
+    }
+
     public static class SpecificComputerTest extends AbstractRangeByIsCountStrategyTest {
 
         @Before
@@ -115,16 +177,31 @@ public class RangeByIsCountStrategyTest {
         }
 
         @Test
-        public void nestedCountEqualsNullShouldLimitToOne() {
+        public void nestedCountEqualsOneShouldLimitToTwo() {
             final AtomicInteger counter = new AtomicInteger(0);
-            final Traversal traversal = __.out().where(__.outE("created").count().is(0));
+            final Traversal traversal = __.out().where(__.outE("created").count().is(1));
             applyRangeByIsCountStrategy(traversal);
 
             final TraversalFilterStep filterStep = TraversalHelper.getStepsOfClass(TraversalFilterStep.class, traversal.asAdmin()).stream().findFirst().get();
             final Traversal nestedTraversal = (Traversal) filterStep.getLocalChildren().get(0);
             TraversalHelper.getStepsOfClass(RangeGlobalStep.class, nestedTraversal.asAdmin()).stream().forEach(step -> {
                 assertEquals(0, step.getLowRange());
-                assertEquals(1, step.getHighRange());
+                assertEquals(2, step.getHighRange());
+                counter.incrementAndGet();
+            });
+            assertEquals(1, counter.get());
+        }
+
+        @Test
+        public void nestedCountEqualsNullShouldUseNotStep() {
+            final AtomicInteger counter = new AtomicInteger(0);
+            final Traversal traversal = __.out().where(__.outE("created").count().is(0));
+            applyRangeByIsCountStrategy(traversal);
+
+            final TraversalFilterStep filterStep = TraversalHelper.getStepsOfClass(TraversalFilterStep.class, traversal.asAdmin()).stream().findFirst().get();
+            final Traversal nestedTraversal = (Traversal) filterStep.getLocalChildren().get(0);
+            TraversalHelper.getStepsOfClass(NotStep.class, nestedTraversal.asAdmin()).stream().forEach(step -> {
+                assertEquals(__.outE("created"), step.getLocalChildren().get(0));
                 counter.incrementAndGet();
             });
             assertEquals(1, counter.get());
@@ -162,10 +239,20 @@ public class RangeByIsCountStrategyTest {
             assertEquals(1, counter.intValue());
         }
 
+        public void doTest(final Object predicate) {
+            final Traversal traversal = __.out().count().is(predicate);
+
+            applyRangeByIsCountStrategy(traversal);
+
+            final List<NotStep> steps = TraversalHelper.getStepsOfClass(NotStep.class, traversal.asAdmin());
+            assertEquals(1, steps.size());
+
+            steps.forEach(step -> assertEquals(__.out(), step.getLocalChildren().get(0)));
+        }
+
         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},
@@ -176,5 +263,13 @@ public class RangeByIsCountStrategyTest {
                     {"countWithinTwoSixFourShouldLimitToSeven", within(2l, 6l, 4l), 7l},
                     {"countWithoutTwoSixFourShouldLimitToSix", without(2l, 6l, 4l), 6l}});
         }
+
+        static Iterable<Object[]> generateNotTestParameters() {
+
+            return Arrays.asList(new Object[][]{
+                    {"countEqualsNullShouldUseNotStep", eq(0l)},
+                    {"countLessThanOneShouldUseNotStep", lt(1l)},
+                    {"countLessThanOrEqualNullShouldUseNotStep", lte(0l)}});
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/572736da/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git 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
index c9f3e6d..269f400 100644
--- 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,7 +18,6 @@
  */
 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;
@@ -32,20 +31,30 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
-import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
 import org.apache.tinkerpop.gremlin.util.TimeUtil;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
 import java.util.Arrays;
 import java.util.List;
-import java.util.function.Function;
 import java.util.function.Supplier;
 
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.lt;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.as;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.choose;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.count;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.fold;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.select;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.union;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.valueMap;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.values;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -71,7 +80,7 @@ public class TinkerGraphPlayTest {
         graph.io(GraphMLIo.build()).readGraph("data/grateful-dead.xml");
         /////////
 
-        g.V().group().by(T.label).by(values("name")).forEachRemaining(x->logger.info(x.toString()));
+        g.V().group().by(T.label).by(values("name")).forEachRemaining(x -> logger.info(x.toString()));
 
         logger.info("group: " + g.V().both("followedBy").both("followedBy").group().by("songType").by(count()).next());
         logger.info("groupV3d0: " + g.V().both("followedBy").both("followedBy").groupV3d0().by("songType").by().by(__.count(Scope.local)).next());
@@ -126,7 +135,7 @@ public class TinkerGraphPlayTest {
         v7.addEdge("link", v9, "weight", 1f);
         v8.addEdge("link", v9, "weight", 7f);
 
-        g.traversal().withSack(Float.MIN_VALUE).V(v1).repeat(outE().sack(Operator.max, "weight").inV()).times(5).sack().forEachRemaining(x->logger.info(x.toString()));
+        g.traversal().withSack(Float.MIN_VALUE).V(v1).repeat(outE().sack(Operator.max, "weight").inV()).times(5).sack().forEachRemaining(x -> logger.info(x.toString()));
     }
 
    /* @Test
@@ -200,18 +209,12 @@ public class TinkerGraphPlayTest {
     @Ignore
     public void testPlayDK() throws Exception {
 
-        new File("/tmp/tinkergraph2.kryo").deleteOnExit();
-        new File("/tmp/tinkergraph3.kryo").deleteOnExit();
-
-        final Graph graph1 = TinkerFactory.createModern();
-        final Graph graph2 = GraphFactory.open("/tmp/graph2.properties");
-        TinkerFactory.generateModern((TinkerGraph) graph2);
-        graph2.close();
-
-        logger.info("graph1 -> graph2");
-        graph1.compute().workers(1).program(BulkLoaderVertexProgram.build().userSuppliedIds(true).writeGraph("/tmp/graph2.properties").create(graph1)).submit().get();
-        logger.info("graph1 -> graph3");
-        graph1.compute().workers(1).program(BulkLoaderVertexProgram.build().userSuppliedIds(true).writeGraph("/tmp/graph3.properties").create(graph1)).submit().get();
+        Graph graph = TinkerGraph.open();
+        GraphTraversalSource g = graph.traversal();
+        graph.io(GraphMLIo.build()).readGraph("/projects/apache/incubator-tinkerpop/data/grateful-dead.xml");
+        System.out.println(g.V().filter(outE("sungBy").count().is(0)).explain());
+        System.out.println(g.V().filter(outE("sungBy").count().is(lt(1))).explain());
+        System.out.println(g.V().filter(outE("sungBy").count().is(1)).explain());
     }
 
     @Test
@@ -256,7 +259,7 @@ public class TinkerGraphPlayTest {
 
         logger.info(traversal.get().toString());
         logger.info(traversal.get().iterate().toString());
-        traversal.get().forEachRemaining(x->logger.info(x.toString()));
+        traversal.get().forEachRemaining(x -> logger.info(x.toString()));
 
     }
 


[18/49] incubator-tinkerpop git commit: moved HaltedTraverserStrategy to the general strategy package as it can now be used with OLTP.

Posted by dk...@apache.org.
moved HaltedTraverserStrategy to the general strategy package as it can now be used with OLTP.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 8be75a92aab1f647db966458fd77fa33eedb7c60
Parents: 56c43ea
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 26 12:52:04 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 26 12:52:04 2016 -0600

----------------------------------------------------------------------
 .../computer/traversal/MasterExecutor.java      |   5 +-
 .../traversal/TraversalVertexProgram.java       |   2 +-
 .../computer/traversal/WorkerExecutor.java      |   2 +-
 .../decoration/HaltedTraverserStrategy.java     |  69 -------------
 .../decoration/HaltedTraverserStrategy.java     |  69 +++++++++++++
 .../decoration/HaltedTraverserStrategyTest.java | 102 -------------------
 .../decoration/HaltedTraverserStrategyTest.java | 102 +++++++++++++++++++
 7 files changed, 175 insertions(+), 176 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
index 0462950..b83b6d6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
@@ -20,7 +20,7 @@
 package org.apache.tinkerpop.gremlin.process.computer.traversal;
 
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
@@ -43,7 +43,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.PureTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMatrix;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 
 import java.util.HashSet;
 import java.util.Iterator;
@@ -107,7 +106,7 @@ final class MasterExecutor {
                         while (previousStep.hasNext()) {
                             final Traverser.Admin<Object> result = previousStep.next();
                             if (result.isHalted())
-                                haltedTraversers.add(haltedTraverserStrategy.halt(traverser));
+                                haltedTraversers.add(haltedTraverserStrategy.halt(result));
                             else if (isRemoteTraverser(result, traversalMatrix))
                                 remoteActiveTraversers.add(result.detach());
                             else

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
index c9dc053..1a54721 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
@@ -32,7 +32,7 @@ import org.apache.tinkerpop.gremlin.process.computer.VertexComputeKey;
 import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.ComputerResultStep;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
 import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
 import org.apache.tinkerpop.gremlin.process.computer.util.AbstractVertexProgramBuilder;
 import org.apache.tinkerpop.gremlin.process.computer.util.SingleMessenger;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
index 7181992..0a3aad2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
@@ -21,7 +21,7 @@ package org.apache.tinkerpop.gremlin.process.computer.traversal;
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.MessageScope;
 import org.apache.tinkerpop.gremlin.process.computer.Messenger;
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
deleted file mode 100644
index 968e167..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
+++ /dev/null
@@ -1,69 +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.computer.traversal.strategy.decoration;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class HaltedTraverserStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy> implements TraversalStrategy.DecorationStrategy {
-
-    private final Class haltedTraverserFactory;
-
-    private HaltedTraverserStrategy(final Class haltedTraverserFactory) {
-        if (haltedTraverserFactory.equals(DetachedFactory.class) || haltedTraverserFactory.equals(ReferenceFactory.class))
-            this.haltedTraverserFactory = haltedTraverserFactory;
-        else
-            throw new IllegalArgumentException("The provided traverser detachment factory is unknown: " + haltedTraverserFactory);
-    }
-
-    public void apply(final Traversal.Admin<?, ?> traversal) {
-        // do nothing as this is simply a metadata strategy
-    }
-
-    public Class getHaltedTraverserFactory() {
-        return this.haltedTraverserFactory;
-    }
-
-    public <R> Traverser.Admin<R> halt(final Traverser.Admin<R> traverser) {
-        if (ReferenceFactory.class.equals(this.haltedTraverserFactory))
-            traverser.set(ReferenceFactory.detach(traverser.get()));
-        else
-            traverser.set(DetachedFactory.detach(traverser.get(), true));
-        return traverser;
-    }
-
-    ////////////
-
-    public static HaltedTraverserStrategy detached() {
-        return new HaltedTraverserStrategy(DetachedFactory.class);
-    }
-
-    public static HaltedTraverserStrategy reference() {
-        return new HaltedTraverserStrategy(ReferenceFactory.class);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/HaltedTraverserStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/HaltedTraverserStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/HaltedTraverserStrategy.java
new file mode 100644
index 0000000..45966f0
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/HaltedTraverserStrategy.java
@@ -0,0 +1,69 @@
+/*
+ * 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.decoration;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class HaltedTraverserStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy> implements TraversalStrategy.DecorationStrategy {
+
+    private final Class haltedTraverserFactory;
+
+    private HaltedTraverserStrategy(final Class haltedTraverserFactory) {
+        if (haltedTraverserFactory.equals(DetachedFactory.class) || haltedTraverserFactory.equals(ReferenceFactory.class))
+            this.haltedTraverserFactory = haltedTraverserFactory;
+        else
+            throw new IllegalArgumentException("The provided traverser detachment factory is unknown: " + haltedTraverserFactory);
+    }
+
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        // do nothing as this is simply a metadata strategy
+    }
+
+    public Class getHaltedTraverserFactory() {
+        return this.haltedTraverserFactory;
+    }
+
+    public <R> Traverser.Admin<R> halt(final Traverser.Admin<R> traverser) {
+        if (ReferenceFactory.class.equals(this.haltedTraverserFactory))
+            traverser.set(ReferenceFactory.detach(traverser.get()));
+        else
+            traverser.set(DetachedFactory.detach(traverser.get(), true));
+        return traverser;
+    }
+
+    ////////////
+
+    public static HaltedTraverserStrategy detached() {
+        return new HaltedTraverserStrategy(DetachedFactory.class);
+    }
+
+    public static HaltedTraverserStrategy reference() {
+        return new HaltedTraverserStrategy(ReferenceFactory.class);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
deleted file mode 100644
index 9c92efe..0000000
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
+++ /dev/null
@@ -1,102 +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.tinkergraph.process.computer.traversal.strategy.decoration;
-
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class HaltedTraverserStrategyTest {
-
-    @Before
-    public void setup() {
-        // necessary as ComputerResult step for testing purposes attaches Attachables
-        System.setProperty("is.testing", "false");
-    }
-
-    @After
-    public void shutdown() {
-        System.setProperty("is.testing", "true");
-    }
-
-    @Test
-    public void shouldReturnDetachedElements() {
-        final Graph graph = TinkerFactory.createModern();
-        final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.detached());
-        g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
-        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
-        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
-        g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
-        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
-        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
-        g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
-        g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
-        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
-        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
-    }
-
-    @Test
-    public void shouldReturnReferenceElements() {
-        final Graph graph = TinkerFactory.createModern();
-        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.reference());
-        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
-        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
-        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
-        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
-        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
-        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
-        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        // the default should be reference elements
-        g = graph.traversal().withComputer();
-        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
-        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
-        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
-        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
-        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
-        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
-        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8be75a92/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/decoration/HaltedTraverserStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
new file mode 100644
index 0000000..0943391
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/strategy/decoration/HaltedTraverserStrategyTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.tinkergraph.process.traversal.strategy.decoration;
+
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.HaltedTraverserStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class HaltedTraverserStrategyTest {
+
+    @Before
+    public void setup() {
+        // necessary as ComputerResult step for testing purposes attaches Attachables
+        System.setProperty("is.testing", "false");
+    }
+
+    @After
+    public void shutdown() {
+        System.setProperty("is.testing", "true");
+    }
+
+    @Test
+    public void shouldReturnDetachedElements() {
+        final Graph graph = TinkerFactory.createModern();
+        final GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.detached());
+        g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
+        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+    }
+
+    @Test
+    public void shouldReturnReferenceElements() {
+        final Graph graph = TinkerFactory.createModern();
+        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserStrategy.reference());
+        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
+        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        // the default should be reference elements
+        g = graph.traversal().withComputer();
+        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
+        g.V().out().pageRank().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().pageRank().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+    }
+
+}


[46/49] incubator-tinkerpop git commit: added BulkExportVertexProgram

Posted by dk...@apache.org.
added BulkExportVertexProgram


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

Branch: refs/heads/TINKERPOP-1298
Commit: df6cfd603468e05a80070b2ba547059c5f4fec12
Parents: 670bc69
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Sun May 22 09:37:41 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue May 31 14:47:25 2016 +0200

----------------------------------------------------------------------
 .../bulkdumping/BulkExportVertexProgram.java    | 163 +++++++++++++++++++
 .../gremlin/structure/io/gryo/GryoMapper.java   |   4 +-
 2 files changed, 166 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/df6cfd60/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
new file mode 100644
index 0000000..cdd6b28
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgram.java
@@ -0,0 +1,163 @@
+/*
+ * 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.computer.bulkdumping;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationUtils;
+import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.MessageScope;
+import org.apache.tinkerpop.gremlin.process.computer.Messenger;
+import org.apache.tinkerpop.gremlin.process.computer.VertexComputeKey;
+import org.apache.tinkerpop.gremlin.process.computer.VertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.TraversalVertexProgram;
+import org.apache.tinkerpop.gremlin.process.computer.util.AbstractVertexProgramBuilder;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.TraverserSet;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.javatuples.Tuple;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author Daniel Kuppitz (http://gremlin.guru)
+ */
+public class BulkExportVertexProgram implements VertexProgram<Tuple> {
+
+    public static final String BULK_EXPORT_VERTEX_PROGRAM_CFG_PREFIX = "gremlin.bulkExportVertexProgram";
+    public static final String BULK_EXPORT_PROPERTIES = String.join(".", BULK_EXPORT_VERTEX_PROGRAM_CFG_PREFIX, "properties");
+
+    private Configuration configuration;
+    private String properties;
+    private Set<VertexComputeKey> vertexComputeKeys;
+
+    private BulkExportVertexProgram() {
+    }
+
+    @Override
+    public void loadState(final Graph graph, final Configuration config) {
+        configuration = new BaseConfiguration();
+        if (config != null) {
+            ConfigurationUtils.copy(config, configuration);
+        }
+        properties = configuration.getString(BULK_EXPORT_PROPERTIES);
+        vertexComputeKeys = Collections.singleton(VertexComputeKey.of(BULK_EXPORT_PROPERTIES, false));
+    }
+
+    @Override
+    public void storeState(final Configuration config) {
+        VertexProgram.super.storeState(config);
+        if (configuration != null) {
+            ConfigurationUtils.copy(configuration, config);
+        }
+    }
+
+    @Override
+    public void setup(final Memory memory) {
+    }
+
+    @Override
+    public void execute(final Vertex sourceVertex, final Messenger<Tuple> messenger, final Memory memory) {
+        final VertexProperty<TraverserSet> haltedTraversers = sourceVertex.property(TraversalVertexProgram.HALTED_TRAVERSERS);
+        if (haltedTraversers.isPresent()) {
+            sourceVertex.property(BULK_EXPORT_PROPERTIES, properties);
+        }
+    }
+
+    @Override
+    public boolean terminate(final Memory memory) {
+        return properties == null || properties.isEmpty() || !memory.isInitialIteration();
+    }
+
+    @Override
+    public Set<MessageScope> getMessageScopes(final Memory memory) {
+        return Collections.emptySet();
+    }
+
+    @SuppressWarnings({"CloneDoesntDeclareCloneNotSupportedException", "CloneDoesntCallSuperClone"})
+    @Override
+    public VertexProgram<Tuple> clone() {
+        return this;
+    }
+
+    @Override
+    public GraphComputer.ResultGraph getPreferredResultGraph() {
+        return GraphComputer.ResultGraph.NEW;
+    }
+
+    @Override
+    public GraphComputer.Persist getPreferredPersist() {
+        return GraphComputer.Persist.EDGES;
+    }
+
+    @Override
+    public Set<VertexComputeKey> getVertexComputeKeys() {
+        return this.vertexComputeKeys;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.vertexProgramString(this);
+    }
+
+    public static Builder build() {
+        return new Builder();
+    }
+
+    public static class Builder extends AbstractVertexProgramBuilder<Builder> {
+
+        private List<String> properties;
+
+        private Builder() {
+            super(BulkExportVertexProgram.class);
+            properties = new ArrayList<>();
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public BulkExportVertexProgram create(final Graph graph) {
+            configuration.setProperty(BULK_EXPORT_PROPERTIES, String.join("\1", properties));
+            graph.configuration().setProperty("gremlin.hadoop.graphWriter", "org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptOutputFormat");
+            return (BulkExportVertexProgram) VertexProgram.createVertexProgram(graph, configuration);
+        }
+
+        public Builder key(final String key, final String format) {
+            properties.add(key + "\2" + format);
+            return this;
+        }
+
+        public Builder key(final String key) {
+            this.key(key, "");
+            return this;
+        }
+
+        public Builder keys(final String... keys) {
+            for (final String key : keys) {
+                this.key(key, "");
+            }
+            return this;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/df6cfd60/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
index 9cae845..705e136 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoMapper.java
@@ -95,6 +95,7 @@ import java.time.Year;
 import java.time.YearMonth;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
+import java.util.AbstractMap;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Calendar;
@@ -295,6 +296,7 @@ public final class GryoMapper implements Mapper<Kryo> {
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(UUID.class, kryo -> new UUIDSerializer(), 17));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(URI.class, kryo -> new URISerializer(), 72));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(VertexTerminator.class, null, 13));
+            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(AbstractMap.SimpleEntry.class, kryo -> new EntrySerializer(), 120)); // ***LAST ID***
 
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(ReferenceEdge.class, null, 81));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(ReferenceVertexProperty.class, null, 82));
@@ -356,7 +358,7 @@ public final class GryoMapper implements Mapper<Kryo> {
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(GroupStepV3d0.GroupBiOperatorV3d0.class, null, 113));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(RangeGlobalStep.RangeBiOperator.class, null, 114));
             add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(OrderGlobalStep.OrderBiOperator.class, kryo -> new JavaSerializer(), 118)); // because they contain traversals
-            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(ProfileStep.ProfileBiOperator.class, null, 119)); // ***LAST ID***
+            add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(ProfileStep.ProfileBiOperator.class, null, 119));
         }};
 
         private final List<IoRegistry> registries = new ArrayList<>();


[04/49] incubator-tinkerpop git commit: some code clean up/organization and added a more complex group() nesting that requires an OLAP walk and an OLTP walk. Also found a bunch of HadoopGraph tests that were needlessly being Opt_Out'd -- fixed.

Posted by dk...@apache.org.
some code clean up/organization and added a more complex group() nesting that requires an OLAP walk and an OLTP walk. Also found a bunch of HadoopGraph tests that were needlessly being Opt_Out'd -- fixed.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 085be94691357db5615ed4281a978b686bce6898
Parents: e087123
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue May 24 01:23:14 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue May 24 01:23:14 2016 -0600

----------------------------------------------------------------------
 .../process/traversal/step/map/GroupStep.java   |  59 ++++++---
 .../step/sideEffect/GroovyGroupTest.groovy      |   5 +
 .../traversal/step/sideEffect/GroupTest.java    |  35 ++++++
 .../gremlin/hadoop/structure/HadoopGraph.java   | 124 ++++++++++++++-----
 4 files changed, 172 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/085be946/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
index 7a93796..77e39bb 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroupStep.java
@@ -40,6 +40,9 @@ import org.apache.tinkerpop.gremlin.util.function.HashMapSupplier;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.javatuples.Pair;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -85,11 +88,11 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
     public Map<K, V> projectTraverser(final Traverser.Admin<S> traverser) {
         final Map<K, V> map = new HashMap<>(1);
         if (null == this.preTraversal) {
-            map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverser.split());
+            map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverser);
         } else {
             final TraverserSet traverserSet = new TraverserSet<>();
             this.preTraversal.reset();
-            this.preTraversal.addStart(traverser.split());
+            this.preTraversal.addStart(traverser);
             this.preTraversal.getEndStep().forEachRemaining(traverserSet::add);
             map.put(TraversalUtil.applyNullable(traverser, this.keyTraversal), (V) traverserSet);
         }
@@ -150,6 +153,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
 
     public static final class GroupBiOperator<K, V> implements BinaryOperator<Map<K, V>>, Serializable {
 
+        // size limit before Barrier.processAllStarts() to lazy reduce
         private static final int SIZE_LIMIT = 1000;
 
         private Traversal.Admin<?, V> valueTraversal;
@@ -173,6 +177,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                 if (null == objectA) {
                     objectA = objectB;
                 } else {
+                    // TRAVERSER
                     if (objectA instanceof Traverser.Admin) {
                         if (objectB instanceof Traverser.Admin) {
                             final TraverserSet set = new TraverserSet();
@@ -186,29 +191,28 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                                 this.valueTraversal.reset();
                                 ((Step) this.barrierStep).addStarts(set.iterator());
                                 objectA = this.barrierStep.nextBarrier();
-                            } else {
+                            } else
                                 objectA = objectB;
-                            }
                         } else if (objectB instanceof Pair) {
                             final TraverserSet set = (TraverserSet) ((Pair) objectB).getValue0();
                             set.add((Traverser.Admin) objectA);
-                            if (set.size() > SIZE_LIMIT) {
+                            if (set.size() > SIZE_LIMIT) {    // barrier step can never be null -- no need to check
                                 this.valueTraversal.reset();
                                 ((Step) this.barrierStep).addStarts(set.iterator());
                                 this.barrierStep.addBarrier(((Pair) objectB).getValue1());
                                 objectA = this.barrierStep.nextBarrier();
-                            } else {
+                            } else
                                 objectA = Pair.with(set, ((Pair) objectB).getValue1());
-                            }
-                        } else {
+                        } else
                             objectA = Pair.with(new TraverserSet((Traverser.Admin) objectA), objectB);
-                        }
+                        // TRAVERSER SET
                     } else if (objectA instanceof TraverserSet) {
                         if (objectB instanceof Traverser.Admin) {
-                            ((TraverserSet) objectA).add((Traverser.Admin) objectB);
-                            if (null != this.barrierStep && ((TraverserSet) objectA).size() > SIZE_LIMIT) {
+                            final TraverserSet set = (TraverserSet) objectA;
+                            set.add((Traverser.Admin) objectB);
+                            if (null != this.barrierStep && set.size() > SIZE_LIMIT) {
                                 this.valueTraversal.reset();
-                                ((Step) this.barrierStep).addStarts(((TraverserSet) objectA).iterator());
+                                ((Step) this.barrierStep).addStarts(set.iterator());
                                 objectA = this.barrierStep.nextBarrier();
                             }
                         } else if (objectB instanceof TraverserSet) {
@@ -222,24 +226,30 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                         } else if (objectB instanceof Pair) {
                             final TraverserSet set = (TraverserSet) objectA;
                             set.addAll((TraverserSet) ((Pair) objectB).getValue0());
-                            if (set.size() > SIZE_LIMIT) {
+                            if (set.size() > SIZE_LIMIT) {  // barrier step can never be null -- no need to check
                                 this.valueTraversal.reset();
                                 ((Step) this.barrierStep).addStarts(set.iterator());
                                 this.barrierStep.addBarrier(((Pair) objectB).getValue1());
                                 objectA = this.barrierStep.nextBarrier();
-                            } else {
+                            } else
                                 objectA = Pair.with(set, ((Pair) objectB).getValue1());
-                            }
-                        } else {
+                        } else
                             objectA = Pair.with(objectA, objectB);
-                        }
+                        // TRAVERSER SET + BARRIER
                     } else if (objectA instanceof Pair) {
                         if (objectB instanceof Traverser.Admin) {
-                            ((TraverserSet) ((Pair) objectA).getValue0()).add((Traverser.Admin) objectB);
+                            final TraverserSet set = ((TraverserSet) ((Pair) objectA).getValue0());
+                            set.add((Traverser.Admin) objectB);
+                            if (set.size() > SIZE_LIMIT) { // barrier step can never be null -- no need to check
+                                this.valueTraversal.reset();
+                                ((Step) this.barrierStep).addStarts(set.iterator());
+                                this.barrierStep.addBarrier(((Pair) objectA).getValue1());
+                                objectA = this.barrierStep.nextBarrier();
+                            }
                         } else if (objectB instanceof TraverserSet) {
                             final TraverserSet set = (TraverserSet) ((Pair) objectA).getValue0();
                             set.addAll((TraverserSet) objectB);
-                            if (null != this.barrierStep && set.size() > SIZE_LIMIT) {
+                            if (set.size() > SIZE_LIMIT) {   // barrier step can never be null -- no need to check
                                 this.valueTraversal.reset();
                                 ((Step) this.barrierStep).addStarts(set.iterator());
                                 this.barrierStep.addBarrier(((Pair) objectA).getValue1());
@@ -259,6 +269,7 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
                             ((Step) this.barrierStep).addStarts(((TraverserSet) ((Pair) objectA).getValue0()).iterator());
                             objectA = this.barrierStep.nextBarrier();
                         }
+                        // BARRIER
                     } else {
                         if (objectB instanceof Traverser.Admin) {
                             objectA = Pair.with(new TraverserSet<>((Traverser.Admin) objectB), objectA);
@@ -282,6 +293,16 @@ public final class GroupStep<S, K, V> extends ReducingBarrierStep<S, Map<K, V>>
             }
             return mapA;
         }
+
+        // necessary to control Java Serialization to ensure proper clearing of internal traverser data
+        private void writeObject(final ObjectOutputStream outputStream) throws IOException {
+            outputStream.writeObject(this.valueTraversal.clone());
+        }
+
+        private void readObject(final ObjectInputStream inputStream) throws IOException, ClassNotFoundException {
+            this.valueTraversal = (Traversal.Admin<?, V>) inputStream.readObject();
+            this.barrierStep = TraversalHelper.getFirstStepOfAssignableClass(Barrier.class, this.valueTraversal).orElse(null);
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/085be946/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
index 156b350..13802b8 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
@@ -113,5 +113,10 @@ public abstract class GroovyGroupTest {
         public Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX() {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V.group().by(bothE().count).by(group().by(label))")
         }
+
+        @Override
+        public Traversal<Vertex, Map<String, Map<String, Number>>> get_g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V.out('followedBy').group.by('songType').by(bothE().group.by(label).by(values('weight').sum))")
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/085be946/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
index d4c4d74..356eb58 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
@@ -86,6 +86,8 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX();
 
+    public abstract Traversal<Vertex, Map<String, Map<String, Number>>> get_g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_group_byXnameX() {
@@ -393,6 +395,34 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
         assertTrue(list.contains(convertToVertex(graph, "josh")));
     }
 
+    @Test
+    @LoadGraphWith(GRATEFUL)
+    public void g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX() {
+        final Traversal<Vertex, Map<String, Map<String, Number>>> traversal = get_g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX();
+        final Map<String, Map<String, Number>> map = traversal.next();
+        assertFalse(traversal.hasNext());
+        assertEquals(3, map.size());
+        assertTrue(map.containsKey(""));
+        assertTrue(map.containsKey("original"));
+        assertTrue(map.containsKey("cover"));
+        //
+        Map<String, Number> subMap = map.get("");
+        assertEquals(1, subMap.size());
+        assertEquals(179350, subMap.get("followedBy").intValue());
+        //
+        subMap = map.get("original");
+        assertEquals(3, subMap.size());
+        assertEquals(2185613, subMap.get("followedBy").intValue());
+        assertEquals(0, subMap.get("writtenBy").intValue());
+        assertEquals(0, subMap.get("sungBy").intValue());
+        //
+        subMap = map.get("cover");
+        assertEquals(3, subMap.size());
+        assertEquals(777982, subMap.get("followedBy").intValue());
+        assertEquals(0, subMap.get("writtenBy").intValue());
+        assertEquals(0, subMap.get("sungBy").intValue());
+    }
+
     public static class Traversals extends GroupTest {
 
         @Override
@@ -479,5 +509,10 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Map<Long, Map<String, List<Vertex>>>> get_g_V_group_byXbothE_countX_byXgroup_byXlabelXX() {
             return g.V().<Long, Map<String, List<Vertex>>>group().by(__.bothE().count()).by(__.group().by(T.label));
         }
+
+        @Override
+        public Traversal<Vertex, Map<String, Map<String, Number>>> get_g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX() {
+            return g.V().out("followedBy").<String, Map<String, Number>>group().by("songType").by(__.bothE().group().by(T.label).by(__.values("weight").sum()));
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/085be946/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index bf2f08b..d643cd4 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -53,97 +53,113 @@ import java.util.stream.Stream;
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__a_0sungBy_bX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_dX_whereXc_sungBy_dX_whereXd_hasXname_GarciaXX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_matchXa_knows_b__c_knows_bX",
-        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
-//computers = {GiraphGraphComputer.class})
+        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.",
+        computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_matchXa_created_b__c_created_bX_selectXa_b_cX_byXnameX",
-        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
-//computers = {GiraphGraphComputer.class})
+        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.",
+        computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.MatchTest$Traversals",
         method = "g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX",
-        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
-// computers = {GiraphGraphComputer.class})
+        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.",
+        computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__a_0sungBy_bX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_knows_b__c_knows_bX",
-        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
-//computers = {GiraphGraphComputer.class})
+        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.",
+        computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_created_b__c_created_bX_selectXa_b_cX_byXnameX",
-        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
-//computers = {GiraphGraphComputer.class})
+        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.",
+        computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_out_asXcX_matchXb_knows_a__c_created_eX_selectXcX",
-        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.")
-//computers = {GiraphGraphComputer.class})
+        reason = "Giraph does a hard kill on failure and stops threads which stops test cases. Exception handling semantics are correct though.",
+        computers = {"org.apache.tinkerpop.gremlin.giraph.process.computer.GiraphGraphComputer"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_dX_whereXc_sungBy_dX_whereXd_hasXname_GarciaXX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals",
         method = "g_V_both_both_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals",
         method = "g_V_repeatXoutX_timesX3X_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals",
         method = "g_V_repeatXoutX_timesX8X_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest$Traversals",
         method = "g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals",
         method = "g_V_both_both_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals",
         method = "g_V_repeatXoutX_timesX3X_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals",
         method = "g_V_repeatXoutX_timesX8X_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyCountTest$Traversals",
         method = "g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.ProfileTest$Traversals",
         method = "grateful_V_out_out_profile",
@@ -162,20 +178,64 @@ import java.util.stream.Stream;
         reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest",
+        method = "g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest",
+        method = "g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest",
         method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTest",
         method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0",
         method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupTestV3d0",
         method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX",
-        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.")
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals",
+        method = "g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals",
+        method = "g_V_outXfollowedByX_group_byXsongTypeX_byXbothE_group_byXlabelX_byXweight_sumXX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals",
+        method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTest$Traversals",
+        method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTestV3d0$Traversals",
+        method = "g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
+@Graph.OptOut(
+        test = "org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroovyGroupTestV3d0$Traversals",
+        method = "g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX",
+        reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
+        computers = {"ALL"})
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest",
         method = "shouldStartAndEndWorkersForVertexProgramAndMapReduce",


[36/49] incubator-tinkerpop git commit: Renamed gryo method for better consistency with graphson.

Posted by dk...@apache.org.
Renamed gryo method for better consistency with graphson.


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

Branch: refs/heads/TINKERPOP-1298
Commit: c12771c862f5f47028e37cc51372e1c190a29c0c
Parents: 5b6394c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 20 13:09:02 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 27 10:59:46 2016 -0400

----------------------------------------------------------------------
 .../gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java  | 6 +++---
 .../gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java      | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c12771c8/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
index 4190d96..9198ae1 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
@@ -80,8 +80,8 @@ public abstract class AbstractGryoMessageSerializerV1d0 extends AbstractMessageS
      * Called from the {@link #configure(Map, Map)} method right before the call to create the builder. Sub-classes
      * can choose to alter the builder or completely replace it.
      */
-    public GryoMapper.Builder beforeCreateMapper(final GryoMapper.Builder builder, final Map<String, Object> config,
-                                                 final Map<String, Graph> graphs) {
+    public GryoMapper.Builder configureBuilder(final GryoMapper.Builder builder, final Map<String, Object> config,
+                                               final Map<String, Graph> graphs) {
         return builder;
     }
 
@@ -115,7 +115,7 @@ public abstract class AbstractGryoMessageSerializerV1d0 extends AbstractMessageS
         this.serializeToString = Boolean.parseBoolean(config.getOrDefault(TOKEN_SERIALIZE_RESULT_TO_STRING, "false").toString());
         this.bufferSize = Integer.parseInt(config.getOrDefault(TOKEN_BUFFER_SIZE, "4096").toString());
 
-        this.gryoMapper = beforeCreateMapper(builder, config, graphs).create();
+        this.gryoMapper = configureBuilder(builder, config, graphs).create();
     }
 
     private void addClassResolverSupplier(final Map<String, Object> config, final GryoMapper.Builder builder) {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c12771c8/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
index a4ff38b..dab7c58 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
@@ -63,8 +63,8 @@ public class GryoLiteMessageSerializerV1d0 extends AbstractGryoMessageSerializer
     }
 
     @Override
-    public GryoMapper.Builder beforeCreateMapper(final GryoMapper.Builder builder, final Map<String, Object> config,
-                                                 final Map<String, Graph> graphs) {
+    public GryoMapper.Builder configureBuilder(final GryoMapper.Builder builder, final Map<String, Object> config,
+                                               final Map<String, Graph> graphs) {
         return overrideWithLite(builder);
     }
 


[15/49] incubator-tinkerpop git commit: lots of more documentation on TraversalVertexProgram and I really combed through the code and was able to find numerous minor optimizations here and there.

Posted by dk...@apache.org.
lots of more documentation on TraversalVertexProgram and I really combed through the code and was able to find numerous minor optimizations here and there.


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

Branch: refs/heads/TINKERPOP-1298
Commit: e6f2caa89adc8e6630dadc613ca9b6b92416c223
Parents: 7255844
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 14:54:15 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 14:54:15 2016 -0600

----------------------------------------------------------------------
 .../computer/traversal/MasterExecutor.java      | 47 +++++++++-----------
 .../traversal/TraversalVertexProgram.java       |  2 +
 .../computer/traversal/WorkerExecutor.java      | 32 ++++++-------
 .../gremlin/hadoop/structure/HadoopGraph.java   |  2 +-
 .../HaltedTraverserFactoryStrategyTest.java     |  7 ++-
 5 files changed, 43 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6f2caa8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
index b994f1e..1c1e9d2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
@@ -43,7 +43,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMatrix;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
-import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.util.HashSet;
 import java.util.Iterator;
@@ -70,20 +69,17 @@ final class MasterExecutor {
         return traverser;
     }
 
-    // handle traversers and data that were sent from the workers to the master traversal via memory
-    protected static void processMemory(final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final TraverserSet<Object> traverserSet, final Set<String> completedBarriers) {
+    protected static void processMemory(final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final TraverserSet<Object> toProcessTraversers, final Set<String> completedBarriers) {
+        // handle traversers and data that were sent from the workers to the master traversal via memory
         if (memory.exists(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
             for (final String key : memory.<Set<String>>get(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
                 final Step<Object, Object> step = traversalMatrix.getStepById(key);
-                if (null == step) continue; // why? how can this happen?
                 assert step instanceof Barrier;
                 completedBarriers.add(step.getId());
                 if (!(step instanceof LocalBarrier)) {  // local barriers don't do any processing on the master traversal (they just lock on the workers)
                     final Barrier<Object> barrier = (Barrier<Object>) step;
                     barrier.addBarrier(memory.get(key));
-                    while (step.hasNext()) {
-                        traverserSet.add(step.next());
-                    }
+                    step.forEachRemaining(toProcessTraversers::add);
                     // if it was a reducing barrier step, reset the barrier to its seed value
                     if (step instanceof ReducingBarrierStep)
                         memory.set(step.getId(), ((ReducingBarrierStep) step).getSeedSupplier().get());
@@ -100,34 +96,33 @@ final class MasterExecutor {
                                             final TraverserSet<Object> haltedTraversers,
                                             final Class haltedTraverserFactory) {
 
-
         while (!toProcessTraversers.isEmpty()) {
             final TraverserSet<Object> localActiveTraversers = new TraverserSet<>();
             Step<Object, Object> previousStep = EmptyStep.instance();
             Step<Object, Object> currentStep = EmptyStep.instance();
 
-            final Iterator<Traverser.Admin<Object>> traversers = IteratorUtils.removeOnNext(toProcessTraversers.iterator());
+            // these are traversers that are at the master traversal and will either halt here or be distributed back to the workers as needed
+            final Iterator<Traverser.Admin<Object>> traversers = toProcessTraversers.iterator();
             while (traversers.hasNext()) {
                 final Traverser.Admin<Object> traverser = traversers.next();
-                traverser.set(DetachedFactory.detach(traverser.get(), true));
+                traversers.remove();
+                traverser.set(DetachedFactory.detach(traverser.get(), true)); // why?
                 traverser.setSideEffects(traversal.get().getSideEffects());
-                if (traverser.isHalted()) {
+                if (traverser.isHalted())
                     haltedTraversers.add(MasterExecutor.detach(traverser, haltedTraverserFactory));
-                } else if (isRemoteTraverser(traverser, traversalMatrix)) {  // this is so that patterns like order().name work as expected.
+                else if (isRemoteTraverser(traverser, traversalMatrix))  // this is so that patterns like order().name work as expected. try and stay local as long as possible
                     remoteActiveTraversers.add(traverser.detach());
-                } else {
+                else {
                     currentStep = traversalMatrix.getStepById(traverser.getStepId());
                     if (!currentStep.getId().equals(previousStep.getId()) && !(previousStep instanceof EmptyStep)) {
                         while (previousStep.hasNext()) {
                             final Traverser.Admin<Object> result = previousStep.next();
-                            if (result.isHalted()) {
+                            if (result.isHalted())
                                 haltedTraversers.add(MasterExecutor.detach(result, haltedTraverserFactory));
-                            } else {
-                                if (isRemoteTraverser(result, traversalMatrix)) {
-                                    remoteActiveTraversers.add(result.detach());
-                                } else
-                                    localActiveTraversers.add(result);
-                            }
+                            else if (isRemoteTraverser(result, traversalMatrix))
+                                remoteActiveTraversers.add(result.detach());
+                            else
+                                localActiveTraversers.add(result);
                         }
                     }
                     currentStep.addStart(traverser);
@@ -137,14 +132,12 @@ final class MasterExecutor {
             if (!(currentStep instanceof EmptyStep)) {
                 while (currentStep.hasNext()) {
                     final Traverser.Admin<Object> traverser = currentStep.next();
-                    if (traverser.isHalted()) {
+                    if (traverser.isHalted())
                         haltedTraversers.add(MasterExecutor.detach(traverser, haltedTraverserFactory));
-                    } else {
-                        if (isRemoteTraverser(traverser, traversalMatrix)) {
-                            remoteActiveTraversers.add(traverser.detach());
-                        } else
-                            localActiveTraversers.add(traverser);
-                    }
+                    else if (isRemoteTraverser(traverser, traversalMatrix))
+                        remoteActiveTraversers.add(traverser.detach());
+                    else
+                        localActiveTraversers.add(traverser);
                 }
             }
             assert toProcessTraversers.isEmpty();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6f2caa8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
index d4daaac..4479306 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
@@ -297,7 +297,9 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
         if (voteToHalt) {
             // local traverser sets to process
             final TraverserSet<Object> toProcessTraversers = new TraverserSet<>();
+            // traversers that need to be sent back to the workers (no longer can be processed locally by the master traversal)
             final TraverserSet<Object> remoteActiveTraversers = new TraverserSet<>();
+            // halted traversers that have completed their journey
             final TraverserSet<Object> haltedTraversers = memory.get(HALTED_TRAVERSERS);
             // get all barrier traversers
             final Set<String> completedBarriers = new HashSet<>();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6f2caa8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
index f833b6f..5798af0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.process.computer.traversal;
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.MessageScope;
 import org.apache.tinkerpop.gremlin.process.computer.Messenger;
-import org.apache.tinkerpop.gremlin.process.computer.util.SingleMessenger;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
@@ -36,7 +35,6 @@ import org.apache.tinkerpop.gremlin.structure.Element;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
-import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceElement;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
@@ -65,19 +63,18 @@ final class WorkerExecutor {
         final TraverserSet<Object> haltedTraversers = vertex.value(TraversalVertexProgram.HALTED_TRAVERSERS);
         final TraverserSet<Object> activeTraversers = new TraverserSet<>();
         final TraverserSet<Object> toProcessTraversers = new TraverserSet<>();
-        final boolean isTesting = Boolean.valueOf(System.getProperty("is.testing", "false"));
 
         ////////////////////////////////
         // GENERATE LOCAL TRAVERSERS //
         ///////////////////////////////
 
-        // some memory systems are interacted by multiple threads and thus, concurrent modification can happen at iterator.remove()
+        // these are traversers that are going from OLTP (master) to OLAP (workers)
+        // these traversers were broadcasted from the master traversal to the workers for attachment
+        final TraverserSet<Object> maybeActiveTraversers = memory.get(TraversalVertexProgram.ACTIVE_TRAVERSERS);
+        // some memory systems are interacted with by multiple threads and thus, concurrent modification can happen at iterator.remove().
         // its better to reduce the memory footprint and shorten the active traverser list so synchronization is worth it.
-        // most distributed OLAP systems have the memory partitioned and thus, this synchronization does nothing
-        synchronized (memory) {
-            // these are traversers that are going from OLTP to OLAP
-            // these traversers were broadcasted from the master traversal to the workers for attachment
-            final TraverserSet<Object> maybeActiveTraversers = memory.get(TraversalVertexProgram.ACTIVE_TRAVERSERS);
+        // most distributed OLAP systems have the memory partitioned and thus, this synchronization does nothing.
+        synchronized (maybeActiveTraversers) {
             final Iterator<Traverser.Admin<Object>> iterator = maybeActiveTraversers.iterator();
             while (iterator.hasNext()) {
                 final Traverser.Admin<Object> traverser = iterator.next();
@@ -97,20 +94,19 @@ final class WorkerExecutor {
                 traverser.setSideEffects(traversalSideEffects);
                 toProcessTraversers.add(traverser);
             });
+            assert previousActiveTraversers.isEmpty();
+            // remove the property to save space
             vertex.property(TraversalVertexProgram.ACTIVE_TRAVERSERS).remove();
         });
         // these are traversers that have been messaged to the vertex from another vertex
         final Iterator<TraverserSet<Object>> messages = messenger.receiveMessages();
         while (messages.hasNext()) {
             IteratorUtils.removeOnNext(messages.next().iterator()).forEachRemaining(traverser -> {
-                // this is internal testing to ensure that messaged elements are always ReferenceXXX and not DetachedXXX (related to HaltedTraverserFactoryStrategy)
-                if (isTesting && !(messenger instanceof SingleMessenger) && traverser.get() instanceof Element)
-                    assert traverser.get() instanceof ReferenceElement;
                 if (traverser.isHalted()) {
                     if (returnHaltedTraversers)
                         memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
                     else
-                        haltedTraversers.add(traverser);
+                        haltedTraversers.add(traverser.detach());
                 } else {
                     // traverser is not halted and thus, should be processed locally
                     traverser.attach(Attachable.Method.get(vertex));
@@ -132,6 +128,7 @@ final class WorkerExecutor {
                 final Traverser.Admin<Object> traverser = traversers.next();
                 traversers.remove();
                 final Step<Object, Object> currentStep = traversalMatrix.getStepById(traverser.getStepId());
+                // try and fill up the current step as much as possible with traversers to get a bulking optimization
                 if (!currentStep.getId().equals(previousStep.getId()) && !(previousStep instanceof EmptyStep))
                     WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserFactory);
                 currentStep.addStart(traverser);
@@ -150,12 +147,11 @@ final class WorkerExecutor {
                     if (traverser.get() instanceof Element || traverser.get() instanceof Property) {      // GRAPH OBJECT
                         // if the element is remote, then message, else store it locally for re-processing
                         final Vertex hostingVertex = WorkerExecutor.getHostingVertex(traverser.get());
-                        if (!vertex.equals(hostingVertex)) { // necessary for path access
-                            voteToHalt.set(false);
+                        if (!vertex.equals(hostingVertex)) { // if its host is not the current vertex, then send the traverser to the hosting vertex
+                            voteToHalt.set(false); // if message is passed, then don't vote to halt
                             messenger.sendMessage(MessageScope.Global.of(hostingVertex), new TraverserSet<>(traverser.detach()));
                         } else {
-                            if (traverser.get() instanceof Attachable)   // necessary for path access to local object
-                                traverser.attach(Attachable.Method.get(vertex));
+                            traverser.attach(Attachable.Method.get(vertex));
                             toProcessTraversers.add(traverser);
                         }
                     } else                                                                              // STANDARD OBJECT
@@ -195,7 +191,7 @@ final class WorkerExecutor {
                             else
                                 haltedTraversers.add(traverser.detach());
                         } else
-                            localBarrierTraversers.add(traverser);
+                            localBarrierTraversers.add(traverser.detach());
                     });
                 }
                 memory.add(TraversalVertexProgram.MUTATED_MEMORY_KEYS, new HashSet<>(Collections.singleton(step.getId())));

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6f2caa8/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
index d643cd4..d0f50d0 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/HadoopGraph.java
@@ -109,7 +109,7 @@ import java.util.stream.Stream;
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX",
         reason = "Hadoop-Gremlin is OLAP-oriented and for OLTP operations, linear-scan joins are required. This particular tests takes many minutes to execute.",
-        computers = {"ALL"})
+        computers = {"org.apache.tinkerpop.gremlin.spark.process.computer.SparkGraphComputer"})  // this is a nasty long test, just do it once in Java MatchTest
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.GroovyMatchTest$Traversals",
         method = "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX",

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e6f2caa8/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
index af0b3b7..43bc94e 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
@@ -23,10 +23,12 @@ import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decorati
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedPath;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferencePath;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
@@ -64,6 +66,7 @@ public class HaltedTraverserFactoryStrategyTest {
         g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
         g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
         g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(DetachedPath.class, path.getClass()));
     }
 
     @Test
@@ -77,7 +80,8 @@ public class HaltedTraverserFactoryStrategyTest {
         g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
         g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
         g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
-        //
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
+        // the default should be reference elements
         g = graph.traversal().withComputer();
         g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
         g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
@@ -86,6 +90,7 @@ public class HaltedTraverserFactoryStrategyTest {
         g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
         g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
         g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().out().path().forEachRemaining(path -> assertEquals(ReferencePath.class, path.getClass()));
     }
 
 }


[40/49] incubator-tinkerpop git commit: Clean up scoping of configuration methods for gryo message serializer.

Posted by dk...@apache.org.
Clean up scoping of configuration methods for gryo message serializer.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 954e3828dcd205a6e7986bd948667b52b4eb4bfc
Parents: c12771c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 20 13:23:32 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 27 10:59:46 2016 -0400

----------------------------------------------------------------------
 .../gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java    | 4 ++--
 .../gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/954e3828/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
index 9198ae1..498536d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGryoMessageSerializerV1d0.java
@@ -80,8 +80,8 @@ public abstract class AbstractGryoMessageSerializerV1d0 extends AbstractMessageS
      * Called from the {@link #configure(Map, Map)} method right before the call to create the builder. Sub-classes
      * can choose to alter the builder or completely replace it.
      */
-    public GryoMapper.Builder configureBuilder(final GryoMapper.Builder builder, final Map<String, Object> config,
-                                               final Map<String, Graph> graphs) {
+    GryoMapper.Builder configureBuilder(final GryoMapper.Builder builder, final Map<String, Object> config,
+                                        final Map<String, Graph> graphs) {
         return builder;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/954e3828/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
index dab7c58..14f716d 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GryoLiteMessageSerializerV1d0.java
@@ -63,7 +63,7 @@ public class GryoLiteMessageSerializerV1d0 extends AbstractGryoMessageSerializer
     }
 
     @Override
-    public GryoMapper.Builder configureBuilder(final GryoMapper.Builder builder, final Map<String, Object> config,
+    GryoMapper.Builder configureBuilder(final GryoMapper.Builder builder, final Map<String, Object> config,
                                                final Map<String, Graph> graphs) {
         return overrideWithLite(builder);
     }


[23/49] incubator-tinkerpop git commit: Fixed the previous commit. We don't want to increase the step offset, but decrease the traversal size, after removing steps from a traversal.

Posted by dk...@apache.org.
Fixed the previous commit. We don't want to increase the step offset, but decrease the traversal size, after removing steps from a traversal.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 041c0333b3ed4d765fcd4afa5d81666bcac0541d
Parents: bffa77f
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed May 25 21:55:27 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:36 2016 +0200

----------------------------------------------------------------------
 .../traversal/strategy/optimization/RangeByIsCountStrategy.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/041c0333/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 1b544c2..efa79e6 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
@@ -70,7 +70,7 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
 
     @Override
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        final int size = traversal.getSteps().size();
+        int size = traversal.getSteps().size();
         Step prev = null;
         for (int i = 0; i < size; i++) {
             final Step curr = traversal.getSteps().get(i);
@@ -109,7 +109,7 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                         if (useNotStep) {
                             traversal.asAdmin().removeStep(next); // IsStep
                             traversal.asAdmin().removeStep(curr); // CountStep
-                            i += 2;
+                            size -= 2;
                             final Traversal.Admin inner = __.start().asAdmin();
                             TraversalHelper.insertAfterStep(prev, inner.getStartStep(), inner);
                             TraversalHelper.replaceStep(prev, new NotStep<>(traversal, inner), traversal);


[10/49] incubator-tinkerpop git commit: minor tweak. need to work in another branch.

Posted by dk...@apache.org.
minor tweak. need to work in another branch.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 19f16f1c6a9954a30fc2031df34724e56b2124fc
Parents: b72ea66
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 08:42:51 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 08:42:51 2016 -0600

----------------------------------------------------------------------
 .../strategy/decoration/HaltedTraverserFactoryStrategy.java   | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19f16f1c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
index 44542c7..b046986 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
@@ -27,6 +27,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 
+import java.util.Collections;
+import java.util.Set;
+
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
@@ -50,4 +53,8 @@ public final class HaltedTraverserFactoryStrategy extends AbstractTraversalStrat
     public static HaltedTraverserFactoryStrategy reference() {
         return new HaltedTraverserFactoryStrategy(ReferenceFactory.class);
     }
+
+    public Set<Class<? extends DecorationStrategy>> applyPrior() {
+        return Collections.singleton(VertexProgramStrategy.class);
+    }
 }


[42/49] incubator-tinkerpop git commit: Merge branch 'TINKERPOP-1310'

Posted by dk...@apache.org.
Merge branch 'TINKERPOP-1310'


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

Branch: refs/heads/TINKERPOP-1298
Commit: aa34888677e748f7316a0870a3a7cc71c4f52df5
Parents: 86d8b5c 8be75a9
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri May 27 09:54:19 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri May 27 09:54:19 2016 -0600

----------------------------------------------------------------------
 .../computer/traversal/MasterExecutor.java      |  65 +++++------
 .../traversal/TraversalVertexProgram.java       |  36 +++---
 .../computer/traversal/WorkerExecutor.java      | 111 ++++++++++++-------
 .../decoration/HaltedTraverserStrategy.java     |  69 ++++++++++++
 .../gremlin/hadoop/structure/HadoopGraph.java   |   2 +-
 .../decoration/HaltedTraverserStrategyTest.java | 102 +++++++++++++++++
 6 files changed, 290 insertions(+), 95 deletions(-)
----------------------------------------------------------------------



[17/49] incubator-tinkerpop git commit: Moved MasterExecutor.detach() to HaltedTraverserStrategy.halt() as this is now generally useful for OLTP and not just OLAP. Lots more nick nack cleanups and comments.

Posted by dk...@apache.org.
Moved MasterExecutor.detach() to HaltedTraverserStrategy.halt() as this is now generally useful for OLTP and not just OLAP. Lots more nick nack cleanups and comments.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 56c43ea7bd89e0ef72b958400d7bd83a10ad6a15
Parents: f78d1cb
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 26 07:38:12 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 26 07:38:12 2016 -0600

----------------------------------------------------------------------
 .../computer/traversal/MasterExecutor.java      | 21 ++-------
 .../traversal/TraversalVertexProgram.java       | 21 +++++----
 .../computer/traversal/WorkerExecutor.java      | 49 ++++++++++++--------
 .../decoration/HaltedTraverserStrategy.java     | 17 ++++++-
 4 files changed, 61 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/56c43ea7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
index 1c1e9d2..0462950 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
@@ -20,6 +20,7 @@
 package org.apache.tinkerpop.gremlin.process.computer.traversal;
 
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
@@ -57,18 +58,6 @@ final class MasterExecutor {
 
     }
 
-    // the halted traversers can either be reference or detached elements -- this is good for determining how much data around the element the user wants to get
-    // see HaltedTraverserFactoryStrategy for how this is all connected
-    protected static <R> Traverser.Admin<R> detach(final Traverser.Admin<R> traverser, final Class haltedTraverserFactory) {
-        if (haltedTraverserFactory.equals(DetachedFactory.class))
-            traverser.set(DetachedFactory.detach(traverser.get(), true));
-        else if (haltedTraverserFactory.equals(ReferenceFactory.class))
-            traverser.set(ReferenceFactory.detach(traverser.get()));
-        else
-            throw new IllegalArgumentException("The following detaching factory is unknown: " + haltedTraverserFactory);
-        return traverser;
-    }
-
     protected static void processMemory(final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final TraverserSet<Object> toProcessTraversers, final Set<String> completedBarriers) {
         // handle traversers and data that were sent from the workers to the master traversal via memory
         if (memory.exists(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
@@ -94,7 +83,7 @@ final class MasterExecutor {
                                             TraverserSet<Object> toProcessTraversers,
                                             final TraverserSet<Object> remoteActiveTraversers,
                                             final TraverserSet<Object> haltedTraversers,
-                                            final Class haltedTraverserFactory) {
+                                            final HaltedTraverserStrategy haltedTraverserStrategy) {
 
         while (!toProcessTraversers.isEmpty()) {
             final TraverserSet<Object> localActiveTraversers = new TraverserSet<>();
@@ -109,7 +98,7 @@ final class MasterExecutor {
                 traverser.set(DetachedFactory.detach(traverser.get(), true)); // why?
                 traverser.setSideEffects(traversal.get().getSideEffects());
                 if (traverser.isHalted())
-                    haltedTraversers.add(MasterExecutor.detach(traverser, haltedTraverserFactory));
+                    haltedTraversers.add(haltedTraverserStrategy.halt(traverser));
                 else if (isRemoteTraverser(traverser, traversalMatrix))  // this is so that patterns like order().name work as expected. try and stay local as long as possible
                     remoteActiveTraversers.add(traverser.detach());
                 else {
@@ -118,7 +107,7 @@ final class MasterExecutor {
                         while (previousStep.hasNext()) {
                             final Traverser.Admin<Object> result = previousStep.next();
                             if (result.isHalted())
-                                haltedTraversers.add(MasterExecutor.detach(result, haltedTraverserFactory));
+                                haltedTraversers.add(haltedTraverserStrategy.halt(traverser));
                             else if (isRemoteTraverser(result, traversalMatrix))
                                 remoteActiveTraversers.add(result.detach());
                             else
@@ -133,7 +122,7 @@ final class MasterExecutor {
                 while (currentStep.hasNext()) {
                     final Traverser.Admin<Object> traverser = currentStep.next();
                     if (traverser.isHalted())
-                        haltedTraversers.add(MasterExecutor.detach(traverser, haltedTraverserFactory));
+                        haltedTraversers.add(haltedTraverserStrategy.halt(traverser));
                     else if (isRemoteTraverser(traverser, traversalMatrix))
                         remoteActiveTraversers.add(traverser.detach());
                     else

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/56c43ea7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
index 07ab98a..c9dc053 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/TraversalVertexProgram.java
@@ -109,7 +109,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     private final Set<MapReduce> mapReducers = new HashSet<>();
     private TraverserSet<Object> haltedTraversers;
     private boolean returnHaltedTraversers = false;
-    private Class haltedTraverserDetachFactory;
+    private HaltedTraverserStrategy haltedTraverserStrategy;
 
     private TraversalVertexProgram() {
     }
@@ -167,11 +167,11 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                         (this.traversal.get().getParent().asStep().getNextStep() instanceof ProfileStep && // same as above, but needed for profiling
                                 this.traversal.get().getParent().asStep().getNextStep().getNextStep() instanceof ComputerResultStep));
         // determine how to store halted traversers
-        this.haltedTraverserDetachFactory = ((HaltedTraverserStrategy) this.traversal.get().getStrategies().toList()
+        this.haltedTraverserStrategy = ((HaltedTraverserStrategy) this.traversal.get().getStrategies().toList()
                 .stream()
                 .filter(strategy -> strategy instanceof HaltedTraverserStrategy)
                 .findAny()
-                .orElse(HaltedTraverserStrategy.reference())).getHaltedTraverserFactory();
+                .orElse(HaltedTraverserStrategy.reference()));
         // register traversal side-effects in memory
         this.memoryComputeKeys.addAll(MemoryTraversalSideEffects.getMemoryComputeKeys(this.traversal.get()));
         // register MapReducer memory compute keys
@@ -217,9 +217,9 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                 traverser.setStepId(this.traversal.get().getStartStep().getId());
                 toProcessTraversers.add(traverser);
             });
-            assert haltedTraversers.isEmpty();
+            assert this.haltedTraversers.isEmpty();
             final TraverserSet<Object> remoteActiveTraversers = new TraverserSet<>();
-            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, this.haltedTraversers, this.haltedTraverserDetachFactory);
+            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, this.haltedTraversers, this.haltedTraverserStrategy);
             memory.set(HALTED_TRAVERSERS, this.haltedTraversers);
             memory.set(ACTIVE_TRAVERSERS, remoteActiveTraversers);
         } else {
@@ -238,6 +238,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
     @Override
     public void execute(final Vertex vertex, final Messenger<TraverserSet<Object>> messenger, final Memory memory) {
         // if any global halted traversers, simply don't use them as they were handled by master setup()
+        // these halted traversers are typically from a previous OLAP job that yielded traversers at the master traversal
         if (null != this.haltedTraversers)
             this.haltedTraversers = null;
         // memory is distributed
@@ -274,16 +275,16 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                 graphStep.forEachRemaining(traverser -> {
                     if (traverser.isHalted()) {
                         if (this.returnHaltedTraversers)
-                            memory.add(HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, this.haltedTraverserDetachFactory)));
+                            memory.add(HALTED_TRAVERSERS, new TraverserSet<>(this.haltedTraverserStrategy.halt(traverser)));
                         else
                             haltedTraversers.add((Traverser.Admin) traverser.detach());
                     } else
                         activeTraversers.add((Traverser.Admin) traverser);
                 });
             }
-            memory.add(VOTE_TO_HALT, activeTraversers.isEmpty() || WorkerExecutor.execute(vertex, new SingleMessenger<>(messenger, activeTraversers), this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserDetachFactory));
+            memory.add(VOTE_TO_HALT, activeTraversers.isEmpty() || WorkerExecutor.execute(vertex, new SingleMessenger<>(messenger, activeTraversers), this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserStrategy));
         } else   // ITERATION 1+
-            memory.add(VOTE_TO_HALT, WorkerExecutor.execute(vertex, messenger, this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserDetachFactory));
+            memory.add(VOTE_TO_HALT, WorkerExecutor.execute(vertex, messenger, this.traversalMatrix, memory, this.returnHaltedTraversers, this.haltedTraverserStrategy));
         // save space by not having an empty halted traversers property
         if (this.returnHaltedTraversers || haltedTraversers.isEmpty())
             vertex.<TraverserSet>property(HALTED_TRAVERSERS).remove();
@@ -307,7 +308,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
             final Set<String> completedBarriers = new HashSet<>();
             MasterExecutor.processMemory(this.traversalMatrix, memory, toProcessTraversers, completedBarriers);
             // process all results from barriers locally and when elements are touched, put them in remoteActiveTraversers
-            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, haltedTraversers, this.haltedTraverserDetachFactory);
+            MasterExecutor.processTraversers(this.traversal, this.traversalMatrix, toProcessTraversers, remoteActiveTraversers, haltedTraversers, this.haltedTraverserStrategy);
             // tell parallel barriers that might not have been active in the last round that they are no longer active
             memory.set(COMPLETED_BARRIERS, completedBarriers);
             if (!remoteActiveTraversers.isEmpty() ||
@@ -319,7 +320,7 @@ public final class TraversalVertexProgram implements VertexProgram<TraverserSet<
                 // finalize locally with any last traversers dangling in the local traversal
                 final Step<?, Object> endStep = (Step<?, Object>) this.traversal.get().getEndStep();
                 while (endStep.hasNext()) {
-                    haltedTraversers.add(MasterExecutor.detach(endStep.next(), this.haltedTraverserDetachFactory));
+                    haltedTraversers.add(this.haltedTraverserStrategy.halt(endStep.next()));
                 }
                 // the result of a TraversalVertexProgram are the halted traversers
                 memory.set(HALTED_TRAVERSERS, haltedTraversers);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/56c43ea7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
index 5798af0..7181992 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.process.computer.traversal;
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.MessageScope;
 import org.apache.tinkerpop.gremlin.process.computer.Messenger;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
@@ -57,7 +58,7 @@ final class WorkerExecutor {
                                      final TraversalMatrix<?, ?> traversalMatrix,
                                      final Memory memory,
                                      final boolean returnHaltedTraversers,
-                                     final Class haltedTraverserFactory) {
+                                     final HaltedTraverserStrategy haltedTraverserStrategy) {
         final TraversalSideEffects traversalSideEffects = traversalMatrix.getTraversal().getSideEffects();
         final AtomicBoolean voteToHalt = new AtomicBoolean(true);
         final TraverserSet<Object> haltedTraversers = vertex.value(TraversalVertexProgram.HALTED_TRAVERSERS);
@@ -68,6 +69,7 @@ final class WorkerExecutor {
         // GENERATE LOCAL TRAVERSERS //
         ///////////////////////////////
 
+        // MASTER ACTIVE
         // these are traversers that are going from OLTP (master) to OLAP (workers)
         // these traversers were broadcasted from the master traversal to the workers for attachment
         final TraverserSet<Object> maybeActiveTraversers = memory.get(TraversalVertexProgram.ACTIVE_TRAVERSERS);
@@ -75,17 +77,21 @@ final class WorkerExecutor {
         // its better to reduce the memory footprint and shorten the active traverser list so synchronization is worth it.
         // most distributed OLAP systems have the memory partitioned and thus, this synchronization does nothing.
         synchronized (maybeActiveTraversers) {
-            final Iterator<Traverser.Admin<Object>> iterator = maybeActiveTraversers.iterator();
-            while (iterator.hasNext()) {
-                final Traverser.Admin<Object> traverser = iterator.next();
-                if (vertex.equals(WorkerExecutor.getHostingVertex(traverser.get()))) {
-                    iterator.remove();
-                    traverser.attach(Attachable.Method.get(vertex));
-                    traverser.setSideEffects(traversalSideEffects);
-                    toProcessTraversers.add(traverser);
+            if (!maybeActiveTraversers.isEmpty()) {
+                final Iterator<Traverser.Admin<Object>> iterator = maybeActiveTraversers.iterator();
+                while (iterator.hasNext()) {
+                    final Traverser.Admin<Object> traverser = iterator.next();
+                    if (vertex.equals(WorkerExecutor.getHostingVertex(traverser.get()))) {
+                        iterator.remove();
+                        traverser.attach(Attachable.Method.get(vertex));
+                        traverser.setSideEffects(traversalSideEffects);
+                        toProcessTraversers.add(traverser);
+                    }
                 }
             }
         }
+
+        // WORKER ACTIVE
         // these are traversers that exist from from a local barrier
         // these traversers will simply saved at the local vertex while the master traversal synchronized the barrier
         vertex.<TraverserSet<Object>>property(TraversalVertexProgram.ACTIVE_TRAVERSERS).ifPresent(previousActiveTraversers -> {
@@ -98,17 +104,20 @@ final class WorkerExecutor {
             // remove the property to save space
             vertex.property(TraversalVertexProgram.ACTIVE_TRAVERSERS).remove();
         });
+
+        // TRAVERSER MESSAGES (WORKER -> WORKER)
         // these are traversers that have been messaged to the vertex from another vertex
         final Iterator<TraverserSet<Object>> messages = messenger.receiveMessages();
         while (messages.hasNext()) {
             IteratorUtils.removeOnNext(messages.next().iterator()).forEachRemaining(traverser -> {
                 if (traverser.isHalted()) {
                     if (returnHaltedTraversers)
-                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
+                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(haltedTraverserStrategy.halt(traverser)));
                     else
-                        haltedTraversers.add(traverser.detach());
+                        haltedTraversers.add(traverser); // the traverser has already been detached so no need to detach it again
                 } else {
                     // traverser is not halted and thus, should be processed locally
+                    // attach it and process
                     traverser.attach(Attachable.Method.get(vertex));
                     traverser.setSideEffects(traversalSideEffects);
                     toProcessTraversers.add(traverser);
@@ -120,7 +129,7 @@ final class WorkerExecutor {
         // PROCESS LOCAL TRAVERSERS //
         //////////////////////////////
 
-        // while there are still local traversers, process them until they leave the vertex or halt (i.e. isHalted()).
+        // while there are still local traversers, process them until they leave the vertex (message pass) or halt (store).
         while (!toProcessTraversers.isEmpty()) {
             Step<Object, Object> previousStep = EmptyStep.instance();
             Iterator<Traverser.Admin<Object>> traversers = toProcessTraversers.iterator();
@@ -130,11 +139,11 @@ final class WorkerExecutor {
                 final Step<Object, Object> currentStep = traversalMatrix.getStepById(traverser.getStepId());
                 // try and fill up the current step as much as possible with traversers to get a bulking optimization
                 if (!currentStep.getId().equals(previousStep.getId()) && !(previousStep instanceof EmptyStep))
-                    WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserFactory);
+                    WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserStrategy);
                 currentStep.addStart(traverser);
                 previousStep = currentStep;
             }
-            WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserFactory);
+            WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserStrategy);
             // all processed traversers should be either halted or active
             assert toProcessTraversers.isEmpty();
             // process all the local objects and send messages or store locally again
@@ -151,7 +160,7 @@ final class WorkerExecutor {
                             voteToHalt.set(false); // if message is passed, then don't vote to halt
                             messenger.sendMessage(MessageScope.Global.of(hostingVertex), new TraverserSet<>(traverser.detach()));
                         } else {
-                            traverser.attach(Attachable.Method.get(vertex));
+                            traverser.attach(Attachable.Method.get(vertex)); // necessary for select() steps that reference the current object
                             toProcessTraversers.add(traverser);
                         }
                     } else                                                                              // STANDARD OBJECT
@@ -169,7 +178,7 @@ final class WorkerExecutor {
                                   final TraverserSet<Object> haltedTraversers,
                                   final Memory memory,
                                   final boolean returnHaltedTraversers,
-                                  final Class haltedTraverserFactory) {
+                                  final HaltedTraverserStrategy haltedTraverserStrategy) {
         if (step instanceof Barrier) {
             if (step instanceof Bypassing)
                 ((Bypassing) step).setBypass(true);
@@ -187,7 +196,7 @@ final class WorkerExecutor {
                                         (!(traverser.get() instanceof Element) && !(traverser.get() instanceof Property)) ||
                                         getHostingVertex(traverser.get()).equals(vertex))) {
                             if (returnHaltedTraversers)
-                                memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
+                                memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(haltedTraverserStrategy.halt(traverser)));
                             else
                                 haltedTraversers.add(traverser.detach());
                         } else
@@ -205,12 +214,12 @@ final class WorkerExecutor {
         } else { // LOCAL PROCESSING
             step.forEachRemaining(traverser -> {
                 if (traverser.isHalted() &&
-                        // if its a ReferenceFactory (one less iteration)
-                        ((returnHaltedTraversers || ReferenceFactory.class == haltedTraverserFactory) &&
+                        // if its a ReferenceFactory (one less iteration required)
+                        ((returnHaltedTraversers || ReferenceFactory.class == haltedTraverserStrategy.getHaltedTraverserFactory()) &&
                                 (!(traverser.get() instanceof Element) && !(traverser.get() instanceof Property)) ||
                                 getHostingVertex(traverser.get()).equals(vertex))) {
                     if (returnHaltedTraversers)
-                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
+                        memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(haltedTraverserStrategy.halt(traverser)));
                     else
                         haltedTraversers.add(traverser.detach());
                 } else {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/56c43ea7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
index fd07e23..968e167 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserStrategy.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decorat
 
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
@@ -33,7 +34,10 @@ public final class HaltedTraverserStrategy extends AbstractTraversalStrategy<Tra
     private final Class haltedTraverserFactory;
 
     private HaltedTraverserStrategy(final Class haltedTraverserFactory) {
-        this.haltedTraverserFactory = haltedTraverserFactory;
+        if (haltedTraverserFactory.equals(DetachedFactory.class) || haltedTraverserFactory.equals(ReferenceFactory.class))
+            this.haltedTraverserFactory = haltedTraverserFactory;
+        else
+            throw new IllegalArgumentException("The provided traverser detachment factory is unknown: " + haltedTraverserFactory);
     }
 
     public void apply(final Traversal.Admin<?, ?> traversal) {
@@ -44,6 +48,16 @@ public final class HaltedTraverserStrategy extends AbstractTraversalStrategy<Tra
         return this.haltedTraverserFactory;
     }
 
+    public <R> Traverser.Admin<R> halt(final Traverser.Admin<R> traverser) {
+        if (ReferenceFactory.class.equals(this.haltedTraverserFactory))
+            traverser.set(ReferenceFactory.detach(traverser.get()));
+        else
+            traverser.set(DetachedFactory.detach(traverser.get(), true));
+        return traverser;
+    }
+
+    ////////////
+
     public static HaltedTraverserStrategy detached() {
         return new HaltedTraverserStrategy(DetachedFactory.class);
     }
@@ -51,4 +65,5 @@ public final class HaltedTraverserStrategy extends AbstractTraversalStrategy<Tra
     public static HaltedTraverserStrategy reference() {
         return new HaltedTraverserStrategy(ReferenceFactory.class);
     }
+
 }


[13/49] incubator-tinkerpop git commit: lots of documentation on TraversalVertexProgram and got HaltedTraveserFactoryStrategy tested and optimized.

Posted by dk...@apache.org.
lots of documentation on TraversalVertexProgram and got HaltedTraveserFactoryStrategy tested and optimized.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 3978e7bda5f4896ea1c2815c889e206afcbaccaa
Parents: 19f16f1
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 12:25:31 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 12:25:31 2016 -0600

----------------------------------------------------------------------
 .../computer/traversal/MasterExecutor.java      |  6 +-
 .../computer/traversal/WorkerExecutor.java      | 56 +++++++-----
 .../HaltedTraverserFactoryStrategy.java         | 13 ++-
 .../HaltedTraverserFactoryStrategyTest.java     | 91 ++++++++++++++++++++
 4 files changed, 140 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3978e7bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
index b5ec12b..b994f1e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/MasterExecutor.java
@@ -58,6 +58,8 @@ final class MasterExecutor {
 
     }
 
+    // the halted traversers can either be reference or detached elements -- this is good for determining how much data around the element the user wants to get
+    // see HaltedTraverserFactoryStrategy for how this is all connected
     protected static <R> Traverser.Admin<R> detach(final Traverser.Admin<R> traverser, final Class haltedTraverserFactory) {
         if (haltedTraverserFactory.equals(DetachedFactory.class))
             traverser.set(DetachedFactory.detach(traverser.get(), true));
@@ -68,11 +70,12 @@ final class MasterExecutor {
         return traverser;
     }
 
+    // handle traversers and data that were sent from the workers to the master traversal via memory
     protected static void processMemory(final TraversalMatrix<?, ?> traversalMatrix, final Memory memory, final TraverserSet<Object> traverserSet, final Set<String> completedBarriers) {
         if (memory.exists(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
             for (final String key : memory.<Set<String>>get(TraversalVertexProgram.MUTATED_MEMORY_KEYS)) {
                 final Step<Object, Object> step = traversalMatrix.getStepById(key);
-                if (null == step) continue;
+                if (null == step) continue; // why? how can this happen?
                 assert step instanceof Barrier;
                 completedBarriers.add(step.getId());
                 if (!(step instanceof LocalBarrier)) {  // local barriers don't do any processing on the master traversal (they just lock on the workers)
@@ -81,6 +84,7 @@ final class MasterExecutor {
                     while (step.hasNext()) {
                         traverserSet.add(step.next());
                     }
+                    // if it was a reducing barrier step, reset the barrier to its seed value
                     if (step instanceof ReducingBarrierStep)
                         memory.set(step.getId(), ((ReducingBarrierStep) step).getSeedSupplier().get());
                 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3978e7bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
index 5bc3da9..f833b6f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/WorkerExecutor.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.process.computer.traversal;
 import org.apache.tinkerpop.gremlin.process.computer.Memory;
 import org.apache.tinkerpop.gremlin.process.computer.MessageScope;
 import org.apache.tinkerpop.gremlin.process.computer.Messenger;
+import org.apache.tinkerpop.gremlin.process.computer.util.SingleMessenger;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
@@ -35,6 +36,7 @@ import org.apache.tinkerpop.gremlin.structure.Element;
 import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceElement;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
@@ -58,30 +60,37 @@ final class WorkerExecutor {
                                      final Memory memory,
                                      final boolean returnHaltedTraversers,
                                      final Class haltedTraverserFactory) {
-
         final TraversalSideEffects traversalSideEffects = traversalMatrix.getTraversal().getSideEffects();
         final AtomicBoolean voteToHalt = new AtomicBoolean(true);
         final TraverserSet<Object> haltedTraversers = vertex.value(TraversalVertexProgram.HALTED_TRAVERSERS);
         final TraverserSet<Object> activeTraversers = new TraverserSet<>();
         final TraverserSet<Object> toProcessTraversers = new TraverserSet<>();
+        final boolean isTesting = Boolean.valueOf(System.getProperty("is.testing", "false"));
 
         ////////////////////////////////
         // GENERATE LOCAL TRAVERSERS //
         ///////////////////////////////
 
-        // these are traversers that are going from OLTP to OLAP
-        final TraverserSet<Object> maybeActiveTraversers = memory.get(TraversalVertexProgram.ACTIVE_TRAVERSERS);
-        final Iterator<Traverser.Admin<Object>> iterator = maybeActiveTraversers.iterator();
-        while (iterator.hasNext()) {
-            final Traverser.Admin<Object> traverser = iterator.next();
-            if (vertex.equals(WorkerExecutor.getHostingVertex(traverser.get()))) {
-                // iterator.remove(); ConcurrentModificationException
-                traverser.attach(Attachable.Method.get(vertex));
-                traverser.setSideEffects(traversalSideEffects);
-                toProcessTraversers.add(traverser);
+        // some memory systems are interacted by multiple threads and thus, concurrent modification can happen at iterator.remove()
+        // its better to reduce the memory footprint and shorten the active traverser list so synchronization is worth it.
+        // most distributed OLAP systems have the memory partitioned and thus, this synchronization does nothing
+        synchronized (memory) {
+            // these are traversers that are going from OLTP to OLAP
+            // these traversers were broadcasted from the master traversal to the workers for attachment
+            final TraverserSet<Object> maybeActiveTraversers = memory.get(TraversalVertexProgram.ACTIVE_TRAVERSERS);
+            final Iterator<Traverser.Admin<Object>> iterator = maybeActiveTraversers.iterator();
+            while (iterator.hasNext()) {
+                final Traverser.Admin<Object> traverser = iterator.next();
+                if (vertex.equals(WorkerExecutor.getHostingVertex(traverser.get()))) {
+                    iterator.remove();
+                    traverser.attach(Attachable.Method.get(vertex));
+                    traverser.setSideEffects(traversalSideEffects);
+                    toProcessTraversers.add(traverser);
+                }
             }
         }
         // these are traversers that exist from from a local barrier
+        // these traversers will simply saved at the local vertex while the master traversal synchronized the barrier
         vertex.<TraverserSet<Object>>property(TraversalVertexProgram.ACTIVE_TRAVERSERS).ifPresent(previousActiveTraversers -> {
             IteratorUtils.removeOnNext(previousActiveTraversers.iterator()).forEachRemaining(traverser -> {
                 traverser.attach(Attachable.Method.get(vertex));
@@ -90,24 +99,25 @@ final class WorkerExecutor {
             });
             vertex.property(TraversalVertexProgram.ACTIVE_TRAVERSERS).remove();
         });
-        // these are traversers that have been messaged to the vertex
+        // these are traversers that have been messaged to the vertex from another vertex
         final Iterator<TraverserSet<Object>> messages = messenger.receiveMessages();
         while (messages.hasNext()) {
-            final Iterator<Traverser.Admin<Object>> traversers = messages.next().iterator();
-            while (traversers.hasNext()) {
-                final Traverser.Admin<Object> traverser = traversers.next();
-                traversers.remove();
+            IteratorUtils.removeOnNext(messages.next().iterator()).forEachRemaining(traverser -> {
+                // this is internal testing to ensure that messaged elements are always ReferenceXXX and not DetachedXXX (related to HaltedTraverserFactoryStrategy)
+                if (isTesting && !(messenger instanceof SingleMessenger) && traverser.get() instanceof Element)
+                    assert traverser.get() instanceof ReferenceElement;
                 if (traverser.isHalted()) {
                     if (returnHaltedTraversers)
                         memory.add(TraversalVertexProgram.HALTED_TRAVERSERS, new TraverserSet<>(MasterExecutor.detach(traverser, haltedTraverserFactory)));
                     else
                         haltedTraversers.add(traverser);
                 } else {
+                    // traverser is not halted and thus, should be processed locally
                     traverser.attach(Attachable.Method.get(vertex));
                     traverser.setSideEffects(traversalSideEffects);
                     toProcessTraversers.add(traverser);
                 }
-            }
+            });
         }
 
         ///////////////////////////////
@@ -116,7 +126,6 @@ final class WorkerExecutor {
 
         // while there are still local traversers, process them until they leave the vertex or halt (i.e. isHalted()).
         while (!toProcessTraversers.isEmpty()) {
-            // process local traversers and if alive, repeat, else halt.
             Step<Object, Object> previousStep = EmptyStep.instance();
             Iterator<Traverser.Admin<Object>> traversers = toProcessTraversers.iterator();
             while (traversers.hasNext()) {
@@ -129,6 +138,7 @@ final class WorkerExecutor {
                 previousStep = currentStep;
             }
             WorkerExecutor.drainStep(vertex, previousStep, activeTraversers, haltedTraversers, memory, returnHaltedTraversers, haltedTraverserFactory);
+            // all processed traversers should be either halted or active
             assert toProcessTraversers.isEmpty();
             // process all the local objects and send messages or store locally again
             if (!activeTraversers.isEmpty()) {
@@ -136,6 +146,7 @@ final class WorkerExecutor {
                 while (traversers.hasNext()) {
                     final Traverser.Admin<Object> traverser = traversers.next();
                     traversers.remove();
+                    // decide whether to message the traverser or to process it locally
                     if (traverser.get() instanceof Element || traverser.get() instanceof Property) {      // GRAPH OBJECT
                         // if the element is remote, then message, else store it locally for re-processing
                         final Vertex hostingVertex = WorkerExecutor.getHostingVertex(traverser.get());
@@ -167,9 +178,10 @@ final class WorkerExecutor {
             if (step instanceof Bypassing)
                 ((Bypassing) step).setBypass(true);
             if (step instanceof LocalBarrier) {
+                // local barrier traversers are stored on the vertex until the master traversal synchronizes the system
                 final LocalBarrier<Object> barrier = (LocalBarrier<Object>) step;
-                final TraverserSet<Object> traverserSet = vertex.<TraverserSet<Object>>property(TraversalVertexProgram.ACTIVE_TRAVERSERS).orElse(new TraverserSet<>());
-                vertex.property(TraversalVertexProgram.ACTIVE_TRAVERSERS, traverserSet);
+                final TraverserSet<Object> localBarrierTraversers = vertex.<TraverserSet<Object>>property(TraversalVertexProgram.ACTIVE_TRAVERSERS).orElse(new TraverserSet<>());
+                vertex.property(TraversalVertexProgram.ACTIVE_TRAVERSERS, localBarrierTraversers);
                 while (barrier.hasNextBarrier()) {
                     final TraverserSet<Object> barrierSet = barrier.nextBarrier();
                     IteratorUtils.removeOnNext(barrierSet.iterator()).forEachRemaining(traverser -> {
@@ -183,7 +195,7 @@ final class WorkerExecutor {
                             else
                                 haltedTraversers.add(traverser.detach());
                         } else
-                            traverserSet.add(traverser.detach());
+                            localBarrierTraversers.add(traverser);
                     });
                 }
                 memory.add(TraversalVertexProgram.MUTATED_MEMORY_KEYS, new HashSet<>(Collections.singleton(step.getId())));
@@ -198,7 +210,7 @@ final class WorkerExecutor {
             step.forEachRemaining(traverser -> {
                 if (traverser.isHalted() &&
                         // if its a ReferenceFactory (one less iteration)
-                        ((returnHaltedTraversers || haltedTraverserFactory == ReferenceFactory.class) &&
+                        ((returnHaltedTraversers || ReferenceFactory.class == haltedTraverserFactory) &&
                                 (!(traverser.get() instanceof Element) && !(traverser.get() instanceof Property)) ||
                                 getHostingVertex(traverser.get()).equals(vertex))) {
                     if (returnHaltedTraversers)

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3978e7bd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
index b046986..c2f3855 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategy.java
@@ -22,12 +22,14 @@ package org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decorat
 import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
 import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceFactory;
 
 import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -42,11 +44,16 @@ public final class HaltedTraverserFactoryStrategy extends AbstractTraversalStrat
     }
 
     public void apply(final Traversal.Admin<?, ?> traversal) {
-        TraversalHelper.getStepsOfAssignableClass(TraversalVertexProgramStep.class, traversal)
-                .forEach(step -> step.setHaltedTraverserFactory(this.haltedTraverserFactory));
+        // only the root traversal should be processed
+        if (traversal.getParent() instanceof EmptyStep) {
+            final List<TraversalVertexProgramStep> steps = TraversalHelper.getStepsOfAssignableClass(TraversalVertexProgramStep.class, traversal);
+            // only the last step (the one returning data) needs to have a non-reference traverser factory
+            if (!steps.isEmpty())
+                steps.get(steps.size() - 1).setHaltedTraverserFactory(this.haltedTraverserFactory);
+        }
     }
 
-    public static HaltedTraverserFactoryStrategy detach() {
+    public static HaltedTraverserFactoryStrategy detached() {
         return new HaltedTraverserFactoryStrategy(DetachedFactory.class);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/3978e7bd/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
new file mode 100644
index 0000000..af0b3b7
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/traversal/strategy/decoration/HaltedTraverserFactoryStrategyTest.java
@@ -0,0 +1,91 @@
+/*
+ * 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.tinkergraph.process.computer.traversal.strategy.decoration;
+
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.HaltedTraverserFactoryStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedProperty;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceEdge;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceProperty;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex;
+import org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertexProperty;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class HaltedTraverserFactoryStrategyTest {
+
+    @Before
+    public void setup() {
+        // necessary as ComputerResult step for testing purposes attaches Attachables
+        System.setProperty("is.testing", "false");
+    }
+
+    @After
+    public void shutdown() {
+        System.setProperty("is.testing", "true");
+    }
+
+    @Test
+    public void shouldReturnDetachedElements() {
+        Graph graph = TinkerFactory.createModern();
+        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserFactoryStrategy.detached());
+        g.V().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(DetachedVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(DetachedEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(DetachedProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(DetachedVertex.class, vertex.getClass()));
+    }
+
+    @Test
+    public void shouldReturnReferenceElements() {
+        Graph graph = TinkerFactory.createModern();
+        GraphTraversalSource g = graph.traversal().withComputer().withStrategies(HaltedTraverserFactoryStrategy.reference());
+        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        //
+        g = graph.traversal().withComputer();
+        g.V().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+        g.V().out().properties("name").forEachRemaining(vertexProperty -> assertEquals(ReferenceVertexProperty.class, vertexProperty.getClass()));
+        g.V().out().values("name").forEachRemaining(value -> assertEquals(String.class, value.getClass()));
+        g.V().out().outE().forEachRemaining(edge -> assertEquals(ReferenceEdge.class, edge.getClass()));
+        g.V().out().outE().properties("weight").forEachRemaining(property -> assertEquals(ReferenceProperty.class, property.getClass()));
+        g.V().out().outE().values("weight").forEachRemaining(value -> assertEquals(Double.class, value.getClass()));
+        g.V().out().out().forEachRemaining(vertex -> assertEquals(ReferenceVertex.class, vertex.getClass()));
+    }
+
+}


[12/49] incubator-tinkerpop git commit: updated CHANGELOG.

Posted by dk...@apache.org.
updated CHANGELOG.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 6113c9283661b253356fafc753b2d8b30d9555a5
Parents: 4318b6c
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 08:47:42 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 08:47:42 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6113c928/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 4ba3c80..171b772 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.2.1 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Fixed a `NullPointerException` bug around nested `group()`-steps in OLAP.
 * Fixed a severe bug around halted traversers in a multi-job OLAP traversal chain.
 * Ensure a separation of `GraphComputer` and `VertexProgram` configurations in `SparkGraphComputer` and `GiraphGraphComputer`.
 * `PeerPressureVertexProgram` now supports dynamic initial vote strength calculations.


[44/49] incubator-tinkerpop git commit: Improved error detection in docs preprocessor.

Posted by dk...@apache.org.
Improved error detection in docs preprocessor.

This closes #1314


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

Branch: refs/heads/TINKERPOP-1298
Commit: 96ee0ba780ed06ff54b29814c96b59fcbba575e8
Parents: 7a1fd4b
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Sun May 29 10:07:16 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Sun May 29 10:07:16 2016 +0200

----------------------------------------------------------------------
 bin/process-docs.sh                  |  2 +-
 docs/preprocessor/awk/prepare.awk    |  4 +++
 docs/preprocessor/preprocess-file.sh |  3 ++-
 docs/preprocessor/preprocess.sh      | 44 +++++++++++++------------------
 4 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/96ee0ba7/bin/process-docs.sh
----------------------------------------------------------------------
diff --git a/bin/process-docs.sh b/bin/process-docs.sh
index eb779a9..7236faa 100755
--- a/bin/process-docs.sh
+++ b/bin/process-docs.sh
@@ -103,7 +103,7 @@ else
   ec=$?
 fi
 
-if [ $ec == 0 ]; then
+if [ $ec -eq 0 ]; then
   mvn process-resources -Dasciidoc && docs/postprocessor/postprocess.sh
   ec=$?
 fi

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/96ee0ba7/docs/preprocessor/awk/prepare.awk
----------------------------------------------------------------------
diff --git a/docs/preprocessor/awk/prepare.awk b/docs/preprocessor/awk/prepare.awk
index b9ee682..46960be 100644
--- a/docs/preprocessor/awk/prepare.awk
+++ b/docs/preprocessor/awk/prepare.awk
@@ -67,3 +67,7 @@ function remove_callouts(code) {
 /^\[gremlin-/ {
   inCodeSection = 1
 }
+
+END {
+  print_string("// LAST LINE")
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/96ee0ba7/docs/preprocessor/preprocess-file.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/preprocess-file.sh b/docs/preprocessor/preprocess-file.sh
index 78622d6..35b1f15 100755
--- a/docs/preprocessor/preprocess-file.sh
+++ b/docs/preprocessor/preprocess-file.sh
@@ -132,7 +132,8 @@ if [ ! ${SKIP} ] && [ $(grep -c '^\[gremlin' ${input}) -gt 0 ]; then
   fi
 
   if [ ${ec} -eq 0 ]; then
-    ec=`grep -c '\bpb([0-9][0-9]*);' ${output}`
+    tail -n1 ${output} | grep -F '// LAST LINE' > /dev/null
+    ec=$?
   fi
 
   if [ ${ec} -eq 0 ]; then

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/96ee0ba7/docs/preprocessor/preprocess.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/preprocess.sh b/docs/preprocessor/preprocess.sh
index 740808c..d225c48 100755
--- a/docs/preprocessor/preprocess.sh
+++ b/docs/preprocessor/preprocess.sh
@@ -128,33 +128,27 @@ echo "+   Processing AsciiDocs   +"
 echo "============================"
 
 ec=0
-process_subdirs=1
-find "${TP_HOME}/docs/src/" -name index.asciidoc | xargs -n1 dirname | while read subdir ; do
-  if [ ${process_subdirs} -eq 1 ]; then
-    find "${subdir}" -name "*.asciidoc" |
-         xargs -n1 basename |
-         xargs -n1 -I {} echo "echo -ne {}' '; (grep -n {} ${subdir}/index.asciidoc || echo 0) | head -n1 | cut -d ':' -f1" | /bin/bash | sort -nk2 | cut -d ' ' -f1 |
-         xargs -n1 -I {} echo "${subdir}/{}" |
-         xargs -n1 ${TP_HOME}/docs/preprocessor/preprocess-file.sh "${CONSOLE_HOME}" "${DRYRUN_DOCS}" "${FULLRUN_DOCS}"
-
-    ps=(${PIPESTATUS[@]})
-    for i in {0..7}; do
-      ec=${ps[i]}
-      [ ${ec} -eq 0 ] || break
-    done
-
-    if [ ${ec} -ne 0 ]; then
-      process_subdirs=0
-    fi
-  fi
+for subdir in $(find "${TP_HOME}/docs/src/" -name index.asciidoc | xargs -n1 dirname)
+do
+  find "${subdir}" -name "*.asciidoc" |
+       xargs -n1 basename |
+       xargs -n1 -I {} echo "echo -ne {}' '; (grep -n {} ${subdir}/index.asciidoc || echo 0) | head -n1 | cut -d ':' -f1" | /bin/bash | sort -nk2 | cut -d ' ' -f1 |
+       xargs -n1 -I {} echo "${subdir}/{}" |
+       xargs -n1 ${TP_HOME}/docs/preprocessor/preprocess-file.sh "${CONSOLE_HOME}" "${DRYRUN_DOCS}" "${FULLRUN_DOCS}"
+
+  ps=(${PIPESTATUS[@]})
+  for i in {0..7}; do
+    ec=${ps[i]}
+    [ ${ec} -eq 0 ] || break
+  done
+  [ ${ec} -eq 0 ] || break
 done
 
 tput smam
 [[ "${COLUMNS}" != "" ]] && stty cols ${COLS}
 
-if [ ${ec} -ne 0 ]; then
-  exit 1
-else
-  rm -rf /tmp/neo4j /tmp/tinkergraph.kryo
-  echo
-fi
+rm -rf /tmp/neo4j /tmp/tinkergraph.kryo
+
+[ ${ec} -eq 0 ] || exit 1
+
+echo


[08/49] incubator-tinkerpop git commit: This closes #195

Posted by dk...@apache.org.
This closes #195


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

Branch: refs/heads/TINKERPOP-1298
Commit: afd40488fb50d4a9e92419e63bcbd73187eb2912
Parents: 366edb3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue May 24 17:07:43 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue May 24 17:07:43 2016 -0400

----------------------------------------------------------------------

----------------------------------------------------------------------



[14/49] incubator-tinkerpop git commit: Merge branch 'master' into TINKERPOP-1310

Posted by dk...@apache.org.
Merge branch 'master' into TINKERPOP-1310


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

Branch: refs/heads/TINKERPOP-1298
Commit: 7255844c03fc1b6d447a2631250100758c4f84cb
Parents: 3978e7b 6113c92
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed May 25 12:25:51 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed May 25 12:25:51 2016 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../process/traversal/step/map/GroupStep.java   | 307 ++++++++++++-------
 .../step/sideEffect/GroupSideEffectStep.java    |  61 ++--
 .../step/sideEffect/GroovyGroupTest.groovy      |  10 +
 .../traversal/step/sideEffect/GroupTest.java    |  77 +++++
 .../gremlin/hadoop/structure/HadoopGraph.java   | 124 ++++++--
 .../SparkStarBarrierInterceptor.java            |   1 -
 .../structure/TinkerGraphPlayTest.java          |   4 +-
 8 files changed, 390 insertions(+), 195 deletions(-)
----------------------------------------------------------------------



[49/49] incubator-tinkerpop git commit: Documented `BulkExportVertexProgram` and added an integration test.

Posted by dk...@apache.org.
Documented `BulkExportVertexProgram` and added an integration test.


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

Branch: refs/heads/TINKERPOP-1298
Commit: 741ca40269203ee4bf7f53f960575415f4b8a121
Parents: d3292fb
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Tue May 31 14:46:01 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Tue May 31 14:47:26 2016 +0200

----------------------------------------------------------------------
 .../reference/implementations-hadoop.asciidoc   | 40 ++++++++
 docs/src/reference/the-graphcomputer.asciidoc   | 13 +++
 .../gremlin/process/ProcessComputerSuite.java   |  4 +-
 .../BulkExportVertexProgramTest.java            | 99 ++++++++++++++++++++
 .../io/script/script-csv-export.groovy          | 36 +++++++
 .../gremlin/hadoop/HadoopGraphProvider.java     |  1 +
 6 files changed, 192 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/741ca402/docs/src/reference/implementations-hadoop.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/implementations-hadoop.asciidoc b/docs/src/reference/implementations-hadoop.asciidoc
index 9e388ea..3c756a7 100644
--- a/docs/src/reference/implementations-hadoop.asciidoc
+++ b/docs/src/reference/implementations-hadoop.asciidoc
@@ -379,6 +379,46 @@ hdfs.ls('output')
 hdfs.head('output/~g')
 ----
 
+[[bulkexportvertexprogramusingspark]]
+Exporting CSV-formatted data with BulkExportVertexProgram
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+The <<bulkexportvertexprogram, BulkExportVertexProgram>> exports a chunk of preselected data using the `ScriptOutputFormat`. The example below takes a Hadoop
+graph as the input (in `GryoInputFormat`), selects multiple values (a person's name and age, the number of projects created by this person and the number of
+coworkers) from the modern sample graph  and writes them out in CSV format.
+
+[gremlin-groovy]
+----
+hdfs.copyFromLocal('data/tinkerpop-modern.kryo', 'tinkerpop-modern.kryo')
+hdfs.copyFromLocal('data/script-csv-export.groovy', 'script-csv-export.groovy')
+
+graph = GraphFactory.open("conf/hadoop/hadoop-gryo.properties")
+g = graph.traversal().withComputer()
+
+g.V().hasLabel('person').match(
+    __.as('person').values('name').as('name'),
+    __.as('person').values('age').as('age'),
+    __.as('person').outE('created').count().as('projects')
+  ).select('person').
+    coalesce(out('created'), identity()).
+    coalesce(__.in('created'), identity()).
+    groupCount('m').by(select('person','name','age','projects')).cap('m').unfold().as('kv').
+    select(keys).select('person').as('person').
+    select('kv').select(keys).select('name').as('name').
+    select('kv').select(keys).select('age').as('age').
+    select('kv').select(keys).select('projects').as('projects').
+    select('kv').select(values).map(union(identity(), constant(-1)).sum()).as('coworkers').
+    select('person','name','age','projects','coworkers').
+    program(BulkDumperVertexProgram.build().create(graph))
+
+hdfs.head('output/~g', GryoInputFormat)
+hdfs.head('output/~g', GryoInputFormat).each {println it.property(BulkExportVertexProgram.BULK_EXPORT_PROPERTIES)}
+
+graph = GraphFactory.open('conf/hadoop/hadoop-csv-export.properties')
+graph.compute().program(BulkExportVertexProgram.build().keys('name','age','projects','coworkers').create(graph)).submit().get()
+println String.join('\n', hdfs.head('export/~g').toList()); []
+----
+
 Loading with BulkLoaderVertexProgram
 ++++++++++++++++++++++++++++++++++++
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/741ca402/docs/src/reference/the-graphcomputer.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/the-graphcomputer.asciidoc b/docs/src/reference/the-graphcomputer.asciidoc
index 25ae39e..32f0d86 100644
--- a/docs/src/reference/the-graphcomputer.asciidoc
+++ b/docs/src/reference/the-graphcomputer.asciidoc
@@ -381,6 +381,19 @@ The `BulkDumperVertexProgram` can be used to export a whole graph in any of the
 (e.g. `GraphSONInputFormat`, `GryoInputFormat` or `ScriptInputFormat`). An <<bulkdumpervertexprogramusingspark,example>>
 is provided in the SparkGraphComputer section.
 
+[[bulkexportvertexprogram]]
+BulkExportVertexProgram
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The `BulkExportVertexProgram` is similar to the <<bulkdumpervertexprogram,`BulkDumperVertexProgram`>>, but it strongly relies
+on `ScriptOutputFormat` to allow clear-text exports (e.g. CSV) of preselected data. It takes a list of keys / labeled steps and
+optionally a formatter for each key, which it then uses to collect the data. Finally a Groovy script is used to write out the
+tabular data. The script can access the vertex property `BulkExportVertexProgram.BULK_EXPORT_PROPERTIES`, which can hold multiple
+rows and columns of values to be exported.
+
+TinkerPop comes with a sample configuration and Groovy script file that show how `BulkExportVertexProgram` can be used to generate
+CSV file exports. An <<bulkexportvertexprogramusingspark,example>> is provided in the SparkGraphComputer section.
+
 [[bulkloadervertexprogram]]
 BulkLoaderVertexProgram
 ~~~~~~~~~~~~~~~~~~~~~~~

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/741ca402/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
index d8021eb..04d3373 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/ProcessComputerSuite.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputerTest;
 import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkDumperVertexProgramTest;
+import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkExportVertexProgramTest;
 import org.apache.tinkerpop.gremlin.process.computer.bulkloading.BulkLoaderVertexProgramTest;
 import org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.PeerPressureVertexProgramTest;
 import org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgramTest;
@@ -29,8 +30,8 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseTest;
-import org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.AndTest;
@@ -191,6 +192,7 @@ public class ProcessComputerSuite extends AbstractGremlinSuite {
             PeerPressureVertexProgramTest.class,
             BulkLoaderVertexProgramTest.class,
             BulkDumperVertexProgramTest.class,
+            BulkExportVertexProgramTest.class,
 
             // decorations
             ReadOnlyStrategyProcessTest.class,

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/741ca402/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgramTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgramTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgramTest.java
new file mode 100644
index 0000000..6a45d2d
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkdumping/BulkExportVertexProgramTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.computer.bulkdumping;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
+import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.io.script.ScriptResourceAccess;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
+import static org.apache.tinkerpop.gremlin.structure.Column.keys;
+import static org.apache.tinkerpop.gremlin.structure.Column.values;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Daniel Kuppitz (http://gremlin.guru)
+ */
+public class BulkExportVertexProgramTest extends AbstractGremlinProcessTest {
+
+    @Test
+    @LoadGraphWith(MODERN)
+    public void shouldExportCsvFile() throws Exception {
+        if (graphProvider.getGraphComputer(graph).features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.EDGES)) {
+            g.V().hasLabel("person").match(
+                    __.as("person").values("name").as("name"),
+                    __.as("person").values("age").as("age"),
+                    __.as("person").outE("created").count().as("projects")
+            ).select("person").
+                    coalesce(__.out("created"), __.identity()).
+                    coalesce(__.in("created"), __.identity()).
+                    groupCount("m").by(__.select("person", "name", "age", "projects")).cap("m").unfold().as("kv").
+                    select(keys).select("person").as("person").
+                    select("kv").select(keys).select("name").as("name").
+                    select("kv").select(keys).select("age").as("age").
+                    select("kv").select(keys).select("projects").as("projects").
+                    select("kv").select(values).map(__.union(__.identity(), __.constant(-1)).sum()).as("coworkers").
+                    select("person", "name", "age", "projects", "coworkers").
+                    program(BulkDumperVertexProgram.build().create(graph)).iterate();
+
+            final Configuration config = graph.configuration();
+            final String outputLocation = config.getString("gremlin.hadoop.outputLocation");
+            final String scriptFileName =
+                    TestHelper.generateTempFileFromResource(ScriptResourceAccess.class, "script-csv-export.groovy", "").
+                            getAbsolutePath().replace('\\', '/');
+
+            config.setProperty("gremlin.hadoop.inputLocation", outputLocation + "/~g");
+            config.setProperty("gremlin.hadoop.outputLocation", outputLocation + "-csv");
+            config.setProperty("gremlin.hadoop.graphReader", "org.apache.tinkerpop.gremlin.hadoop.structure.io.gryo.GryoInputFormat");
+            config.setProperty("gremlin.hadoop.graphWriter", "org.apache.tinkerpop.gremlin.hadoop.structure.io.script.ScriptOutputFormat");
+            config.setProperty("gremlin.hadoop.scriptOutputFormat.script", scriptFileName);
+
+            graph.compute().program(BulkExportVertexProgram.build().keys("name", "age", "projects", "coworkers").create(graph)).submit().get();
+
+            final Set<String> lines = new HashSet<>();
+            lines.add("josh,32,2,3");
+            lines.add("marko,29,1,2");
+            lines.add("peter,35,1,2");
+            lines.add("vadas,27,0,0");
+
+            final File output = new File(outputLocation + "-csv/~g");
+            for (final File f : output.listFiles()) {
+                if (f.getName().startsWith("part-")) {
+                    try (final BufferedReader reader = new BufferedReader(new FileReader(f))) {
+                        reader.lines().forEach(line -> assertTrue(lines.remove(line)));
+                    }
+                }
+            }
+
+            assertEquals(0, lines.size());
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/741ca402/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/script-csv-export.groovy
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/script-csv-export.groovy b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/script-csv-export.groovy
new file mode 100644
index 0000000..4e6d5b1
--- /dev/null
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/script/script-csv-export.groovy
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+@Grab(group = 'com.opencsv', module = 'opencsv', version = '3.7')
+import com.opencsv.*
+
+import org.apache.tinkerpop.gremlin.process.computer.bulkdumping.BulkExportVertexProgram
+
+def stringify(vertex) {
+  def result = null
+  def rows = vertex.property(BulkExportVertexProgram.BULK_EXPORT_PROPERTIES)
+  if (rows.isPresent()) {
+    def writer = new StringWriter()
+    def w = new CSVWriter(writer)
+    rows.value().each { def row ->
+      w.writeNext((String[]) row, false)
+    }
+    result = writer.toString().trim()
+  }
+  return result
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/741ca402/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
index da00463..79c6a60 100644
--- a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
+++ b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/HadoopGraphProvider.java
@@ -96,6 +96,7 @@ public class HadoopGraphProvider extends AbstractGraphProvider {
                     "tinkerpop-classic.txt",
                     "script-input.groovy",
                     "script-output.groovy",
+                    "script-csv-export.groovy",
                     "grateful-dead.txt",
                     "script-input-grateful-dead.groovy",
                     "script-output-grateful-dead.groovy");


[27/49] incubator-tinkerpop git commit: Don't over-optimize in `RangeByIsCountStrategy` if `count()` or `is()` is labeled.

Posted by dk...@apache.org.
Don't over-optimize in `RangeByIsCountStrategy` if `count()` or `is()` is labeled.


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

Branch: refs/heads/TINKERPOP-1298
Commit: d55897afcd3833d9161d0871ad46cc21cf3db7ce
Parents: 51f55df
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu May 26 11:13:17 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Fri May 27 13:25:37 2016 +0200

----------------------------------------------------------------------
 .../traversal/strategy/optimization/RangeByIsCountStrategy.java | 5 +++--
 .../strategy/optimization/RangeByIsCountStrategyTest.java       | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d55897af/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 efa79e6..2994085 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
@@ -90,8 +90,9 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             final boolean update = highRange == null || highRangeCandidate > highRange;
                             if (update) {
                                 highRange = highRangeCandidate;
-                                useNotStep = (highRange <= 1L && predicate.equals(Compare.lt)) ||
-                                        (highRange == 1L && (predicate.equals(Compare.eq) || predicate.equals(Compare.lte)));
+                                useNotStep = curr.getLabels().isEmpty() && next.getLabels().isEmpty()
+                                        && ((highRange <= 1L && predicate.equals(Compare.lt))
+                                        || (highRange == 1L && (predicate.equals(Compare.eq) || predicate.equals(Compare.lte))));
                             }
                         } else {
                             final Long highRangeOffset = RANGE_PREDICATES.get(predicate);

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d55897af/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 b6d0e27..f07c267 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
@@ -127,6 +127,8 @@ public class RangeByIsCountStrategyTest {
                     {__.out().count().is(0), __.not(__.out())},
                     {__.out().count().is(lt(1)), __.not(__.out())},
                     {__.out().count().is(lte(0)), __.not(__.out())},
+                    {__.out().count().is(0).as("a"), __.out().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))},


[41/49] incubator-tinkerpop git commit: This closes #321

Posted by dk...@apache.org.
This closes #321


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

Branch: refs/heads/TINKERPOP-1298
Commit: 86d8b5cdfdcaff205ac6c809da8e6d009812973c
Parents: bd9972e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 27 11:40:24 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 27 11:40:24 2016 -0400

----------------------------------------------------------------------

----------------------------------------------------------------------