You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/05/29 00:05:39 UTC

incubator-tinkerpop git commit: added CypherStartStep which is Scoping to recommend Scope.local for Select/Where/etc. steps that follow.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/neo4j-gremlin-apache b0aca8e14 -> dffcc033b


added CypherStartStep which is Scoping to recommend Scope.local for Select/Where/etc. steps that follow.


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

Branch: refs/heads/neo4j-gremlin-apache
Commit: dffcc033b294d3b20d2d23a777789b84bc5215c3
Parents: b0aca8e
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 28 16:05:49 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 28 16:05:49 2015 -0600

----------------------------------------------------------------------
 .../step/sideEffect/CypherStartStep.java        | 54 ++++++++++++++++++++
 .../gremlin/neo4j/structure/Neo4jGraph.java     |  4 +-
 .../neo4j/process/NativeNeo4jCypherTest.java    |  9 ++--
 3 files changed, 60 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/dffcc033/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/step/sideEffect/CypherStartStep.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/step/sideEffect/CypherStartStep.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/step/sideEffect/CypherStartStep.java
new file mode 100644
index 0000000..09d00ff
--- /dev/null
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/process/traversal/step/sideEffect/CypherStartStep.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.neo4j.process.traversal.step.sideEffect;
+
+import org.apache.tinkerpop.gremlin.neo4j.process.util.Neo4jCypherIterator;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.Scoping;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+import java.util.Map;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public final class CypherStartStep extends StartStep<Map<String, Object>> implements Scoping {
+
+    private final String query;
+
+    public CypherStartStep(final Traversal.Admin traversal, final String query, final Neo4jCypherIterator<?> cypherIterator) {
+        super(traversal, cypherIterator);
+        this.query = query;
+    }
+
+    @Override
+    public Scope recommendNextScope() {
+        return Scope.local;
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.stepString(this,this.query);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/dffcc033/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
index 9ed8c20..5697543 100644
--- a/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
+++ b/neo4j-gremlin/src/main/java/org/apache/tinkerpop/gremlin/neo4j/structure/Neo4jGraph.java
@@ -21,13 +21,13 @@ package org.apache.tinkerpop.gremlin.neo4j.structure;
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationConverter;
+import org.apache.tinkerpop.gremlin.neo4j.process.traversal.step.sideEffect.CypherStartStep;
 import org.apache.tinkerpop.gremlin.neo4j.process.util.Neo4jCypherIterator;
 import org.apache.tinkerpop.gremlin.neo4j.structure.full.FullNeo4jGraph;
 import org.apache.tinkerpop.gremlin.neo4j.structure.simple.SimpleNeo4jGraph;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StartStep;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -265,7 +265,7 @@ public abstract class Neo4jGraph implements Graph, WrappedGraph<Neo4jGraphAPI> {
         this.tx().readWrite();
         final GraphTraversal.Admin<S, E> traversal = new DefaultGraphTraversal<>(this);
         Iterator result = this.baseGraph.execute(query, parameters);
-        traversal.addStep(new StartStep(traversal, new Neo4jCypherIterator<S>(result, this)));
+        traversal.addStep(new CypherStartStep(traversal, query, new Neo4jCypherIterator<S>(result, this)));
         return traversal;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/dffcc033/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
----------------------------------------------------------------------
diff --git a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
index 0c8c014..872dadc 100644
--- a/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
+++ b/neo4j-gremlin/src/test/java/org/apache/tinkerpop/gremlin/neo4j/process/NativeNeo4jCypherTest.java
@@ -20,7 +20,6 @@ package org.apache.tinkerpop.gremlin.neo4j.process;
 
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.neo4j.AbstractNeo4jGremlinTest;
-import org.apache.tinkerpop.gremlin.process.traversal.Scope;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.junit.Test;
@@ -71,7 +70,7 @@ public class NativeNeo4jCypherTest extends AbstractNeo4jGremlinTest {
 
         final Map<String, Object> bindings = new HashMap<>();
         bindings.put("ids", idList);
-        final Iterator<String> result = this.getGraph().cypher("START n=node({ids}) RETURN n", bindings).select(Scope.local, "n").values("name");
+        final Iterator<String> result = this.getGraph().cypher("START n=node({ids}) RETURN n", bindings).select("n").values("name");
         assertNotNull(result);
         assertTrue(result.hasNext());
         assertEquals("marko", result.next());
@@ -84,7 +83,7 @@ public class NativeNeo4jCypherTest extends AbstractNeo4jGremlinTest {
         this.graph.addVertex("name", "marko", "age", 30, "color", "yellow");
 
         this.graph.tx().commit();
-        final Traversal result = this.getGraph().cypher("MATCH (a {name:\"marko\"}) RETURN a").select(Scope.local, "a").has("age", 29).values("color");
+        final Traversal result = this.getGraph().cypher("MATCH (a {name:\"marko\"}) RETURN a").select("a").has("age", 29).values("color");
         assertNotNull(result);
         assertTrue(result.hasNext());
         assertEquals("red", result.next().toString());
@@ -98,7 +97,7 @@ public class NativeNeo4jCypherTest extends AbstractNeo4jGremlinTest {
         this.graph.addVertex("name", "marko", "age", 30, "color", "orange");
         this.graph.tx().commit();
 
-        final List<Object> result = this.getGraph().cypher("MATCH n WHERE id(n) IN [1,2] RETURN n").select(Scope.local, "n").id().toList();
+        final List<Object> result = this.getGraph().cypher("MATCH n WHERE id(n) IN [1,2] RETURN n").select("n").id().toList();
         assertNotNull(result);
         assertEquals(2, result.size());
         assertTrue(result.contains(1l));
@@ -116,7 +115,7 @@ public class NativeNeo4jCypherTest extends AbstractNeo4jGremlinTest {
         final List<Object> ids = Arrays.asList(v1.id(), v2.id());
         final Map<String, Object> m = new HashMap<>();
         m.put("ids", ids);
-        final List<Object> result = this.getGraph().cypher("MATCH n WHERE id(n) IN {ids} RETURN n", m).select(Scope.local, "n").id().toList();
+        final List<Object> result = this.getGraph().cypher("MATCH n WHERE id(n) IN {ids} RETURN n", m).select("n").id().toList();
         assertNotNull(result);
         assertEquals(2, result.size());
         assertTrue(result.contains(v1.id()));