You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2018/08/01 13:49:14 UTC

[01/50] tinkerpop git commit: Consistent use of hyphen for step references CTR [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1878 98975edc4 -> fafda957f (forced update)


Consistent use of hyphen for step references CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: 9b693c02c6101b82af0d19bae3252fe022ecb988
Parents: 66099fe
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 07:18:25 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 07:18:25 2018 -0400

----------------------------------------------------------------------
 docs/src/upgrade/release-3.3.x.asciidoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9b693c02/docs/src/upgrade/release-3.3.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.3.x.asciidoc b/docs/src/upgrade/release-3.3.x.asciidoc
index a18075f..f6cade0 100644
--- a/docs/src/upgrade/release-3.3.x.asciidoc
+++ b/docs/src/upgrade/release-3.3.x.asciidoc
@@ -115,7 +115,7 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.3.1/CHANGELOG.asc
 ==== Gremlin Python path()
 
 There was a bug in GraphSON 3.0 serialization that prevented proper handling of results contain `Path` object. As a
-result, traversals that used and returned results from the `path()` step in Python would return unusable results,
+result, traversals that used and returned results from the `path()`-step in Python would return unusable results,
 but did not actually cause an exception condition. This problem is now resolved.
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1799[TINKERPOP-1799]
@@ -154,7 +154,7 @@ See: link:https://issues.apache.org/jira/browse/TINKERPOP-1632[TINKERPOP-1632]
 
 ==== Changed Typing on `from()` and `to()`
 
-The `from()` and `to()` steps of `GraphTraversal` have a `Traversal<E,Vertex>` overload. The `E` has been changed to `?`
+The `from()` and `to()`-steps of `GraphTraversal` have a `Traversal<E,Vertex>` overload. The `E` has been changed to `?`
 in order to reduce `< >`-based coersion in strongly type Gremlin language variants.
 
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1793[TINKERPOP-1793]


[46/50] tinkerpop git commit: TINKERPOP-1878 Minor transpiler doc fixes

Posted by sp...@apache.org.
TINKERPOP-1878 Minor transpiler doc fixes


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

Branch: refs/heads/TINKERPOP-1878
Commit: c5b3c4c534c4223f23d980cd13a81a7ebcc3e415
Parents: c322416
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jun 15 08:16:03 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:07 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c5b3c4c5/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index 1bb7728..0483a5d 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -131,7 +131,7 @@ The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) do
 * SPARQL queries with variables in the predicate position are not currently covered, with an exception of the following
 case:
 
-[source,text]
+[source,groovy]
 ----
 g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
 ----
@@ -141,7 +141,7 @@ SPARQL query has the same number of patterns on both the side of the union opera
 SPARQL query cannot be mapped using Gremlinator, since a union is executed between different number of graph patterns
 (two patterns `union` 1 pattern).
 
-[source,text]
+[source,groovy]
 ----
 g.sparql("""SELECT * WHERE {
 	{?person e:created ?software .
@@ -163,7 +163,7 @@ g.sparql("""SELECT ?age WHERE {
 
 Whereas, the following SPARQL query will be invalid:
 
-[source,text]
+[source,groovy]
 ----
 g.sparql("""SELECT ?person WHERE {
       ?person v:label "person" .


[38/50] tinkerpop git commit: TINKERPOP-1878 Changed gryo version of SparqlStrategy

Posted by sp...@apache.org.
TINKERPOP-1878 Changed gryo version of SparqlStrategy

Was using some temporary nonsense before...


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

Branch: refs/heads/TINKERPOP-1878
Commit: 3f1b7bf1bb03b34901650e62b7f95021cc88da31
Parents: 3bf9260
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 08:16:24 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3f1b7bf1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
index 45d2970..d87a9c5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
@@ -393,7 +393,7 @@ public enum GryoVersion {
             add(GryoTypeReg.of(LP_NL_O_OB_P_S_SE_SL_Traverser.class, 179));
             add(GryoTypeReg.of(LabelledCounter.class, 180));
             add(GryoTypeReg.of(Stack.class, 181));
-            add(GryoTypeReg.of(ReferenceMap.class, 182));                        // ***LAST ID***
+            add(GryoTypeReg.of(ReferenceMap.class, 182));
 
 
             // placeholder serializers for classes that don't live here in core. this will allow them to be used if
@@ -405,7 +405,7 @@ public enum GryoVersion {
                     "org.apache.tinkerpop.gremlin.driver.ser.ResponseMessageGryoSerializer", 169);
 
             tryAddDynamicType(this, "org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy",
-                    null, 1690);
+                    null, 183);   // ***LAST ID***
         }};
     }
 


[17/50] tinkerpop git commit: dedup build-helper-maven-plugin - CTR

Posted by sp...@apache.org.
dedup build-helper-maven-plugin - CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: dfe79c24f4decb667ad20c729928a50f8cb1ec0b
Parents: c49c0cc
Author: Robert Dale <ro...@gmail.com>
Authored: Tue Jul 31 13:12:31 2018 -0400
Committer: Robert Dale <ro...@gmail.com>
Committed: Tue Jul 31 13:12:31 2018 -0400

----------------------------------------------------------------------
 pom.xml | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/dfe79c24/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b669872..f2629ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -305,6 +305,7 @@ limitations under the License.
                             <failIfNoMatch>false</failIfNoMatch>
                         </configuration>
                     </execution>
+                    <!-- Needed to figure out the version components when reading revapi API check config below -->
                     <execution>
                         <id>parse-version</id>
                         <goals>
@@ -407,21 +408,6 @@ limitations under the License.
                     </dependency>
                 </dependencies>
             </plugin>
-            <!-- Needed to figure out the version components when reading revapi API check config below -->
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-		<version>3.0.0</version>
-                <executions>
-                    <execution>
-                        <id>parse-version</id>
-                        <goals>
-                            <goal>parse-version</goal>
-                        </goals>
-                        <phase>validate</phase>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <groupId>org.revapi</groupId>
                 <artifactId>revapi-maven-plugin</artifactId>


[40/50] tinkerpop git commit: TINKERPOP-1878 General refactoring and javadoc on Prefixes class

Posted by sp...@apache.org.
TINKERPOP-1878 General refactoring and javadoc on Prefixes class


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

Branch: refs/heads/TINKERPOP-1878
Commit: fe14b3cbe0b6663b34a4379da90507a1acf41ff7
Parents: 3f1b7bf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 09:39:28 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/sparql/Prefixes.java      | 23 ++++++++++----------
 1 file changed, 12 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe14b3cb/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
index 452bf68..32768a7 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
@@ -22,15 +22,16 @@ package org.apache.tinkerpop.gremlin.sparql;
 import java.util.Arrays;
 import java.util.List;
 
+/**
+ * Helper methods for working with prefix lines in SPARQL queries.
+ */
+class Prefixes {
 
-public class Prefixes {
-
-	// public final static String BASE_URI = "http://northwind.com/model/";
-    public final static String BASE_URI = "http://www.tinkerpop.com/traversal/";
+    final static String BASE_URI = "http://tinkerpop.apache.org/traversal/";
 
-    final static List<String> PREFIXES = Arrays.asList("edge", "property", "value");
+    private final static List<String> PREFIXES = Arrays.asList("edge", "property", "value");
 
-    final static String PREFIX_DEFINITIONS;
+    private final static String PREFIX_DEFINITIONS;
 
     static {
         final StringBuilder builder = new StringBuilder();
@@ -41,24 +42,24 @@ public class Prefixes {
         PREFIX_DEFINITIONS = builder.toString();
     }
 
-    public static String getURI(final String prefix) {
+    static String getURI(final String prefix) {
         return BASE_URI + prefix + "#";
     }
 
-    public static String getURIValue(final String uri) {
+    static String getURIValue(final String uri) {
         return uri.substring(uri.indexOf("#") + 1);
     }
 
-    public static String getPrefix(final String uri) {
+    static String getPrefix(final String uri) {
         final String tmp = uri.substring(0, uri.indexOf("#"));
         return tmp.substring(tmp.lastIndexOf("/") + 1);
     }
 
-    public static String prepend(final String script) {
+    static String prepend(final String script) {
         return PREFIX_DEFINITIONS + script;
     }
 
-    public static StringBuilder prepend(final StringBuilder scriptBuilder) {
+    static StringBuilder prepend(final StringBuilder scriptBuilder) {
         return scriptBuilder.insert(0, PREFIX_DEFINITIONS);
     }
 }


[15/50] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by sp...@apache.org.
Merge branch 'tp32' into tp33


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

Branch: refs/heads/TINKERPOP-1878
Commit: c49c0ccb3bce76caabb4b0a9c7efe9df43801b39
Parents: ddc6694 e3018fb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 31 08:35:24 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 31 08:35:24 2018 -0400

----------------------------------------------------------------------
 docs/src/dev/developer/development-environment.asciidoc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c49c0ccb/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------


[36/50] tinkerpop git commit: testing logo

Posted by sp...@apache.org.
testing logo

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

Branch: refs/heads/TINKERPOP-1878
Commit: 8e60e914402a1190726ea281550a46e31f28541a
Parents: 8e6acf4
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Mar 28 10:29:43 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e60e914/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index 305e3dc..9100f84 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -17,6 +17,10 @@ limitations under the License.
 [[transpilers]]
 = Gremlin Transpilers
 
+![gremlinator][SPARQL-Gremlin]
+
+[SPARQL-Gremlin]: https://raw.githubusercontent.com/LITMUS-Benchmark-Suite/sparql-to-gremlin/master/docs/images/sparql-gremlin-logo.png
+
 There are many languages built to query data. SQL is typically used to query relational data. There is SPARQL for RDF
 data. Cypher is used to do pattern matching in graph data. The list could go on. Transpilers convert languages like
 these to Gremlin so that it becomes possible to use them in any context that Gremlin is used. In other words, a


[26/50] tinkerpop git commit: TINKERPOP-1878 Updates to changelog and code comments

Posted by sp...@apache.org.
TINKERPOP-1878 Updates to changelog and code comments


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

Branch: refs/heads/TINKERPOP-1878
Commit: 492db1839f1743128fea4e027bb0c2b6e7898004
Parents: 7171f37
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 17:09:17 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                             | 1 +
 .../process/traversal/dsl/sparql/SparqlTraversalSource.java    | 6 ++++++
 2 files changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/492db183/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 430f52d..db819af 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -111,6 +111,7 @@ This release also includes changes from <<release-3-2-8, 3.2.8>>.
 
 * Fixed regression issue where the HTTPChannelizer doesn't instantiate the specified AuthenticationHandler.
 * Defaulted GLV tests for gremlin-python to run for GraphSON 3.0.
+* Fixed a bug in dynamic Gryo registration where registrations that did not have serializers would fail.
 * Fixed a bug with `Tree` serialization in GraphSON 3.0.
 * In gremlin-python, the GraphSON 3.0 `g:Set` type is now deserialized to `List`.
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/492db183/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
index 3889d95..deb16f7 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
@@ -124,6 +124,12 @@ public class SparqlTraversalSource implements TraversalSource {
      */
     public <S> SparqlTraversal<S,String> sparql(final String query) {
         final SparqlTraversalSource clone = this.clone();
+
+        // this is a bit of a hack to get remote traversals to work cleanly. on the remote side, we'd expect a
+        // GraphTraversalSource not a SparqlTraversalSource (given that sparql-gremlin is to be implemented in the
+        // DSL pattern). Instead of just sending the constant() step with the sparql query we also include an
+        // inject() step which will be recognized by a GraphTraversalSource on the remote side. Since SparqlStrategy
+        // wholly replaces both of these steps, the traversal bytecode can be read properly.
         clone.bytecode.addStep(GraphTraversal.Symbols.inject);
         clone.bytecode.addStep(GraphTraversal.Symbols.constant, query);
         final SparqlTraversal.Admin<S, S> traversal = new DefaultSparqlTraversal<>(clone);


[27/50] tinkerpop git commit: TINKERPOP-1878 sparql() step works over remoting

Posted by sp...@apache.org.
TINKERPOP-1878 sparql() step works over remoting

At this point it is only tested to work with Gryo 3.0. Fixed a bug with how dynamic gryo registrations work - they failed if you didn't have a specific serializer specified. Introduced a bit of a hack to make SparqlTraversalSource behave like a GraphTraversalSource and thus more cleanly follow the DSL pattern. Not sure if that's a great approach yet or not, but it seems harmless at this point.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 7171f37de7f2ffe501e907b7fc922aaf31263a51
Parents: 48ae8aa
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 17:00:54 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java | 5 ++++-
 sparql-gremlin/pom.xml                                          | 4 ----
 .../process/traversal/dsl/sparql/SparqlTraversalSource.java     | 3 +++
 .../sparql/process/traversal/strategy/SparqlStrategy.java       | 5 +++--
 4 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7171f37d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
index e7dfd93..45d2970 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoVersion.java
@@ -403,6 +403,9 @@ public enum GryoVersion {
                     "org.apache.tinkerpop.gremlin.driver.ser.RequestMessageGryoSerializer", 167);
             tryAddDynamicType(this, "org.apache.tinkerpop.gremlin.driver.message.ResponseMessage",
                     "org.apache.tinkerpop.gremlin.driver.ser.ResponseMessageGryoSerializer", 169);
+
+            tryAddDynamicType(this, "org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy",
+                    null, 1690);
         }};
     }
 
@@ -591,7 +594,7 @@ public enum GryoVersion {
                                             final String serializer, final int registrationId) {
         try {
             final Class typeClass = Class.forName(type);
-            final Optional<SerializerShim<?>> serializerInstance = Optional.of(serializer)
+            final Optional<SerializerShim<?>> serializerInstance = Optional.ofNullable(serializer)
                     .map(FunctionUtils.wrapFunction(Class::forName))
                     .map(FunctionUtils.wrapFunction(c -> (SerializerShim<?>) c.getConstructor().newInstance()));
             if (serializerInstance.isPresent()) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7171f37d/sparql-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/sparql-gremlin/pom.xml b/sparql-gremlin/pom.xml
index 0dceb85..0e3da38 100644
--- a/sparql-gremlin/pom.xml
+++ b/sparql-gremlin/pom.xml
@@ -11,10 +11,6 @@
     <artifactId>sparql-gremlin</artifactId>
     <name>Apache TinkerPop :: SPARQL Gremlin</name>
 
-    <properties>
-        <query.dir>src/test/resources/sparql/queries</query.dir>
-    </properties>
-
     <dependencies>
         <dependency>
             <groupId>org.apache.jena</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7171f37d/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
index b156ed1..3889d95 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
@@ -27,6 +27,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
@@ -123,8 +124,10 @@ public class SparqlTraversalSource implements TraversalSource {
      */
     public <S> SparqlTraversal<S,String> sparql(final String query) {
         final SparqlTraversalSource clone = this.clone();
+        clone.bytecode.addStep(GraphTraversal.Symbols.inject);
         clone.bytecode.addStep(GraphTraversal.Symbols.constant, query);
         final SparqlTraversal.Admin<S, S> traversal = new DefaultSparqlTraversal<>(clone);
+        traversal.addStep(new InjectStep<S>(traversal));
         return traversal.addStep(new ConstantStep<S,String>(traversal, query));
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7171f37d/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
index bb0b326..d74ac3e 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy;
 
 import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
+import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.decoration.RemoteStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
@@ -44,7 +45,7 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
         implements TraversalStrategy.DecorationStrategy {
     private static final SparqlStrategy INSTANCE = new SparqlStrategy();
 
-    private static final Set<Class<? extends DecorationStrategy>> POSTS = Collections.singleton(VertexProgramStrategy.class);
+    private static final Set<Class<? extends DecorationStrategy>> POSTS = Collections.singleton(RemoteStrategy.class);
 
     private SparqlStrategy() {}
 
@@ -63,7 +64,7 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
         if (!(traversal.getParent() instanceof EmptyStep))
             return;
 
-        if (traversal.getSteps().size() == 1 && traversal.getEndStep() instanceof ConstantStep) {
+        if (traversal.getSteps().size() == 2 && traversal.getEndStep() instanceof ConstantStep) {
             final ConstantStep stepWithSparql = (ConstantStep) traversal.getEndStep();
             final Object constant = stepWithSparql.getConstant();
             if (constant instanceof String) {


[35/50] tinkerpop git commit: TINKERPOP-1878 Code reformatting - bad spacing/tabs or something

Posted by sp...@apache.org.
TINKERPOP-1878 Code reformatting - bad spacing/tabs or something


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

Branch: refs/heads/TINKERPOP-1878
Commit: fceea4319a4eb834995562c31e4c2f83c6c2dbe4
Parents: 8152624
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 16:03:49 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../sparql/SparqlToGremlinTranspiler.java       | 138 +++++++++----------
 1 file changed, 69 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fceea431/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
index c3bc907..1b28a1d 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
@@ -55,59 +55,59 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
  */
 public class SparqlToGremlinTranspiler {
 
-	private GraphTraversal<Vertex, ?> traversal;
+    private GraphTraversal<Vertex, ?> traversal;
 
     private List<Traversal> traversalList = new ArrayList<>();
 
-	private SparqlToGremlinTranspiler(final GraphTraversal<Vertex, ?> traversal) {
-		this.traversal = traversal;
-	}
+    private SparqlToGremlinTranspiler(final GraphTraversal<Vertex, ?> traversal) {
+        this.traversal = traversal;
+    }
 
-	private SparqlToGremlinTranspiler(final GraphTraversalSource g) {
-		this(g.V());
-	}
+    private SparqlToGremlinTranspiler(final GraphTraversalSource g) {
+        this(g.V());
+    }
 
     /**
      * Converts SPARQL to a Gremlin traversal.
      *
-     * @param graph the {@link Graph} instance to execute the traversal from
+     * @param graph       the {@link Graph} instance to execute the traversal from
      * @param sparqlQuery the query to transpile to Gremlin
      */
     public static GraphTraversal<Vertex, ?> transpile(final Graph graph, final String sparqlQuery) {
-        return transpile(graph.traversal(),	sparqlQuery);
+        return transpile(graph.traversal(), sparqlQuery);
     }
 
     /**
      * Converts SPARQL to a Gremlin traversal.
      *
-     * @param g the {@link GraphTraversalSource} instance to execute the traversal from
+     * @param g           the {@link GraphTraversalSource} instance to execute the traversal from
      * @param sparqlQuery the query to transpile to Gremlin
      */
     public static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final String sparqlQuery) {
         return transpile(g, QueryFactory.create(Prefixes.prepend(sparqlQuery), Syntax.syntaxSPARQL));
     }
 
-	private GraphTraversal<Vertex, ?> transpile(final Query query) {
-		final Op op = Algebra.compile(query);
-		OpWalker.walk(op, new GremlinOpVisitor());
+    private GraphTraversal<Vertex, ?> transpile(final Query query) {
+        final Op op = Algebra.compile(query);
+        OpWalker.walk(op, new GremlinOpVisitor());
 
-		int traversalIndex = 0;
-		final int numberOfTraversal = traversalList.size();
+        int traversalIndex = 0;
+        final int numberOfTraversal = traversalList.size();
         final Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
 
-		for (Traversal tempTrav : traversalList) {
-			arrayOfAllTraversals[traversalIndex++] = tempTrav;
-		}
+        for (Traversal tempTrav : traversalList) {
+            arrayOfAllTraversals[traversalIndex++] = tempTrav;
+        }
 
-		// creates a map of ordering keys and their ordering direction
+        // creates a map of ordering keys and their ordering direction
         final Map<String, Order> orderingIndex = createOrderIndexFromQuery(query);
 
-		if (traversalList.size() > 0)
-			traversal = traversal.match(arrayOfAllTraversals);
+        if (traversalList.size() > 0)
+            traversal = traversal.match(arrayOfAllTraversals);
 
-		final List<String> vars = query.getResultVars();
-		if (!query.isQueryResultStar() && !query.hasGroupBy()) {
-		    // the result sizes have special handling to get the right signatures of select() called. perhaps this
+        final List<String> vars = query.getResultVars();
+        if (!query.isQueryResultStar() && !query.hasGroupBy()) {
+            // the result sizes have special handling to get the right signatures of select() called. perhaps this
             // could be refactored to work more nicely
             switch (vars.size()) {
                 case 0:
@@ -116,7 +116,7 @@ public class SparqlToGremlinTranspiler {
                     if (query.isDistinct())
                         traversal = traversal.dedup(vars.get(0));
 
-                    orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+                    orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
                     traversal = traversal.select(vars.get(0));
 
                     break;
@@ -124,7 +124,7 @@ public class SparqlToGremlinTranspiler {
                     if (query.isDistinct())
                         traversal = traversal.dedup(vars.get(0), vars.get(1));
 
-                    orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+                    orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
                     traversal = traversal.select(vars.get(0), vars.get(1));
 
                     break;
@@ -134,7 +134,7 @@ public class SparqlToGremlinTranspiler {
                     if (query.isDistinct())
                         traversal = traversal.dedup(all);
 
-                    orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+                    orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
 
                     // just some shenanigans to get the right signature of select() called
                     final String[] others = Arrays.copyOfRange(all, 2, vars.size());
@@ -142,59 +142,59 @@ public class SparqlToGremlinTranspiler {
 
                     break;
             }
-		}
-
-		if (query.hasGroupBy()) {
-			final VarExprList lstExpr = query.getGroupBy();
-			String grpVar = "";
-			for (Var expr : lstExpr.getVars()) {
-				grpVar = expr.getName();
-			}
-
-			if (!grpVar.isEmpty())
-				traversal = traversal.select(grpVar);
-			if (query.hasAggregators()) {
+        }
+
+        if (query.hasGroupBy()) {
+            final VarExprList lstExpr = query.getGroupBy();
+            String grpVar = "";
+            for (Var expr : lstExpr.getVars()) {
+                grpVar = expr.getName();
+            }
+
+            if (!grpVar.isEmpty())
+                traversal = traversal.select(grpVar);
+            if (query.hasAggregators()) {
                 final List<ExprAggregator> exprAgg = query.getAggregators();
-				for (ExprAggregator expr : exprAgg) {
-					if (expr.getAggregator().getName().contains("COUNT")) {
-						if (!query.toString().contains("GROUP")) {
-							if (expr.getAggregator().toString().contains("DISTINCT"))
-								traversal = traversal.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
-							else
-								traversal = traversal.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
-
-							traversal = traversal.count();
-						} else {
+                for (ExprAggregator expr : exprAgg) {
+                    if (expr.getAggregator().getName().contains("COUNT")) {
+                        if (!query.toString().contains("GROUP")) {
+                            if (expr.getAggregator().toString().contains("DISTINCT"))
+                                traversal = traversal.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
+                            else
+                                traversal = traversal.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
+
+                            traversal = traversal.count();
+                        } else {
                             traversal = traversal.groupCount();
                         }
-					}
+                    }
 
-					if (expr.getAggregator().getName().contains("MAX")) {
-						traversal = traversal.max();
-					}
-				}
-			} else {
+                    if (expr.getAggregator().getName().contains("MAX")) {
+                        traversal = traversal.max();
+                    }
+                }
+            } else {
                 traversal = traversal.group();
             }
-		}
+        }
 
-		if (query.hasOrderBy() && query.hasGroupBy())
-            orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+        if (query.hasOrderBy() && query.hasGroupBy())
+            orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
 
-		if (query.hasLimit()) {
-			long limit = query.getLimit(), offset = 0;
+        if (query.hasLimit()) {
+            long limit = query.getLimit(), offset = 0;
 
-			if (query.hasOffset())
-				offset = query.getOffset();
+            if (query.hasOffset())
+                offset = query.getOffset();
 
-			if (query.hasGroupBy() && query.hasOrderBy())
-				traversal = traversal.range(Scope.local, offset, offset + limit);
-			else
-				traversal = traversal.range(offset, offset + limit);
-		}
+            if (query.hasGroupBy() && query.hasOrderBy())
+                traversal = traversal.range(Scope.local, offset, offset + limit);
+            else
+                traversal = traversal.range(offset, offset + limit);
+        }
 
-		return traversal;
-	}
+        return traversal;
+    }
 
     /**
      * Extracts any {@code SortCondition} instances from the SPARQL query and holds them in an index of their keys


[14/50] tinkerpop git commit: Added dev notes for python environment CTR

Posted by sp...@apache.org.
Added dev notes for python environment CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: e3018fb2e98df62a21272446f63cea5ee550408e
Parents: 00a085a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 31 08:35:06 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 31 08:35:06 2018 -0400

----------------------------------------------------------------------
 docs/src/dev/developer/development-environment.asciidoc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e3018fb2/docs/src/dev/developer/development-environment.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc
index cde81c1..779f642 100644
--- a/docs/src/dev/developer/development-environment.asciidoc
+++ b/docs/src/dev/developer/development-environment.asciidoc
@@ -74,13 +74,14 @@ The site will be generated to the `target/site/home` directory.
 [[python-environment]]
 === Python Environment
 
-As of TinkerPop 3.2.2, the build optionally requires link:https://www.python.org/[Python 2.x] to work with the
-`gremlin-python` module. If Python is not installed, TinkerPop will still build with Maven, but native Python tests and
+As of TinkerPop 3.2.2, the build optionally requires link:https://www.python.org/[Python] to build the `gremlin-python`
+module. If Python is not installed, TinkerPop will still build with Maven, but native Python tests and
 Java tests that require Python code will be skipped. Developers should also install link:https://pypi.python.org/pypi/pip[pip]
 and link:https://virtualenv.pypa.io/en/stable/[virtualenv] (version 15.0.2 - older versions may cause build failures).
 
-Once the Python environment is established, the full building and testing of `gremlin-python` may commence. It can be
-done manually from the command line with:
+The build expects two Python executables `python` and `python3` where `python` maps to 2.7.6 and `python3` is 3.4.3 or
+higher. Once the Python environment is established, the full building and testing of `gremlin-python` may commence. It
+can be done manually from the command line with:
 
 [source,text]
 mvn clean install -Pglv-python


[32/50] tinkerpop git commit: TINKERPOP-1878 Added the plugin for sparql-gremlin

Posted by sp...@apache.org.
TINKERPOP-1878 Added the plugin for sparql-gremlin


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

Branch: refs/heads/TINKERPOP-1878
Commit: a816dec72b4d0c1b2cc7c8882e9df8e3bdc44650
Parents: 37f4df3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 29 09:37:15 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../sparql/jsr223/SparqlGremlinPlugin.java      | 63 ++++++++++++++++++++
 ...pache.tinkerpop.gremlin.jsr223.GremlinPlugin |  1 +
 2 files changed, 64 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a816dec7/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/jsr223/SparqlGremlinPlugin.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/jsr223/SparqlGremlinPlugin.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/jsr223/SparqlGremlinPlugin.java
new file mode 100644
index 0000000..8d0115b
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/jsr223/SparqlGremlinPlugin.java
@@ -0,0 +1,63 @@
+/*
+ * 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.sparql.jsr223;
+
+import org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.DefaultImportCustomizer;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin;
+import org.apache.tinkerpop.gremlin.jsr223.ImportCustomizer;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql.DefaultSparqlTraversal;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql.SparqlTraversal;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql.SparqlTraversalSource;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy;
+
+/**
+ * {@link GremlinPlugin} implementation for {@code sparql-gremlin} that imports the key classes and interfaces required
+ * to use SPARQL in TinkerPop.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class SparqlGremlinPlugin extends AbstractGremlinPlugin {
+
+    private static final String NAME = "tinkerpop.sparql";
+
+    private static final ImportCustomizer imports;
+
+    static {
+        try {
+            imports = DefaultImportCustomizer.build().addClassImports(
+                    SparqlTraversalSource.class,
+                    SparqlTraversal.class,
+                    DefaultSparqlTraversal.class,
+                    SparqlStrategy.class).create();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private static final SparqlGremlinPlugin instance = new SparqlGremlinPlugin();
+
+    public SparqlGremlinPlugin() {
+        super(NAME, imports);
+    }
+
+    public static SparqlGremlinPlugin instance() {
+        return instance;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a816dec7/sparql-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin b/sparql-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
new file mode 100644
index 0000000..882054c
--- /dev/null
+++ b/sparql-gremlin/src/main/resources/META-INF/services/org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin
@@ -0,0 +1 @@
+org.apache.tinkerpop.gremlin.sparql.jsr223.SparqlGremlinPlugin
\ No newline at end of file


[30/50] tinkerpop git commit: TINKERPOP-1878 Added a test for GROUP

Posted by sp...@apache.org.
TINKERPOP-1878 Added a test for GROUP


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

Branch: refs/heads/TINKERPOP-1878
Commit: 37f4df31f7f20af15d80e5efe952e5442d3e2d7d
Parents: 960b045
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 29 09:09:07 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../dsl/sparql/SparqlTraversalSourceTest.java       | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/37f4df31/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
index 56d62c9..0e56347 100644
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -110,6 +110,7 @@ public class SparqlTraversalSourceTest {
         assertEquals(x.get("a"), _g.V(1).next());
         assertEquals(x.get("b"), _g.V(4).next());
         assertEquals(x.get("c"), _g.V(3).next());
+        assertEquals(3, x.size());
     }
 
     @Test
@@ -134,4 +135,19 @@ public class SparqlTraversalSourceTest {
                         "ORDER BY ?name").toList();
         assertThat(x, contains("josh", "marko", "peter"));
     }
+
+    @Test
+    public void shouldGroup() {
+        final Map<String,Long> x = (Map) g.sparql(
+                "SELECT ?name (COUNT(?name) AS ?name_count)\n" +
+                        "WHERE {\n" +
+                        "    ?a e:created ?b .\n" +
+                        "    ?a v:name ?name .\n" +
+                        "}" +
+                        "GROUP BY ?name").next();
+        assertEquals(new Long(2), x.get("josh"));
+        assertEquals(new Long(1), x.get("peter"));
+        assertEquals(new Long(1), x.get("marko"));
+        assertEquals(3, x.size());
+    }
 }


[44/50] tinkerpop git commit: TINKERPOP-1878 Bump sparql-gremlin to 3.4.0-SNAPSHOT

Posted by sp...@apache.org.
TINKERPOP-1878 Bump sparql-gremlin to 3.4.0-SNAPSHOT


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

Branch: refs/heads/TINKERPOP-1878
Commit: 4fc2b0de9bce26cde30efc93e5b26e8fc396789a
Parents: 8732c6b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun May 13 11:07:10 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:07 2018 -0400

----------------------------------------------------------------------
 sparql-gremlin/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4fc2b0de/sparql-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/sparql-gremlin/pom.xml b/sparql-gremlin/pom.xml
index 731b822..8608cc6 100644
--- a/sparql-gremlin/pom.xml
+++ b/sparql-gremlin/pom.xml
@@ -6,7 +6,7 @@
     <parent>
         <artifactId>tinkerpop</artifactId>
         <groupId>org.apache.tinkerpop</groupId>
-        <version>3.3.2-SNAPSHOT</version>
+        <version>3.4.0-SNAPSHOT</version>
     </parent>
     <artifactId>sparql-gremlin</artifactId>
     <name>Apache TinkerPop :: SPARQL Gremlin</name>


[49/50] tinkerpop git commit: Update SparqlToGremlinCompiler.java

Posted by sp...@apache.org.
Update SparqlToGremlinCompiler.java

adding an updated file with SPARQL OPTIONAL clause:

- added optional
- added left-join with optional

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

Branch: refs/heads/TINKERPOP-1878
Commit: 4a08ffc98d29c43ef7f2ec58e10f7ed08a5ff57d
Parents: 55c991b
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Aug 1 11:14:54 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:37:35 2018 -0400

----------------------------------------------------------------------
 .../gremlin/sparql/SparqlToGremlinCompiler.java | 64 ++++++++++++++++++--
 1 file changed, 60 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4a08ffc9/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
index b43de41..e3b4ecb 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
@@ -35,6 +35,7 @@ import org.apache.jena.sparql.algebra.OpVisitorBase;
 import org.apache.jena.sparql.algebra.OpWalker;
 import org.apache.jena.sparql.algebra.op.OpBGP;
 import org.apache.jena.sparql.algebra.op.OpFilter;
+        import org.apache.jena.sparql.algebra.op.OpLeftJoin;  
 import org.apache.jena.sparql.algebra.op.OpUnion;
 import org.apache.jena.sparql.core.Var;
 import org.apache.jena.sparql.core.VarExprList;
@@ -58,6 +59,9 @@ public class SparqlToGremlinCompiler {
     private GraphTraversal<Vertex, ?> traversal;
 
     private List<Traversal> traversalList = new ArrayList<>();
+            List<Traversal> optionalTraversals = new ArrayList<Traversal>();
+            List<String> optionalVariable = new ArrayList<String>();
+            boolean optionalFlag = false;
 
     private SparqlToGremlinCompiler(final GraphTraversal<Vertex, ?> traversal) {
         this.traversal = traversal;
@@ -93,18 +97,38 @@ public class SparqlToGremlinCompiler {
 
         int traversalIndex = 0;
         final int numberOfTraversal = traversalList.size();
-        final Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
+        final int numberOfOptionalTraversal = optionalTraversals.size();
+        Traversal arrayOfAllTraversals[] = null;
+
+        if (numberOfOptionalTraversal > 0) {
+            arrayOfAllTraversals = new Traversal[numberOfTraversal - numberOfOptionalTraversal +1];
+        } else {
+            arrayOfAllTraversals = new Traversal[numberOfTraversal - numberOfOptionalTraversal];
+        }
+        
+        Traversal arrayOfOptionalTraversals[] = new Traversal[numberOfOptionalTraversal];
 
         for (Traversal tempTrav : traversalList) {
             arrayOfAllTraversals[traversalIndex++] = tempTrav;
         }
 
-        // creates a map of ordering keys and their ordering direction
+        traversalIndex = 0;
+        for (Traversal tempTrav : optionalTraversals) 
+            arrayOfOptionalTraversals[traversalIndex++] = tempTrav;
+ 
+         // creates a map of ordering keys and their ordering direction
         final Map<String, Order> orderingIndex = createOrderIndexFromQuery(query);
 
         if (traversalList.size() > 0)
             traversal = traversal.match(arrayOfAllTraversals);
 
+        if (optionalTraversals.size() > 0) {
+            traversal = traversal.coalesce(__.match(arrayOfOptionalTraversals), (Traversal) __.constant("N/A"));
+            for (int i = 0; i < optionalVariable.size(); i++) {
+                traversal = traversal.as(optionalVariable.get(i).substring(1));
+            }
+        }
+
         final List<String> vars = query.getResultVars();
         if (!query.isQueryResultStar() && !query.hasGroupBy()) {
             final String[] all = new String[vars.size()];
@@ -157,7 +181,6 @@ public class SparqlToGremlinCompiler {
                             traversal = traversal.groupCount();
                         }
                     }
-
                     if (expr.getAggregator().getName().contains("MAX")) {
                         traversal = traversal.max();
                     }
@@ -220,7 +243,14 @@ public class SparqlToGremlinCompiler {
          */
         @Override
         public void visit(final OpBGP opBGP) {
-            opBGP.getPattern().getList().forEach(triple -> traversalList.add(TraversalBuilder.transform(triple)));
+        if(optionalFlag)
+            {
+                opBGP.getPattern().getList().forEach(triple -> optionalTraversals.add(TraversalBuilder.transform(triple)));
+                opBGP.getPattern().getList().forEach(triple -> optionalVariable.add(triple.getObject().toString()));
+                
+            }
+            else        
+                opBGP.getPattern().getList().forEach(triple -> traversalList.add(TraversalBuilder.transform(triple)));
         }
 
         /**
@@ -237,6 +267,32 @@ public class SparqlToGremlinCompiler {
             }
         }
 
+        
+        /**
+         * Visiting LeftJoin(Optional) in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpLeftJoin opLeftJoin) {
+            optionalFlag = true;
+            optionalVisit(opLeftJoin.getRight());
+            if (opLeftJoin.getExprs() != null) {
+                for (Expr expr : opLeftJoin.getExprs().getList()) {
+                    if (expr != null) {
+                        if (optionalFlag)
+                            optionalTraversals.add(__.where(WhereTraversalBuilder.transform(expr)));
+                    }
+                }
+            }
+        }
+        
+        /**
+         * Walking OP for Optional in SPARQL algebra.
+         */
+        private void optionalVisit(final Op op) {
+
+            OpWalker.walk(op, this);
+        }
+
         /**
          * Visiting unions in SPARQL algebra.
          */


[50/50] tinkerpop git commit: TINKERPOP-1878 Renamed "transpiler" to "compiler"

Posted by sp...@apache.org.
TINKERPOP-1878 Renamed "transpiler" to "compiler"

Since we're converting to Gremlin bytecode it's really compiling and not transpiling (as in converting to other source code)


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

Branch: refs/heads/TINKERPOP-1878
Commit: 55c991b2d87d5a1676cec1cae190eefbd17ea9a3
Parents: c5b3c4c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 20 07:25:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:37:35 2018 -0400

----------------------------------------------------------------------
 docs/site/home/index.html                       |   1 +
 docs/src/reference/compilers.asciidoc           | 450 +++++++++++++++++++
 docs/src/reference/index.asciidoc               |   2 +-
 docs/src/reference/transpilers.asciidoc         | 449 ------------------
 .../gremlin/sparql/SparqlToGremlinCompiler.java | 266 +++++++++++
 .../sparql/SparqlToGremlinTranspiler.java       | 266 -----------
 .../traversal/strategy/SparqlStrategy.java      |   4 +-
 7 files changed, 720 insertions(+), 718 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/docs/site/home/index.html
----------------------------------------------------------------------
diff --git a/docs/site/home/index.html b/docs/site/home/index.html
index 4ff692c..b17fedc 100644
--- a/docs/site/home/index.html
+++ b/docs/site/home/index.html
@@ -258,6 +258,7 @@ limitations under the License.
             <li><a href="https://github.com/pm-dev/kotlin-gremlin-ogm">kotlin-gremlin-ogm</a> (kotlin/dsl) - An Object Graph Mapping Library for Kotlin and Gremlin.</li>
             <li><a href="http://ogre.clojurewerkz.org/">ogre</a> (clojure/variant) - A Clojure language wrapper for TinkerPop3.</li>
             <li><a href="http://bayofmany.github.io/">Peapod</a> (java/dsl) - An object-graph-wrapper.</li>
+            <li><a href="http://tinkerpop.apache.org/docs/current/reference/#sparql-gremlin">sparql-gremlin</a> (sparql/distinct) - A SPARQL to Gremlin traversal compiler.</li>
             <li><a href="https://github.com/LITMUS-Benchmark-Suite/sparql-to-gremlin">sparql-gremlin</a> (sparql/distinct) - A SPARQL to Gremlin traversal compiler.</li>
             <li><a href="https://github.com/Microsoft/spring-data-gremlin">spring-data-gremlin</a> (java/dsl) - Spring Data support for TinkerPop-enabled graph systems.</li>
             <li><a href="https://github.com/twilmes/sql-gremlin">sql-gremlin</a> (sql/distinct) - An SQL to Gremlin traversal compiler.</li>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/docs/src/reference/compilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/compilers.asciidoc b/docs/src/reference/compilers.asciidoc
new file mode 100644
index 0000000..e015cc8
--- /dev/null
+++ b/docs/src/reference/compilers.asciidoc
@@ -0,0 +1,450 @@
+////
+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.
+////
+[[compilers]]
+= Gremlin Compilers
+
+There are many languages built to query data. SQL is typically used to query relational data. There is SPARQL for RDF
+data. Cypher is used to do pattern matching in graph data. The list could go on. compilers convert languages like
+these to Gremlin so that it becomes possible to use them in any context that Gremlin is used. In other words, a
+Gremlin Cranspiler enables a particular query language to work on any TinkerPop-enabled graph system.
+
+[[sparql-gremlin]]
+== SPARQL-Gremlin
+
+image::gremlintron.png[width=225]
+
+The SPARQL-Gremlin compiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin
+traversals. It uses the https://jena.apache.org/index.html[Apache Jena] SPARQL processor
+link:https://jena.apache.org/documentation/query/index.html[ARQ], which provides access to a syntax tree of a
+SPARQL query.
+
+The goal of this work is to bridge the query interoperability gap between the two famous, yet fairly disconnected,
+graph communities: Semantic Web (which relies on the RDF data model) and Graph database (which relies on property graph
+data model).
+
+NOTE: The foundational research work on SPARQL-Gremlin compiler (aka Gremlinator) can be found in the
+link:https://arxiv.org/pdf/1801.02911.pdf[Gremlinator paper]. This paper presents the graph query language semantics of
+SPARQL and Gremlin, and a formal mapping between SPARQL pattern matching graph patterns and Gremlin traversals.
+
+[source,xml]
+----
+<dependency>
+   <groupId>org.apache.tinkerpop</groupId>
+   <artifactId>sparql-gremlin</artifactId>
+   <version>x.y.z</version>
+</dependency>
+----
+
+The SPARQL-Gremlin compiler converts link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin so that
+they can be executed across any TinkerPop-enabled graph system. To use this compiler in the Gremlin Console, first
+install and activate the "tinkerpop.sparql" plugin:
+
+[source,text]
+----
+gremlin> :install org.apache.tinkerpop sparql-gremlin x.y.z
+==>Loaded: [org.apache.tinkerpop, sparql-gremlin, x.y.z]
+gremlin> :plugin use tinkerpop.sparql
+==>tinkerpop.sparql activated
+----
+
+Installing this plugin will download appropriate dependencies and import certain classes to the console so that they
+may be used as follows:
+
+[gremlin-groovy,modern]
+----
+graph = TinkerFactory.createModern()
+g = graph.traversal(SparqlTraversalSource)                                                             <1>
+g.sparql("""SELECT ?name ?age
+            WHERE { ?person v:name ?name . ?person v:age ?age }
+            ORDER BY ASC(?age)""")                                                                     <2>
+----
+
+<1> Define `g` as a `TraversalSource` that uses the `SparqlTraversalSource` - by default, the `traversal()` method
+usually returns a `GraphTraversalSource` which includes the standard Gremlin starts steps like `V()` or `E()`. In this
+case, the `SparqlTraversalSource` enables starts steps that are specific to SPARQL only - in this case the `sparql()`
+start step.
+<2> Execute a SPARQL query against the TinkerGraph instance. The `SparqlTraversalSource` uses a
+<<traversalstrategy,TraversalStrategy>> to transparently converts that SPARQL query into a standard Gremlin traversal
+and then when finally iterated, executes that against the TinkerGraph.
+
+[[prefixes]]
+=== Prefixes
+
+The SPARQL-Gremlin compiler supports the following prefixes to traverse the graph:
+
+[cols=",",options="header",]
+|====================================
+|Prefix |Purpose
+|`v:<label>` |label-access traversal
+|`e:<label>` |out-edge traversal
+|`p:<name>` |property traversal
+|`v:<name>` |property-value traversal
+|====================================
+
+Note that element IDs and labels are treated like normal properties, hence they can be accessed using the same pattern:
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?id ?label 
+	WHERE { 
+	?element v:name ?name . 
+	?element v:id ?id . 
+	?element v:label ?label .}""")
+----
+
+[[supported-queries]]
+=== Supported Queries
+
+The SPARQL-Gremlin compiler currently supports translation of the SPARQL 1.0 specification, especially `SELECT`
+queries, though there is an on-going effort to cover the entire SPARQL 1.1 query feature spectrum. The supported
+SPARQL query types are:
+
+* Union 
+* Optional 
+* Order-By 
+* Group-By 
+* STAR-shaped or _neighbourhood queries_ 
+* Query modifiers, such as: 
+** Filter with _restrictions_ 
+** Count 
+** LIMIT 
+** OFFSET
+
+[[limitations]]
+=== Limitations
+
+The current implementation of SPARQL-Gremlin compiler (i.e. SPARQL-Gremlin) does not support the following cases:
+
+* SPARQL queries with variables in the predicate position are not currently covered, with an exception of the following
+case:
+
+[source,groovy]
+----
+g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
+----
+
+* A SPARQL Union query with un-balanced patterns, i.e. a gremlin union traversal can only be generated if the input
+SPARQL query has the same number of patterns on both the side of the union operator. For instance, the following
+SPARQL query cannot be mapped using Gremlinator, since a union is executed between different number of graph patterns
+(two patterns `union` 1 pattern).
+
+[source,groovy]
+----
+g.sparql("""SELECT * WHERE {
+	{?person e:created ?software .
+	?person v:name "josh" .}
+	UNION
+	{?software v:lang "java" .} }""")
+----
+
+* A non-Group key variable cannot be projected in a SPARQL query. This is a SPARQL langauge limitation rather than that of Gremlin/TinkerPop. Apache Jena throws the exception " Non-group key variable in SELECT" if this occurs.
+For instance, in a SPARQL query with GROUP-BY clause, only the variable on which the grouping is declared, can be projected. The following query is valid:
+
+[source,groovy]
+----
+g.sparql("""SELECT ?age WHERE {
+    ?person v:label "person" .
+    ?person v:age ?age .
+    ?person v:name ?name .} GROUP BY (?age)""")
+----
+
+Whereas, the following SPARQL query will be invalid:
+
+[source,groovy]
+----
+g.sparql("""SELECT ?person WHERE {
+      ?person v:label "person" .
+      ?person v:age ?age .
+      ?person v:name ?name .} GROUP BY (?age)""")
+----
+
+
+* In a SPARQL query with an ORDER-BY clause, the ordering occurs wrt to the first projected variable in the query. You may choose any number of variable to be projected, however, the first variable in the selection will be the ordering decider.
+For instance, in the query:
+
+
+[source,groovy]
+----
+g.sparql("""SELECT ?name ?age WHERE {
+    ?person v:label "person" .
+    ?person v:age ?age .
+    ?person v:name ?name . } ORDER BY (?age)""")
+----
+
+the result set will be ordered according to the `?name` variable (in ascending order by default) despite having passed `?age` in the order by. Whereas, for the following query:
+
+[source,groovy]
+----
+g.sparql("""SELECT ?age ?name WHERE {
+    ?person v:label "person" .
+    ?person v:age ?age .
+    ?person v:name ?name . } ORDER BY (?age)""")
+----
+
+the result set will be ordered according to the `?age` (as it is the first projected variable). Finally, for the select all case (`SELECT *`):
+
+[source,groovy]
+----
+g.sparql("""SELECT *
+WHERE { ?person v:label "person" . ?person v:age ?age . ?person v:name ?name . } ORDER BY (?age)""")
+----
+
+The the variable encountered first will be the ordering decider, i.e. since we have `?person` being encountered first, the result set will be ordered according to the `?person` variable (which are vertex id).
+
+* OPTIONAL
+....
+currently fixing this...
+....
+
+[[examples]]
+=== Examples
+
+The following section presents a comprehensive examples of SPARQL queries that are currently covered by the
+SPARQL-Gremlin compiler.
+
+[[select-all]]
+==== Select All
+
+Select all vertices in the graph.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * WHERE { }""")
+----
+
+[[match-constant-values]]
+==== Match Constant Values
+
+Select all vertices with the label `person`.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * WHERE {  ?person v:label "person" .}""")
+----
+
+[[select-specific-elements]]
+==== Select Specific Elements
+
+Select the values of the properties `name` and `age` for each `person` vertex.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?age
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+  ?person v:age ?age . }""")
+----
+
+[[pattern-matching]]
+==== Pattern Matching
+
+Select only those persons who created a project.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?age
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+  ?person v:age ?age .
+  ?person e:created ?project . }""")
+----
+
+[[filtering]]
+==== Filtering
+
+Select only those persons who are older than 30.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?age
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+  ?person v:age ?age .
+    FILTER (?age > 30) }""")
+----
+
+[[deduplication]]
+==== Deduplication
+
+Select the distinct names of the created projects.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT DISTINCT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+  ?person e:created ?project .
+  ?project v:name ?name .
+    FILTER (?age > 30)}""")
+----
+
+[[multiple-filters]]
+==== Multiple Filters
+
+Select the distinct names of all Java projects.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT DISTINCT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+  ?person e:created ?project .
+  ?project v:name ?name .
+  ?project v:lang ?lang .
+    FILTER (?age > 30 && ?lang = "java") }""")
+----
+
+////
+[[pattern-filters]]
+==== Pattern Filter(s)
+
+A different way to filter all person who created a project.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+    FILTER EXISTS { ?person e:created ?project } }""")
+----
+
+Filter all person who did not create a project.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+    FILTER NOT EXISTS { ?person e:created ?project } }""")
+----
+////
+
+[[union]]
+==== Union
+
+Select all persons who have developed a software in java using union.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * 
+WHERE {
+  {?person e:created ?software .}
+  UNION
+  {?software v:lang "java" .} }""")
+----
+
+[[optional]]
+==== Optional
+
+Return the names of the persons who have created a software in java and optionally python.
+
+[source,groovy]
+----
+g.sparql("""SELECT ?person 
+WHERE {
+  ?person v:label "person" .
+  ?person e:created ?software .
+  ?software v:lang "java" .
+  OPTIONAL {?software v:lang "python" . }}""")
+----
+
+[[order-by]]
+==== Order By
+
+Select all vertices with the label `person` and order them by their age.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?age ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+  ?person v:name ?name .
+} ORDER BY (?age))
+----
+
+[[group-by]]
+==== Group By
+
+Select all vertices with the label `person` and group them by their age.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?age 
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+} GROUP BY (?age)""")
+----
+
+[[mixedcomplexaggregation-based-queries]]
+==== Mixed/complex/aggregation-based queries
+
+Count the number of projects which have been created by persons under the age of 30 and group them by age. Return only
+the top two.
+
+[source,groovy]
+----
+g.sparql("""SELECT (COUNT(?project) as ?p)
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age . FILTER (?age < 30)
+  ?person e:created ?project .
+} GROUP BY (?age) LIMIT 2""")
+----
+
+[[meta-property-access]]
+==== Meta-Property Access
+
+Accessing the Meta-Property of a graph element. Meta-Property can be perceived as the reified statements in an RDF
+graph.
+
+[gremlin-groovy,theCrew]
+----
+g = graph.traversal(SparqlTraversalSource)
+g.sparql("""SELECT ?name ?startTime
+WHERE {
+  ?person v:name "daniel" .
+  ?person p:location ?location .
+  ?location v:value ?name .
+  ?location v:startTime ?startTime }""")
+----
+
+[[star-shaped-queries]]
+==== STAR-shaped queries
+
+STAR-shaped queries are the queries that form/follow a star-shaped execution plan. These in terms of graph traversals
+can be perceived as path queries or neighborhood queries. For instance, getting all the information about a specific
+`person` or `software`.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?age ?software ?lang ?name
+WHERE {
+  ?person v:name "josh" .
+  ?person v:age ?age .
+  ?person e:created ?software .
+  ?software v:lang ?lang .
+  ?software v:name ?name . }""")
+----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/docs/src/reference/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/index.asciidoc b/docs/src/reference/index.asciidoc
index 02a218b..9d92c28 100644
--- a/docs/src/reference/index.asciidoc
+++ b/docs/src/reference/index.asciidoc
@@ -45,7 +45,7 @@ include::implementations-hadoop-end.asciidoc[]
 
 include::gremlin-variants.asciidoc[]
 
-include::transpilers.asciidoc[]
+include::compilers.asciidoc[]
 
 include::conclusion.asciidoc[]
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
deleted file mode 100644
index 0483a5d..0000000
--- a/docs/src/reference/transpilers.asciidoc
+++ /dev/null
@@ -1,449 +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.
-////
-[[transpilers]]
-= Gremlin Transpilers
-
-There are many languages built to query data. SQL is typically used to query relational data. There is SPARQL for RDF
-data. Cypher is used to do pattern matching in graph data. The list could go on. Transpilers convert languages like
-these to Gremlin so that it becomes possible to use them in any context that Gremlin is used. In other words, a
-Gremlin Transpiler enables a particular query language to work on any TinkerPop-enabled graph system.
-
-== SPARQL-Gremlin
-
-image::gremlintron.png[width=225]
-
-The SPARQL-Gremlin transpiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin
-traversals. It uses the https://jena.apache.org/index.html[Apache Jena] SPARQL processor
-link:https://jena.apache.org/documentation/query/index.html[ARQ], which provides access to a syntax tree of a
-SPARQL query.
-
-The goal of this work is to bridge the query interoperability gap between the two famous, yet fairly disconnected,
-graph communities: Semantic Web (which relies on the RDF data model) and Graph database (which relies on property graph
-data model).
-
-NOTE: The foundational research work on SPARQL-Gremlin transpiler (aka Gremlinator) can be found in the
-link:https://arxiv.org/pdf/1801.02911.pdf[Gremlinator paper]. This paper presents the graph query language semantics of
-SPARQL and Gremlin, and a formal mapping between SPARQL pattern matching graph patterns and Gremlin traversals.
-
-[source,xml]
-----
-<dependency>
-   <groupId>org.apache.tinkerpop</groupId>
-   <artifactId>sparql-gremlin</artifactId>
-   <version>x.y.z</version>
-</dependency>
-----
-
-The SPARQL-Gremlin transpiler converts link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin so that
-they can be executed across any TinkerPop-enabled graph system. To use this transpiler in the Gremlin Console, first
-install and activate the "tinkerpop.sparql" plugin:
-
-[source,text]
-----
-gremlin> :install org.apache.tinkerpop sparql-gremlin x.y.z
-==>Loaded: [org.apache.tinkerpop, sparql-gremlin, x.y.z]
-gremlin> :plugin use tinkerpop.sparql
-==>tinkerpop.sparql activated
-----
-
-Installing this plugin will download appropriate dependencies and import certain classes to the console so that they
-may be used as follows:
-
-[gremlin-groovy,modern]
-----
-graph = TinkerFactory.createModern()
-g = graph.traversal(SparqlTraversalSource)                                                             <1>
-g.sparql("""SELECT ?name ?age
-            WHERE { ?person v:name ?name . ?person v:age ?age }
-            ORDER BY ASC(?age)""")                                                                     <2>
-----
-
-<1> Define `g` as a `TraversalSource` that uses the `SparqlTraversalSource` - by default, the `traversal()` method
-usually returns a `GraphTraversalSource` which includes the standard Gremlin starts steps like `V()` or `E()`. In this
-case, the `SparqlTraversalSource` enables starts steps that are specific to SPARQL only - in this case the `sparql()`
-start step.
-<2> Execute a SPARQL query against the TinkerGraph instance. The `SparqlTraversalSource` uses a
-<<traversalstrategy,TraversalStrategy>> to transparently converts that SPARQL query into a standard Gremlin traversal
-and then when finally iterated, executes that against the TinkerGraph.
-
-[[prefixes]]
-=== Prefixes
-
-The SPARQL-Gremlin transpiler supports the following prefixes to traverse the graph:
-
-[cols=",",options="header",]
-|====================================
-|Prefix |Purpose
-|`v:<label>` |label-access traversal
-|`e:<label>` |out-edge traversal
-|`p:<name>` |property traversal
-|`v:<name>` |property-value traversal
-|====================================
-
-Note that element IDs and labels are treated like normal properties, hence they can be accessed using the same pattern:
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name ?id ?label 
-	WHERE { 
-	?element v:name ?name . 
-	?element v:id ?id . 
-	?element v:label ?label .}""")
-----
-
-[[supported-queries]]
-=== Supported Queries
-
-The SPARQL-Gremlin transpiler currently supports translation of the SPARQL 1.0 specification, especially `SELECT`
-queries, though there is an on-going effort to cover the entire SPARQL 1.1 query feature spectrum. The supported
-SPARQL query types are:
-
-* Union 
-* Optional 
-* Order-By 
-* Group-By 
-* STAR-shaped or _neighbourhood queries_ 
-* Query modifiers, such as: 
-** Filter with _restrictions_ 
-** Count 
-** LIMIT 
-** OFFSET
-
-[[limitations]]
-=== Limitations
-
-The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) does not support the following cases:
-
-* SPARQL queries with variables in the predicate position are not currently covered, with an exception of the following
-case:
-
-[source,groovy]
-----
-g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
-----
-
-* A SPARQL Union query with un-balanced patterns, i.e. a gremlin union traversal can only be generated if the input
-SPARQL query has the same number of patterns on both the side of the union operator. For instance, the following
-SPARQL query cannot be mapped using Gremlinator, since a union is executed between different number of graph patterns
-(two patterns `union` 1 pattern).
-
-[source,groovy]
-----
-g.sparql("""SELECT * WHERE {
-	{?person e:created ?software .
-	?person v:name "josh" .}
-	UNION
-	{?software v:lang "java" .} }""")
-----
-
-* A non-Group key variable cannot be projected in a SPARQL query. This is a SPARQL langauge limitation rather than that of Gremlin/TinkerPop. Apache Jena throws the exception " Non-group key variable in SELECT" if this occurs.
-For instance, in a SPARQL query with GROUP-BY clause, only the variable on which the grouping is declared, can be projected. The following query is valid:
-
-[source,groovy]
-----
-g.sparql("""SELECT ?age WHERE {
-    ?person v:label "person" .
-    ?person v:age ?age .
-    ?person v:name ?name .} GROUP BY (?age)""")
-----
-
-Whereas, the following SPARQL query will be invalid:
-
-[source,groovy]
-----
-g.sparql("""SELECT ?person WHERE {
-      ?person v:label "person" .
-      ?person v:age ?age .
-      ?person v:name ?name .} GROUP BY (?age)""")
-----
-
-
-* In a SPARQL query with an ORDER-BY clause, the ordering occurs wrt to the first projected variable in the query. You may choose any number of variable to be projected, however, the first variable in the selection will be the ordering decider.
-For instance, in the query:
-
-
-[source,groovy]
-----
-g.sparql("""SELECT ?name ?age WHERE {
-    ?person v:label "person" .
-    ?person v:age ?age .
-    ?person v:name ?name . } ORDER BY (?age)""")
-----
-
-the result set will be ordered according to the `?name` variable (in ascending order by default) despite having passed `?age` in the order by. Whereas, for the following query:
-
-[source,groovy]
-----
-g.sparql("""SELECT ?age ?name WHERE {
-    ?person v:label "person" .
-    ?person v:age ?age .
-    ?person v:name ?name . } ORDER BY (?age)""")
-----
-
-the result set will be ordered according to the `?age` (as it is the first projected variable). Finally, for the select all case (`SELECT *`):
-
-[source,groovy]
-----
-g.sparql("""SELECT *
-WHERE { ?person v:label "person" . ?person v:age ?age . ?person v:name ?name . } ORDER BY (?age)""")
-----
-
-The the variable encountered first will be the ordering decider, i.e. since we have `?person` being encountered first, the result set will be ordered according to the `?person` variable (which are vertex id).
-
-* OPTIONAL
-....
-currently fixing this...
-....
-
-[[examples]]
-=== Examples
-
-The following section presents a comprehensive examples of SPARQL queries that are currently covered by the
-SPARQL-Gremlin transpiler.
-
-[[select-all]]
-==== Select All
-
-Select all vertices in the graph.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT * WHERE { }""")
-----
-
-[[match-constant-values]]
-==== Match Constant Values
-
-Select all vertices with the label `person`.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT * WHERE {  ?person v:label "person" .}""")
-----
-
-[[select-specific-elements]]
-==== Select Specific Elements
-
-Select the values of the properties `name` and `age` for each `person` vertex.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name ?age
-WHERE {
-  ?person v:label "person" .
-  ?person v:name ?name .
-  ?person v:age ?age . }""")
-----
-
-[[pattern-matching]]
-==== Pattern Matching
-
-Select only those persons who created a project.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name ?age
-WHERE {
-  ?person v:label "person" .
-  ?person v:name ?name .
-  ?person v:age ?age .
-  ?person e:created ?project . }""")
-----
-
-[[filtering]]
-==== Filtering
-
-Select only those persons who are older than 30.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name ?age
-WHERE {
-  ?person v:label "person" .
-  ?person v:name ?name .
-  ?person v:age ?age .
-    FILTER (?age > 30) }""")
-----
-
-[[deduplication]]
-==== Deduplication
-
-Select the distinct names of the created projects.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT DISTINCT ?name
-WHERE {
-  ?person v:label "person" .
-  ?person v:age ?age .
-  ?person e:created ?project .
-  ?project v:name ?name .
-    FILTER (?age > 30)}""")
-----
-
-[[multiple-filters]]
-==== Multiple Filters
-
-Select the distinct names of all Java projects.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT DISTINCT ?name
-WHERE {
-  ?person v:label "person" .
-  ?person v:age ?age .
-  ?person e:created ?project .
-  ?project v:name ?name .
-  ?project v:lang ?lang .
-    FILTER (?age > 30 && ?lang = "java") }""")
-----
-
-////
-[[pattern-filters]]
-==== Pattern Filter(s)
-
-A different way to filter all person who created a project.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name
-WHERE {
-  ?person v:label "person" .
-  ?person v:name ?name .
-    FILTER EXISTS { ?person e:created ?project } }""")
-----
-
-Filter all person who did not create a project.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name
-WHERE {
-  ?person v:label "person" .
-  ?person v:name ?name .
-    FILTER NOT EXISTS { ?person e:created ?project } }""")
-----
-////
-
-[[union]]
-==== Union
-
-Select all persons who have developed a software in java using union.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT * 
-WHERE {
-  {?person e:created ?software .}
-  UNION
-  {?software v:lang "java" .} }""")
-----
-
-[[optional]]
-==== Optional
-
-Return the names of the persons who have created a software in java and optionally python.
-
-[source,groovy]
-----
-g.sparql("""SELECT ?person 
-WHERE {
-  ?person v:label "person" .
-  ?person e:created ?software .
-  ?software v:lang "java" .
-  OPTIONAL {?software v:lang "python" . }}""")
-----
-
-[[order-by]]
-==== Order By
-
-Select all vertices with the label `person` and order them by their age.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?age ?name
-WHERE {
-  ?person v:label "person" .
-  ?person v:age ?age .
-  ?person v:name ?name .
-} ORDER BY (?age))
-----
-
-[[group-by]]
-==== Group By
-
-Select all vertices with the label `person` and group them by their age.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?age 
-WHERE {
-  ?person v:label "person" .
-  ?person v:age ?age .
-} GROUP BY (?age)""")
-----
-
-[[mixedcomplexaggregation-based-queries]]
-==== Mixed/complex/aggregation-based queries
-
-Count the number of projects which have been created by persons under the age of 30 and group them by age. Return only
-the top two.
-
-[source,groovy]
-----
-g.sparql("""SELECT (COUNT(?project) as ?p)
-WHERE {
-  ?person v:label "person" .
-  ?person v:age ?age . FILTER (?age < 30)
-  ?person e:created ?project .
-} GROUP BY (?age) LIMIT 2""")
-----
-
-[[meta-property-access]]
-==== Meta-Property Access
-
-Accessing the Meta-Property of a graph element. Meta-Property can be perceived as the reified statements in an RDF
-graph.
-
-[gremlin-groovy,theCrew]
-----
-g = graph.traversal(SparqlTraversalSource)
-g.sparql("""SELECT ?name ?startTime
-WHERE {
-  ?person v:name "daniel" .
-  ?person p:location ?location .
-  ?location v:value ?name .
-  ?location v:startTime ?startTime }""")
-----
-
-[[star-shaped-queries]]
-==== STAR-shaped queries
-
-STAR-shaped queries are the queries that form/follow a star-shaped execution plan. These in terms of graph traversals
-can be perceived as path queries or neighborhood queries. For instance, getting all the information about a specific
-`person` or `software`.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?age ?software ?lang ?name
-WHERE {
-  ?person v:name "josh" .
-  ?person v:age ?age .
-  ?person e:created ?software .
-  ?software v:lang ?lang .
-  ?software v:name ?name . }""")
-----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
new file mode 100644
index 0000000..b43de41
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
@@ -0,0 +1,266 @@
+/*
+ * 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.sparql;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jena.query.Query;
+import org.apache.jena.query.QueryFactory;
+import org.apache.jena.query.SortCondition;
+import org.apache.jena.query.Syntax;
+import org.apache.jena.sparql.algebra.Algebra;
+import org.apache.jena.sparql.algebra.Op;
+import org.apache.jena.sparql.algebra.OpVisitorBase;
+import org.apache.jena.sparql.algebra.OpWalker;
+import org.apache.jena.sparql.algebra.op.OpBGP;
+import org.apache.jena.sparql.algebra.op.OpFilter;
+import org.apache.jena.sparql.algebra.op.OpUnion;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.core.VarExprList;
+import org.apache.jena.sparql.expr.Expr;
+import org.apache.jena.sparql.expr.ExprAggregator;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+/**
+ * The engine that transpiles SPARQL to Gremlin traversals thus enabling SPARQL to be executed on any TinkerPop-enabled
+ * graph system.
+ */
+public class SparqlToGremlinCompiler {
+
+    private GraphTraversal<Vertex, ?> traversal;
+
+    private List<Traversal> traversalList = new ArrayList<>();
+
+    private SparqlToGremlinCompiler(final GraphTraversal<Vertex, ?> traversal) {
+        this.traversal = traversal;
+    }
+
+    private SparqlToGremlinCompiler(final GraphTraversalSource g) {
+        this(g.V());
+    }
+
+    /**
+     * Converts SPARQL to a Gremlin traversal.
+     *
+     * @param graph       the {@link Graph} instance to execute the traversal from
+     * @param sparqlQuery the query to transpile to Gremlin
+     */
+    public static GraphTraversal<Vertex, ?> transpile(final Graph graph, final String sparqlQuery) {
+        return transpile(graph.traversal(), sparqlQuery);
+    }
+
+    /**
+     * Converts SPARQL to a Gremlin traversal.
+     *
+     * @param g           the {@link GraphTraversalSource} instance to execute the traversal from
+     * @param sparqlQuery the query to transpile to Gremlin
+     */
+    public static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final String sparqlQuery) {
+        return transpile(g, QueryFactory.create(Prefixes.prepend(sparqlQuery), Syntax.syntaxSPARQL));
+    }
+
+    private GraphTraversal<Vertex, ?> transpile(final Query query) {
+        final Op op = Algebra.compile(query);
+        OpWalker.walk(op, new GremlinOpVisitor());
+
+        int traversalIndex = 0;
+        final int numberOfTraversal = traversalList.size();
+        final Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
+
+        for (Traversal tempTrav : traversalList) {
+            arrayOfAllTraversals[traversalIndex++] = tempTrav;
+        }
+
+        // creates a map of ordering keys and their ordering direction
+        final Map<String, Order> orderingIndex = createOrderIndexFromQuery(query);
+
+        if (traversalList.size() > 0)
+            traversal = traversal.match(arrayOfAllTraversals);
+
+        final List<String> vars = query.getResultVars();
+        if (!query.isQueryResultStar() && !query.hasGroupBy()) {
+            final String[] all = new String[vars.size()];
+            vars.toArray(all);
+            if (query.isDistinct()) {
+                traversal = traversal.dedup(all);
+            }
+
+            // apply ordering from ORDER BY
+            orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
+
+            // the result sizes have special handling to get the right signatures of select() called.
+            switch (all.length) {
+                case 0:
+                    throw new IllegalStateException();
+                case 1:
+                    traversal = traversal.select(all[0]);
+                    break;
+                case 2:
+                    traversal = traversal.select(all[0], all[1]);
+                    break;
+                default:
+                    final String[] others = Arrays.copyOfRange(all, 2, vars.size());
+                    traversal = traversal.select(all[0], all[1], others);
+                    break;
+            }
+        }
+
+        if (query.hasGroupBy()) {
+            final VarExprList lstExpr = query.getGroupBy();
+            String grpVar = "";
+            for (Var expr : lstExpr.getVars()) {
+                grpVar = expr.getName();
+            }
+
+            if (!grpVar.isEmpty())
+                traversal = traversal.select(grpVar);
+            if (query.hasAggregators()) {
+                final List<ExprAggregator> exprAgg = query.getAggregators();
+                for (ExprAggregator expr : exprAgg) {
+                    if (expr.getAggregator().getName().contains("COUNT")) {
+                        if (!query.toString().contains("GROUP")) {
+                            if (expr.getAggregator().toString().contains("DISTINCT"))
+                                traversal = traversal.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
+                            else
+                                traversal = traversal.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
+
+                            traversal = traversal.count();
+                        } else {
+                            traversal = traversal.groupCount();
+                        }
+                    }
+
+                    if (expr.getAggregator().getName().contains("MAX")) {
+                        traversal = traversal.max();
+                    }
+                }
+            } else {
+                traversal = traversal.group();
+            }
+        }
+
+        if (query.hasOrderBy() && query.hasGroupBy())
+            orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
+
+        if (query.hasLimit()) {
+            long limit = query.getLimit(), offset = 0;
+
+            if (query.hasOffset())
+                offset = query.getOffset();
+
+            if (query.hasGroupBy() && query.hasOrderBy())
+                traversal = traversal.range(Scope.local, offset, offset + limit);
+            else
+                traversal = traversal.range(offset, offset + limit);
+        }
+
+        return traversal;
+    }
+
+    /**
+     * Extracts any {@code SortCondition} instances from the SPARQL query and holds them in an index of their keys
+     * where the value is that keys sorting direction.
+     */
+    private static Map<String, Order> createOrderIndexFromQuery(final Query query) {
+        final Map<String, Order> orderingIndex = new HashMap<>();
+        if (query.hasOrderBy()) {
+            final List<SortCondition> sortingConditions = query.getOrderBy();
+
+            for (SortCondition sortCondition : sortingConditions) {
+                final Expr expr = sortCondition.getExpression();
+
+                // by default, the sort will be ascending. getDirection() returns -2 if the DESC/ASC isn't
+                // supplied - weird
+                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == -1 ? Order.decr : Order.incr);
+            }
+        }
+
+        return orderingIndex;
+    }
+
+    private static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final Query query) {
+        return new SparqlToGremlinCompiler(g).transpile(query);
+    }
+
+    /**
+     * An {@code OpVisitor} implementation that reads SPARQL algebra operations into Gremlin traversals.
+     */
+    private class GremlinOpVisitor extends OpVisitorBase {
+
+        /**
+         * Visiting triple patterns in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpBGP opBGP) {
+            opBGP.getPattern().getList().forEach(triple -> traversalList.add(TraversalBuilder.transform(triple)));
+        }
+
+        /**
+         * Visiting filters in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpFilter opFilter) {
+            Traversal traversal;
+            for (Expr expr : opFilter.getExprs().getList()) {
+                if (expr != null) {
+                    traversal = __.where(WhereTraversalBuilder.transform(expr));
+                    traversalList.add(traversal);
+                }
+            }
+        }
+
+        /**
+         * Visiting unions in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpUnion opUnion) {
+            final Traversal unionTemp[] = new Traversal[2];
+            final Traversal unionTemp1[] = new Traversal[traversalList.size() / 2];
+            final Traversal unionTemp2[] = new Traversal[traversalList.size() / 2];
+
+            int count = 0;
+
+            for (int i = 0; i < traversalList.size(); i++) {
+                if (i < traversalList.size() / 2)
+                    unionTemp1[i] = traversalList.get(i);
+                else
+                    unionTemp2[count++] = traversalList.get(i);
+            }
+
+            unionTemp[1] = __.match(unionTemp2);
+            unionTemp[0] = __.match(unionTemp1);
+
+            traversalList.clear();
+            traversal = (GraphTraversal<Vertex, ?>) traversal.union(unionTemp);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
deleted file mode 100644
index 67ac1e1..0000000
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
+++ /dev/null
@@ -1,266 +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.sparql;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.jena.query.Query;
-import org.apache.jena.query.QueryFactory;
-import org.apache.jena.query.SortCondition;
-import org.apache.jena.query.Syntax;
-import org.apache.jena.sparql.algebra.Algebra;
-import org.apache.jena.sparql.algebra.Op;
-import org.apache.jena.sparql.algebra.OpVisitorBase;
-import org.apache.jena.sparql.algebra.OpWalker;
-import org.apache.jena.sparql.algebra.op.OpBGP;
-import org.apache.jena.sparql.algebra.op.OpFilter;
-import org.apache.jena.sparql.algebra.op.OpUnion;
-import org.apache.jena.sparql.core.Var;
-import org.apache.jena.sparql.core.VarExprList;
-import org.apache.jena.sparql.expr.Expr;
-import org.apache.jena.sparql.expr.ExprAggregator;
-import org.apache.tinkerpop.gremlin.process.traversal.Order;
-import org.apache.tinkerpop.gremlin.process.traversal.Scope;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-/**
- * The engine that transpiles SPARQL to Gremlin traversals thus enabling SPARQL to be executed on any TinkerPop-enabled
- * graph system.
- */
-public class SparqlToGremlinTranspiler {
-
-    private GraphTraversal<Vertex, ?> traversal;
-
-    private List<Traversal> traversalList = new ArrayList<>();
-
-    private SparqlToGremlinTranspiler(final GraphTraversal<Vertex, ?> traversal) {
-        this.traversal = traversal;
-    }
-
-    private SparqlToGremlinTranspiler(final GraphTraversalSource g) {
-        this(g.V());
-    }
-
-    /**
-     * Converts SPARQL to a Gremlin traversal.
-     *
-     * @param graph       the {@link Graph} instance to execute the traversal from
-     * @param sparqlQuery the query to transpile to Gremlin
-     */
-    public static GraphTraversal<Vertex, ?> transpile(final Graph graph, final String sparqlQuery) {
-        return transpile(graph.traversal(), sparqlQuery);
-    }
-
-    /**
-     * Converts SPARQL to a Gremlin traversal.
-     *
-     * @param g           the {@link GraphTraversalSource} instance to execute the traversal from
-     * @param sparqlQuery the query to transpile to Gremlin
-     */
-    public static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final String sparqlQuery) {
-        return transpile(g, QueryFactory.create(Prefixes.prepend(sparqlQuery), Syntax.syntaxSPARQL));
-    }
-
-    private GraphTraversal<Vertex, ?> transpile(final Query query) {
-        final Op op = Algebra.compile(query);
-        OpWalker.walk(op, new GremlinOpVisitor());
-
-        int traversalIndex = 0;
-        final int numberOfTraversal = traversalList.size();
-        final Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
-
-        for (Traversal tempTrav : traversalList) {
-            arrayOfAllTraversals[traversalIndex++] = tempTrav;
-        }
-
-        // creates a map of ordering keys and their ordering direction
-        final Map<String, Order> orderingIndex = createOrderIndexFromQuery(query);
-
-        if (traversalList.size() > 0)
-            traversal = traversal.match(arrayOfAllTraversals);
-
-        final List<String> vars = query.getResultVars();
-        if (!query.isQueryResultStar() && !query.hasGroupBy()) {
-            final String[] all = new String[vars.size()];
-            vars.toArray(all);
-            if (query.isDistinct()) {
-                traversal = traversal.dedup(all);
-            }
-
-            // apply ordering from ORDER BY
-            orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
-
-            // the result sizes have special handling to get the right signatures of select() called.
-            switch (all.length) {
-                case 0:
-                    throw new IllegalStateException();
-                case 1:
-                    traversal = traversal.select(all[0]);
-                    break;
-                case 2:
-                    traversal = traversal.select(all[0], all[1]);
-                    break;
-                default:
-                    final String[] others = Arrays.copyOfRange(all, 2, vars.size());
-                    traversal = traversal.select(all[0], all[1], others);
-                    break;
-            }
-        }
-
-        if (query.hasGroupBy()) {
-            final VarExprList lstExpr = query.getGroupBy();
-            String grpVar = "";
-            for (Var expr : lstExpr.getVars()) {
-                grpVar = expr.getName();
-            }
-
-            if (!grpVar.isEmpty())
-                traversal = traversal.select(grpVar);
-            if (query.hasAggregators()) {
-                final List<ExprAggregator> exprAgg = query.getAggregators();
-                for (ExprAggregator expr : exprAgg) {
-                    if (expr.getAggregator().getName().contains("COUNT")) {
-                        if (!query.toString().contains("GROUP")) {
-                            if (expr.getAggregator().toString().contains("DISTINCT"))
-                                traversal = traversal.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
-                            else
-                                traversal = traversal.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
-
-                            traversal = traversal.count();
-                        } else {
-                            traversal = traversal.groupCount();
-                        }
-                    }
-
-                    if (expr.getAggregator().getName().contains("MAX")) {
-                        traversal = traversal.max();
-                    }
-                }
-            } else {
-                traversal = traversal.group();
-            }
-        }
-
-        if (query.hasOrderBy() && query.hasGroupBy())
-            orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
-
-        if (query.hasLimit()) {
-            long limit = query.getLimit(), offset = 0;
-
-            if (query.hasOffset())
-                offset = query.getOffset();
-
-            if (query.hasGroupBy() && query.hasOrderBy())
-                traversal = traversal.range(Scope.local, offset, offset + limit);
-            else
-                traversal = traversal.range(offset, offset + limit);
-        }
-
-        return traversal;
-    }
-
-    /**
-     * Extracts any {@code SortCondition} instances from the SPARQL query and holds them in an index of their keys
-     * where the value is that keys sorting direction.
-     */
-    private static Map<String, Order> createOrderIndexFromQuery(final Query query) {
-        final Map<String, Order> orderingIndex = new HashMap<>();
-        if (query.hasOrderBy()) {
-            final List<SortCondition> sortingConditions = query.getOrderBy();
-
-            for (SortCondition sortCondition : sortingConditions) {
-                final Expr expr = sortCondition.getExpression();
-
-                // by default, the sort will be ascending. getDirection() returns -2 if the DESC/ASC isn't
-                // supplied - weird
-                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == -1 ? Order.decr : Order.incr);
-            }
-        }
-
-        return orderingIndex;
-    }
-
-    private static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final Query query) {
-        return new SparqlToGremlinTranspiler(g).transpile(query);
-    }
-
-    /**
-     * An {@code OpVisitor} implementation that reads SPARQL algebra operations into Gremlin traversals.
-     */
-    private class GremlinOpVisitor extends OpVisitorBase {
-
-        /**
-         * Visiting triple patterns in SPARQL algebra.
-         */
-        @Override
-        public void visit(final OpBGP opBGP) {
-            opBGP.getPattern().getList().forEach(triple -> traversalList.add(TraversalBuilder.transform(triple)));
-        }
-
-        /**
-         * Visiting filters in SPARQL algebra.
-         */
-        @Override
-        public void visit(final OpFilter opFilter) {
-            Traversal traversal;
-            for (Expr expr : opFilter.getExprs().getList()) {
-                if (expr != null) {
-                    traversal = __.where(WhereTraversalBuilder.transform(expr));
-                    traversalList.add(traversal);
-                }
-            }
-        }
-
-        /**
-         * Visiting unions in SPARQL algebra.
-         */
-        @Override
-        public void visit(final OpUnion opUnion) {
-            final Traversal unionTemp[] = new Traversal[2];
-            final Traversal unionTemp1[] = new Traversal[traversalList.size() / 2];
-            final Traversal unionTemp2[] = new Traversal[traversalList.size() / 2];
-
-            int count = 0;
-
-            for (int i = 0; i < traversalList.size(); i++) {
-                if (i < traversalList.size() / 2)
-                    unionTemp1[i] = traversalList.get(i);
-                else
-                    unionTemp2[count++] = traversalList.get(i);
-            }
-
-            unionTemp[1] = __.match(unionTemp2);
-            unionTemp[0] = __.match(unionTemp1);
-
-            traversalList.clear();
-            traversal = (GraphTraversal<Vertex, ?>) traversal.union(unionTemp);
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/55c991b2/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
index 4073ec2..b21c348 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
@@ -25,7 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
 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.sparql.SparqlToGremlinTranspiler;
+import org.apache.tinkerpop.gremlin.sparql.SparqlToGremlinCompiler;
 import org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql.SparqlTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
@@ -68,7 +68,7 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
             final Object constant = stepWithSparql.getConstant();
             if (constant instanceof String) {
                 final String sparql = (String) constant;
-                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinTranspiler.transpile(
+                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinCompiler.transpile(
                         traversal.getGraph().get(), sparql);
                 TraversalHelper.removeAllSteps(traversal);
                 sparqlTraversal.asAdmin().getSteps().forEach(s -> traversal.addStep(s));


[19/50] tinkerpop git commit: This closes #892

Posted by sp...@apache.org.
This closes #892


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

Branch: refs/heads/TINKERPOP-1878
Commit: b183edd10a52dc65022c0270951b5bd9f2b5be7e
Parents: f50aeb6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 31 15:54:01 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 31 15:54:01 2018 -0400

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

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



[33/50] tinkerpop git commit: TINKERPOP-1878 Major refactoring of sparql-gremlin classes

Posted by sp...@apache.org.
TINKERPOP-1878 Major refactoring of sparql-gremlin classes

Renamed the "compiler" to a "transpiler" since it's really transforming sparql to a language of a similar level of abstraction in Gremlin. Lots of code reformatting and dead code pruning.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 456cdcfce5a0397d08a079c7e145e7233e7f6de9
Parents: fe14b3c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 13:36:29 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../gremlin/sparql/SparqlToGremlinCompiler.java | 381 -------------------
 .../sparql/SparqlToGremlinTranspiler.java       | 286 ++++++++++++++
 .../gremlin/sparql/TraversalBuilder.java        |   7 +-
 .../gremlin/sparql/WhereTraversalBuilder.java   |  66 ++--
 .../traversal/strategy/SparqlStrategy.java      |   5 +-
 5 files changed, 322 insertions(+), 423 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/456cdcfc/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
deleted file mode 100644
index adb36e9..0000000
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
+++ /dev/null
@@ -1,381 +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.sparql;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.jena.graph.Triple;
-import org.apache.jena.query.Query;
-import org.apache.jena.query.QueryFactory;
-import org.apache.jena.query.SortCondition;
-import org.apache.jena.query.Syntax;
-import org.apache.jena.sparql.algebra.Algebra;
-import org.apache.jena.sparql.algebra.Op;
-import org.apache.jena.sparql.algebra.OpVisitorBase;
-import org.apache.jena.sparql.algebra.OpWalker;
-import org.apache.jena.sparql.algebra.op.OpBGP;
-import org.apache.jena.sparql.algebra.op.OpFilter;
-import org.apache.jena.sparql.algebra.op.OpLeftJoin;
-import org.apache.jena.sparql.algebra.op.OpUnion;
-import org.apache.jena.sparql.core.Var;
-import org.apache.jena.sparql.core.VarExprList;
-import org.apache.jena.sparql.expr.Expr;
-import org.apache.jena.sparql.expr.ExprAggregator;
-import org.apache.tinkerpop.gremlin.process.traversal.Order;
-import org.apache.tinkerpop.gremlin.process.traversal.Scope;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-
-// TODO: implement OpVisitor, don't extend OpVisitorBase
-public class SparqlToGremlinCompiler extends OpVisitorBase {
-
-	private GraphTraversal<Vertex, ?> traversal;
-
-	List<Traversal> traversalList = new ArrayList<Traversal>();
-
-	String groupVariable = "";
-	int sortingDirection = 0;
-	long offsetLimit = 0;
-	String sortingVariable = "";
-
-	GraphTraversalSource temp;
-	Graph graph;
-
-	private SparqlToGremlinCompiler(final GraphTraversal<Vertex, ?> traversal) {
-		this.traversal = traversal;
-	}
-
-	private SparqlToGremlinCompiler(final GraphTraversalSource g) {
-		this(g.V());
-		temp = g;
-
-	}
-
-	private SparqlToGremlinCompiler(final Graph g) {
-		this.traversal = (GraphTraversal<Vertex, ?>) g.traversal();
-		graph = g;
-	}
-
-	public String createMatchStep(String step) {
-		String st = "";
-		step = step.substring(1, step.length() - 2);
-		String first = step.substring(0, step.indexOf(","));
-		String second = step.substring(step.indexOf(",") + 1);
-		//System.out.println("First : " + first);
-		//System.out.println("Second : " + second);
-		st = first.substring(first.indexOf("["), first.length() - 1);
-		st = "[" + st + "," + second + "]";
-		return st;
-	}
-
-	GraphTraversal<Vertex, ?> convertToGremlinTraversal(final Query query) {
-		
-		// long startTime = System.currentTimeMillis();
-		// long endTime;
-		final Op op = Algebra.compile(query); // SPARQL query compiles here to
-												// OP
-//		System.out.println("OP Tree: " + op.toString());
-
-		
-		OpWalker.walk(op, this); // OP is being walked here
-		
-		
-		
-		
-		//System.out.println("time taken for opWalker:"+ (endTime-startTime));
-		// startTime = System.currentTimeMillis();
-		int traversalIndex = 0;
-		int numberOfTraversal = traversalList.size();
-		Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
-
-		if (query.hasOrderBy() && !query.hasGroupBy()) {
-			List<SortCondition> sortingConditions = query.getOrderBy();
-			int directionOfSort = 0;
-
-			for (SortCondition sortCondition : sortingConditions) {
-				Expr expr = sortCondition.getExpression();
-				directionOfSort = sortCondition.getDirection();
-				sortingVariable = expr.getVarName();
-
-			}
-
-			Order orderDirection = Order.incr;
-			if (directionOfSort == -1) {
-				orderDirection = Order.decr;
-			}
-		}
-		for (Traversal tempTrav : traversalList) {
-
-			arrayOfAllTraversals[traversalIndex++] = tempTrav;
-		}
-
-		int directionOfSort = 0;
-		Order orderDirection = Order.incr;
-		if (query.hasOrderBy()) {
-			List<SortCondition> sortingConditions = query.getOrderBy();
-
-			//
-			for (SortCondition sortCondition : sortingConditions) {
-				Expr expr = sortCondition.getExpression();
-				directionOfSort = sortCondition.getDirection();
-				sortingVariable = expr.getVarName();
-//				System.out.println("order by var: "+sortingDirection);
-			}
-			//
-
-			if (directionOfSort == -1) {
-				orderDirection = Order.decr;
-			}
-
-		}
-
-		if (traversalList.size() > 0)
-			traversal = traversal.match(arrayOfAllTraversals);
-
-		final List<String> vars = query.getResultVars();
-		List<ExprAggregator> lstexpr = query.getAggregators();
-		if (!query.isQueryResultStar() && !query.hasGroupBy()) {
-
-			switch (vars.size()) {
-			case 0:
-				throw new IllegalStateException();
-			case 1:
-				if (query.isDistinct()) {
-//					System.out.println("Inside ------------------- >Select 1------------------------> Distinct");
-					traversal = traversal.dedup(vars.get(0));
-				}
-				if (query.hasOrderBy()) {
-//					System.out.println("Inside ------------------- >Select 1");
-					traversal = traversal.order().by(sortingVariable, orderDirection);
-				} else {
-
-					traversal = traversal.select(vars.get(0));
-				}
-				break;
-			case 2:
-				if (query.isDistinct()) {
-					traversal = traversal.dedup(vars.get(0), vars.get(1));
-				}
-				if (query.hasOrderBy()) {
-//					System.out.println("Inside ------------------- >Select 1");
-					traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
-				} else
-					traversal = traversal.select(vars.get(0), vars.get(1));
-				break;
-			default:
-				final String[] all = new String[vars.size()];
-				vars.toArray(all);
-				if (query.isDistinct()) {
-
-					traversal = traversal.dedup(all);
-				}
-				final String[] others = Arrays.copyOfRange(all, 2, vars.size());
-				if (query.hasOrderBy()) {
-
-					traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
-
-				} else
-					traversal = traversal.select(vars.get(0), vars.get(1), others);
-
-				break;
-			}
-
-		}
-		
-		
-		if (query.hasGroupBy()) {
-			VarExprList lstExpr = query.getGroupBy();
-			String grpVar = "";
-			Traversal tempTrav;
-			for (Var expr : lstExpr.getVars()) {
-				grpVar = expr.getName();
-				// System.out.println("The Group by var: " + expr.getName());
-			}
-
-			if (query.hasLimit()) {
-				long limit = query.getLimit(), offset = 0;
-
-				if (query.hasOffset()) {
-					offset = query.getOffset();
-
-				}
-				// if (query.hasGroupBy() && query.hasOrderBy())
-				// traversal = traversal.range( offset, offset + limit);
-				// else
-				// traversal = traversal.range(offset, offset + limit);
-
-			}
-
-			if (!grpVar.isEmpty())
-				traversal = traversal.select(grpVar);
-			if (query.hasAggregators()) {
-				List<ExprAggregator> exprAgg = query.getAggregators();
-				for (ExprAggregator expr : exprAgg) {
-
-//					System.out.println("The Aggregator by var: " + expr.getAggregator().getExprList().toString()
-//							+ " is :" + expr.getAggregator().toString());
-					if (expr.getAggregator().getName().contains("COUNT")) {
-						if (!query.toString().contains("GROUP")) {
-							if (expr.getAggregator().toString().contains("DISTINCT")) {
-								traversal = traversal
-										.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
-							} else {
-								traversal = traversal
-										.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
-							}
-							traversal = traversal.count();
-						} else
-							traversal = traversal.groupCount();
-					}
-					if (expr.getAggregator().getName().contains("MAX")) {
-						traversal = traversal.max();
-					}
-				}
-
-			} else {
-
-				traversal = traversal.group();
-			}
-			
-			
-		}
-
-
-		if (query.hasOrderBy() && query.hasGroupBy()) {
-
-			traversal = traversal.order().by(sortingVariable, orderDirection);
-		}
-		if (query.hasLimit()) {
-			long limit = query.getLimit(), offset = 0;
-
-			if (query.hasOffset()) {
-				offset = query.getOffset();
-
-			}
-			if (query.hasGroupBy() && query.hasOrderBy())
-				traversal = traversal.range(Scope.local, offset, offset + limit);
-			else
-				traversal = traversal.range(offset, offset + limit);
-
-		}
-		// endTime = System.currentTimeMillis();
-		// System.out.println("time taken for convertToGremlinTraversal Function : "+ (endTime-startTime)+" mili seconds");
-		
-		return traversal;
-	}
-
-	private static GraphTraversal<Vertex, ?> convertToGremlinTraversal(final GraphTraversalSource g,
-			final Query query) {
-		return new SparqlToGremlinCompiler(g).convertToGremlinTraversal(query);
-	}
-
-	public static GraphTraversal<Vertex, ?> convertToGremlinTraversal(final Graph graph, final String query) {
-		return convertToGremlinTraversal(graph.traversal(),	QueryFactory.create(Prefixes.prepend(query)));
-	}
-
-	public static GraphTraversal<Vertex, ?> convertToGremlinTraversal(final GraphTraversalSource g,
-			final String query) {
-		return convertToGremlinTraversal(g, QueryFactory.create(Prefixes.prepend(query), Syntax.syntaxSPARQL));
-	}
-
-	// VISITING SPARQL ALGEBRA OP BASIC TRIPLE PATTERNS - MAYBE
-	@Override
-	public void visit(final OpBGP opBGP) {
-		{
-			
-			// System.out.println("Inside opBGP ---------------------------------------------->");
-			final List<Triple> triples = opBGP.getPattern().getList();
-			final Traversal[] matchTraversals = new Traversal[triples.size()];
-			int i = 0;
-			for (final Triple triple : triples) {
-
-				matchTraversals[i++] = TraversalBuilder.transform(triple);
-				traversalList.add(matchTraversals[i - 1]);
-			}
-
-		}
-
-	}
-
-	// VISITING SPARQL ALGEBRA OP FILTER - MAYBE
-	@Override
-	public void visit(final OpFilter opFilter) {
-
-		// System.out.println("Inside opFilter ---------------------------------------------->");
-		Traversal traversal = null;
-
-		for (Expr expr : opFilter.getExprs().getList()) {
-			if (expr != null) {
-
-				traversal = __.where(WhereTraversalBuilder.transform(expr));
-				traversalList.add(traversal);
-			}
-		}
-
-	}
-	// TODO: add more functions for operators other than FILTER, such as
-	// OPTIONAL
-	// This can be done by understanding how Jena handles these other
-	// operators/filters inherently and then map them to Gremlin
-
-	public void visit(final OpLeftJoin opLeftJoin) {
-
-//		System.out.println("Inside opOptional ---------------------------------------------->");
-//		System.out.println(opLeftJoin.getRight().toString());
-
-	}
-
-	@Override
-	public void visit(final OpUnion opUnion) {
-
-		// System.out.println("Inside opUnion ---------------------------------------------->");
-		Traversal unionTemp[] = new Traversal[2];
-		Traversal unionTemp1[] = new Traversal[traversalList.size() / 2];
-		Traversal unionTemp2[] = new Traversal[traversalList.size() / 2];
-
-		int count = 0;
-
-		for (int i = 0; i < traversalList.size(); i++) {
-
-			if (i < traversalList.size() / 2) {
-
-				unionTemp1[i] = traversalList.get(i);
-			} else {
-				unionTemp2[count++] = traversalList.get(i);
-			}
-		}
-
-		unionTemp[1] = __.match(unionTemp2);
-		unionTemp[0] = __.match(unionTemp1);
-
-		traversalList.clear();
-		traversal = (GraphTraversal<Vertex, ?>) traversal.union(unionTemp);
-		// System.out.println("Getting out from Union -------------------> :
-		// "+traversal);
-		// traversalList.add(__.union(unionTemp));
-		// traversalList.clear();
-	}
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/456cdcfc/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
new file mode 100644
index 0000000..9db7d82
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
@@ -0,0 +1,286 @@
+/*
+ * 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.sparql;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.Query;
+import org.apache.jena.query.QueryFactory;
+import org.apache.jena.query.SortCondition;
+import org.apache.jena.query.Syntax;
+import org.apache.jena.sparql.algebra.Algebra;
+import org.apache.jena.sparql.algebra.Op;
+import org.apache.jena.sparql.algebra.OpVisitorBase;
+import org.apache.jena.sparql.algebra.OpWalker;
+import org.apache.jena.sparql.algebra.op.OpBGP;
+import org.apache.jena.sparql.algebra.op.OpFilter;
+import org.apache.jena.sparql.algebra.op.OpUnion;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.core.VarExprList;
+import org.apache.jena.sparql.expr.Expr;
+import org.apache.jena.sparql.expr.ExprAggregator;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+/**
+ * The engine that transpiles SPARQL to Gremlin traversals thus enabling SPARQL to be executed on any TinkerPop-enabled
+ * graph system.
+ */
+public class SparqlToGremlinTranspiler {
+
+	private GraphTraversal<Vertex, ?> traversal;
+
+    private List<Traversal> traversalList = new ArrayList<>();
+
+    private String sortingVariable = "";
+
+	private SparqlToGremlinTranspiler(final GraphTraversal<Vertex, ?> traversal) {
+		this.traversal = traversal;
+	}
+
+	private SparqlToGremlinTranspiler(final GraphTraversalSource g) {
+		this(g.V());
+	}
+
+    /**
+     * Converts SPARQL to a Gremlin traversal.
+     *
+     * @param graph the {@link Graph} instance to execute the traversal from
+     * @param sparqlQuery the query to transpile to Gremlin
+     */
+    public static GraphTraversal<Vertex, ?> transpile(final Graph graph, final String sparqlQuery) {
+        return transpile(graph.traversal(),	sparqlQuery);
+    }
+
+    /**
+     * Converts SPARQL to a Gremlin traversal.
+     *
+     * @param g the {@link GraphTraversalSource} instance to execute the traversal from
+     * @param sparqlQuery the query to transpile to Gremlin
+     */
+    public static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final String sparqlQuery) {
+        return transpile(g, QueryFactory.create(Prefixes.prepend(sparqlQuery), Syntax.syntaxSPARQL));
+    }
+
+	private GraphTraversal<Vertex, ?> transpile(final Query query) {
+		final Op op = Algebra.compile(query);
+		OpWalker.walk(op, new GremlinOpVisitor());
+
+		int traversalIndex = 0;
+		final int numberOfTraversal = traversalList.size();
+        final Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
+
+		if (query.hasOrderBy() && !query.hasGroupBy()) {
+            final List<SortCondition> sortingConditions = query.getOrderBy();
+
+			for (SortCondition sortCondition : sortingConditions) {
+                final Expr expr = sortCondition.getExpression();
+				sortingVariable = expr.getVarName();
+			}
+		}
+
+		for (Traversal tempTrav : traversalList) {
+			arrayOfAllTraversals[traversalIndex++] = tempTrav;
+		}
+
+		Order orderDirection = Order.incr;
+		if (query.hasOrderBy()) {
+            int directionOfSort = 0;
+            final List<SortCondition> sortingConditions = query.getOrderBy();
+
+			for (SortCondition sortCondition : sortingConditions) {
+                final Expr expr = sortCondition.getExpression();
+				directionOfSort = sortCondition.getDirection();
+				sortingVariable = expr.getVarName();
+			}
+
+			if (directionOfSort == -1) orderDirection = Order.decr;
+		}
+
+		if (traversalList.size() > 0)
+			traversal = traversal.match(arrayOfAllTraversals);
+
+		final List<String> vars = query.getResultVars();
+		if (!query.isQueryResultStar() && !query.hasGroupBy()) {
+            switch (vars.size()) {
+                case 0:
+                    throw new IllegalStateException();
+                case 1:
+                    if (query.isDistinct())
+                        traversal = traversal.dedup(vars.get(0));
+
+                    if (query.hasOrderBy())
+                        traversal = traversal.order().by(sortingVariable, orderDirection);
+                    else
+                        traversal = traversal.select(vars.get(0));
+
+                    break;
+                case 2:
+                    if (query.isDistinct())
+                        traversal = traversal.dedup(vars.get(0), vars.get(1));
+
+                    if (query.hasOrderBy())
+                        traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
+                    else
+                        traversal = traversal.select(vars.get(0), vars.get(1));
+
+                    break;
+                default:
+                    final String[] all = new String[vars.size()];
+                    vars.toArray(all);
+                    if (query.isDistinct())
+                        traversal = traversal.dedup(all);
+
+                    final String[] others = Arrays.copyOfRange(all, 2, vars.size());
+                    if (query.hasOrderBy())
+                        traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
+                    else
+                        traversal = traversal.select(vars.get(0), vars.get(1), others);
+
+                    break;
+            }
+		}
+
+		if (query.hasGroupBy()) {
+			final VarExprList lstExpr = query.getGroupBy();
+			String grpVar = "";
+			for (Var expr : lstExpr.getVars()) {
+				grpVar = expr.getName();
+			}
+
+			if (!grpVar.isEmpty())
+				traversal = traversal.select(grpVar);
+			if (query.hasAggregators()) {
+                final List<ExprAggregator> exprAgg = query.getAggregators();
+				for (ExprAggregator expr : exprAgg) {
+					if (expr.getAggregator().getName().contains("COUNT")) {
+						if (!query.toString().contains("GROUP")) {
+							if (expr.getAggregator().toString().contains("DISTINCT"))
+								traversal = traversal.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
+							else
+								traversal = traversal.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
+
+							traversal = traversal.count();
+						} else {
+                            traversal = traversal.groupCount();
+                        }
+					}
+
+					if (expr.getAggregator().getName().contains("MAX")) {
+						traversal = traversal.max();
+					}
+				}
+			} else {
+                traversal = traversal.group();
+            }
+		}
+
+		if (query.hasOrderBy() && query.hasGroupBy())
+			traversal = traversal.order().by(sortingVariable, orderDirection);
+
+		if (query.hasLimit()) {
+			long limit = query.getLimit(), offset = 0;
+
+			if (query.hasOffset())
+				offset = query.getOffset();
+
+			if (query.hasGroupBy() && query.hasOrderBy())
+				traversal = traversal.range(Scope.local, offset, offset + limit);
+			else
+				traversal = traversal.range(offset, offset + limit);
+		}
+
+		return traversal;
+	}
+
+    private static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final Query query) {
+        return new SparqlToGremlinTranspiler(g).transpile(query);
+    }
+
+    /**
+     * An {@code OpVisitor} implementation that reads SPARQL algebra operations into Gremlin traversals.
+     */
+    private class GremlinOpVisitor extends OpVisitorBase {
+
+        /**
+         * Visiting triple patterns in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpBGP opBGP) {
+            final List<Triple> triples = opBGP.getPattern().getList();
+            final Traversal[] matchTraversals = new Traversal[triples.size()];
+            int i = 0;
+            for (final Triple triple : triples) {
+
+                matchTraversals[i++] = TraversalBuilder.transform(triple);
+                traversalList.add(matchTraversals[i - 1]);
+            }
+        }
+
+        /**
+         * Visiting filters in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpFilter opFilter) {
+            Traversal traversal;
+            for (Expr expr : opFilter.getExprs().getList()) {
+                if (expr != null) {
+                    traversal = __.where(WhereTraversalBuilder.transform(expr));
+                    traversalList.add(traversal);
+                }
+            }
+        }
+
+        /**
+         * Visiting unions in SPARQL algebra.
+         */
+        @Override
+        public void visit(final OpUnion opUnion) {
+            final Traversal unionTemp[] = new Traversal[2];
+            final Traversal unionTemp1[] = new Traversal[traversalList.size() / 2];
+            final Traversal unionTemp2[] = new Traversal[traversalList.size() / 2];
+
+            int count = 0;
+
+            for (int i = 0; i < traversalList.size(); i++) {
+                if (i < traversalList.size() / 2)
+                    unionTemp1[i] = traversalList.get(i);
+                else
+                    unionTemp2[count++] = traversalList.get(i);
+            }
+
+            unionTemp[1] = __.match(unionTemp2);
+            unionTemp[0] = __.match(unionTemp1);
+
+            traversalList.clear();
+            traversal = (GraphTraversal<Vertex, ?>) traversal.union(unionTemp);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/456cdcfc/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
index 72a32a5..6d29442 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
@@ -26,10 +26,12 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.structure.PropertyType;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
-
+/**
+ * Converts triple patterns into {@link GraphTraversal} instances.
+ */
 class TraversalBuilder {
 
-    public static GraphTraversal<?, ?> transform(final Triple triple) {
+    static GraphTraversal<?, ?> transform(final Triple triple) {
         final GraphTraversal<Vertex, ?> matchTraversal = __.as(triple.getSubject().getName());
         
         final Node predicate = triple.getPredicate();
@@ -53,7 +55,6 @@ class TraversalBuilder {
                                                       final PropertyType type, final Node object) {
         switch (propertyName) {
             case "id":
-         
                 return object.isConcrete()
                         ? traversal.hasId(object.getLiteralValue())
                         : traversal.id().as(object.getName());

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/456cdcfc/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
index f4d49b6..80da707 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
@@ -33,61 +33,77 @@ import org.apache.jena.sparql.expr.E_LogicalAnd;
 import org.apache.jena.sparql.expr.E_LogicalOr;
 import org.apache.jena.sparql.expr.E_NotEquals;
 import org.apache.jena.sparql.expr.E_NotExists;
-import org.apache.jena.sparql.expr.E_StrLength;
 import org.apache.jena.sparql.expr.Expr;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 
+/**
+ * Converts SPARQL "where" expressions to Gremlin predicates.
+ */
 class WhereTraversalBuilder {
 
-    public static GraphTraversal<?, ?> transform(final E_Equals expression) {
-    //	System.out.println("The aggr one : "+expression.getArg1().getClass().getName() + "The aggr one :"+expression.getArg2().getClass().getName());
+    /**
+     * Converts a general {@code Expr} to an anonymous {@link GraphTraversal}.
+     */
+    static GraphTraversal<?, ?> transform(final Expr expression) {
+        if (expression instanceof E_Equals) return transform((E_Equals) expression);
+        if (expression instanceof E_NotEquals) return transform((E_NotEquals) expression);
+        if (expression instanceof E_LessThan) return transform((E_LessThan) expression);
+        if (expression instanceof E_LessThanOrEqual) return transform((E_LessThanOrEqual) expression);
+        if (expression instanceof E_GreaterThan) return transform((E_GreaterThan) expression);
+        if (expression instanceof E_GreaterThanOrEqual) return transform((E_GreaterThanOrEqual) expression);
+        if (expression instanceof E_LogicalAnd) return transform((E_LogicalAnd) expression);
+        if (expression instanceof E_LogicalOr) return transform((E_LogicalOr) expression);
+        if (expression instanceof E_Exists) return transform((E_Exists) expression);
+        if (expression instanceof E_NotExists) return transform((E_NotExists) expression);
+        throw new IllegalStateException(String.format("Unhandled expression: %s", expression));
+    }
+
+    private static GraphTraversal<?, ?> transform(final E_Equals expression) {
         final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
         return __.as(expression.getArg1().getVarName()).is(P.eq(value));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_NotEquals expression) {
+    private static GraphTraversal<?, ?> transform(final E_NotEquals expression) {
         final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
         return __.as(expression.getArg1().getVarName()).is(P.neq(value));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_LessThan expression) {
-    //	System.out.println("The aggr one : "+expression.getArg1().getClass().getName() + "The aggr one :"+expression.getArg2().getClass().getName());
+    private static GraphTraversal<?, ?> transform(final E_LessThan expression) {
     	final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
         return __.as(expression.getArg1().getVarName()).is(P.lt(value));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_LessThanOrEqual expression) {
-    //	System.out.println("The aggr one : "+expression.getArg1().getClass().getName() + "The aggr one :"+expression.getArg2().getClass().getName());
+    private static GraphTraversal<?, ?> transform(final E_LessThanOrEqual expression) {
         final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
         return __.as(expression.getArg1().getVarName()).is(P.lte(value));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_GreaterThan expression) {
+    private static GraphTraversal<?, ?> transform(final E_GreaterThan expression) {
         final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
         return __.as(expression.getArg1().getVarName()).is(P.gt(value));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_GreaterThanOrEqual expression) {
+    private static GraphTraversal<?, ?> transform(final E_GreaterThanOrEqual expression) {
         final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
         return __.as(expression.getArg1().getVarName()).is(P.gte(value));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_LogicalAnd expression) {
+    private static GraphTraversal<?, ?> transform(final E_LogicalAnd expression) {
         return __.and(
                 transform(expression.getArg1()),
                 transform(expression.getArg2()));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_LogicalOr expression) {
+    private static GraphTraversal<?, ?> transform(final E_LogicalOr expression) {
         return __.or(
                 transform(expression.getArg1()),
                 transform(expression.getArg2()));
     }
 
-    public static GraphTraversal<?, ?> transform(final E_Exists expression) {
+    private static GraphTraversal<?, ?> transform(final E_Exists expression) {
         final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
         final List<Triple> triples = opBGP.getPattern().getList();
         if (triples.size() != 1) throw new IllegalStateException("Unhandled EXISTS pattern");
@@ -99,7 +115,7 @@ class WhereTraversalBuilder {
     }
     
 
-    public static GraphTraversal<?, ?> transform(final E_NotExists expression) {
+    private static GraphTraversal<?, ?> transform(final E_NotExists expression) {
         final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
         final List<Triple> triples = opBGP.getPattern().getList();
         if (triples.size() != 1) throw new IllegalStateException("Unhandled NOT EXISTS pattern");
@@ -109,26 +125,4 @@ class WhereTraversalBuilder {
         endStep.removeLabel(label);
         return __.not(traversal);
     }
-    
-    public static int getStrLength(final E_StrLength expression){
-    	
-    	return expression.getArg().toString().length();
-    	
-    }
-    
-    
-    //what does <?, ?> signify? possibly <S,E>
-    public static GraphTraversal<?, ?> transform(final Expr expression) {
-        if (expression instanceof E_Equals) return transform((E_Equals) expression);
-        if (expression instanceof E_NotEquals) return transform((E_NotEquals) expression);
-        if (expression instanceof E_LessThan) return transform((E_LessThan) expression);
-        if (expression instanceof E_LessThanOrEqual) return transform((E_LessThanOrEqual) expression);
-        if (expression instanceof E_GreaterThan) return transform((E_GreaterThan) expression);
-        if (expression instanceof E_GreaterThanOrEqual) return transform((E_GreaterThanOrEqual) expression);
-        if (expression instanceof E_LogicalAnd) return transform((E_LogicalAnd) expression);
-        if (expression instanceof E_LogicalOr) return transform((E_LogicalOr) expression);
-        if (expression instanceof E_Exists) return transform((E_Exists) expression);
-        if (expression instanceof E_NotExists) return transform((E_NotExists) expression);
-        throw new IllegalStateException(String.format("Unhandled expression: %s", expression));
-    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/456cdcfc/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
index d74ac3e..4073ec2 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy;
 
-import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
 import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.decoration.RemoteStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
@@ -26,7 +25,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
 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.sparql.SparqlToGremlinCompiler;
+import org.apache.tinkerpop.gremlin.sparql.SparqlToGremlinTranspiler;
 import org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql.SparqlTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
@@ -69,7 +68,7 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
             final Object constant = stepWithSparql.getConstant();
             if (constant instanceof String) {
                 final String sparql = (String) constant;
-                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinCompiler.convertToGremlinTraversal(
+                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinTranspiler.transpile(
                         traversal.getGraph().get(), sparql);
                 TraversalHelper.removeAllSteps(traversal);
                 sparqlTraversal.asAdmin().getSteps().forEach(s -> traversal.addStep(s));


[42/50] tinkerpop git commit: TINKERPOP-1878 More tests for ordering

Posted by sp...@apache.org.
TINKERPOP-1878 More tests for ordering

Factored the order index creation into its own method to tidy up a bit.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 81526247d63564e7054068989426d9e38d2cfd02
Parents: 87ccf58
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 15:56:55 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../sparql/SparqlToGremlinTranspiler.java       | 29 ++++++++++++++------
 .../dsl/sparql/SparqlTraversalSourceTest.java   |  6 ++++
 2 files changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81526247/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
index ea3f828..c3bc907 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
@@ -99,15 +99,8 @@ public class SparqlToGremlinTranspiler {
 			arrayOfAllTraversals[traversalIndex++] = tempTrav;
 		}
 
-		final Map<String, Order> orderingIndex = new HashMap<>();
-		if (query.hasOrderBy()) {
-            final List<SortCondition> sortingConditions = query.getOrderBy();
-
-			for (SortCondition sortCondition : sortingConditions) {
-                final Expr expr = sortCondition.getExpression();
-                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == 1 ? Order.incr : Order.decr);
-			}
-		}
+		// creates a map of ordering keys and their ordering direction
+        final Map<String, Order> orderingIndex = createOrderIndexFromQuery(query);
 
 		if (traversalList.size() > 0)
 			traversal = traversal.match(arrayOfAllTraversals);
@@ -203,6 +196,24 @@ public class SparqlToGremlinTranspiler {
 		return traversal;
 	}
 
+    /**
+     * Extracts any {@code SortCondition} instances from the SPARQL query and holds them in an index of their keys
+     * where the value is that keys sorting direction.
+     */
+    private static Map<String, Order> createOrderIndexFromQuery(final Query query) {
+        final Map<String, Order> orderingIndex = new HashMap<>();
+        if (query.hasOrderBy()) {
+            final List<SortCondition> sortingConditions = query.getOrderBy();
+
+            for (SortCondition sortCondition : sortingConditions) {
+                final Expr expr = sortCondition.getExpression();
+                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == 1 ? Order.incr : Order.decr);
+            }
+        }
+
+        return orderingIndex;
+    }
+
     private static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final Query query) {
         return new SparqlToGremlinTranspiler(g).transpile(query);
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/81526247/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
index 2743255..1b39813 100644
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -82,4 +82,10 @@ public class SparqlTraversalSourceTest {
                 }}
         ));
     }
+
+    @Test
+    public void shouldFindAllNamesOrdered() {
+        final List<?> x = g.sparql("SELECT ?name WHERE { ?person v:name ?name } ORDER BY DESC(?name)").toList();
+        assertThat(x, contains("vadas", "ripple", "peter", "marko", "lop", "josh"));
+    }
 }


[10/50] tinkerpop git commit: Added a better reason for some OptOut on RemoteGraph CTR

Posted by sp...@apache.org.
Added a better reason for some OptOut on RemoteGraph CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: 00a085aa15cfc877222712f8572c89f1c096597c
Parents: 2b045f3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 11:40:52 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 11:40:52 2018 -0400

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/00a085aa/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
index 8a1ab02..4b23475 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
@@ -55,11 +55,11 @@ import java.util.Iterator;
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PeerPressureTest",
         method = "*",
-        reason = "hmmmm")
+        reason = "https://issues.apache.org/jira/browse/TINKERPOP-1976")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.step.map.PageRankTest",
         method = "*",
-        reason = "hmmmm")
+        reason = "https://issues.apache.org/jira/browse/TINKERPOP-1976")
 @Graph.OptOut(
         test = "org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategyProcessTest",
         method = "*",


[25/50] tinkerpop git commit: TINKERPOP-1878 Dropped the console app

Posted by sp...@apache.org.
TINKERPOP-1878 Dropped the console app

This allows TinkerGraph to remain a test dependency only and the console app was more of a test rig than something that a user of this library would use, so it seemed like something that could be dropped.


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

Branch: refs/heads/TINKERPOP-1878
Commit: ad8bba6097782f35d9ad7e626ed23e364532a7b1
Parents: c940117
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 14:49:18 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 sparql-gremlin/pom.xml                          |   1 +
 .../gremlin/sparql/ConsoleCompiler.java         | 165 -------------------
 2 files changed, 1 insertion(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ad8bba60/sparql-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/sparql-gremlin/pom.xml b/sparql-gremlin/pom.xml
index d38a85d..0dceb85 100644
--- a/sparql-gremlin/pom.xml
+++ b/sparql-gremlin/pom.xml
@@ -42,6 +42,7 @@
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>tinkergraph-gremlin</artifactId>
             <version>${project.version}</version>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ad8bba60/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java
deleted file mode 100644
index 0d50475..0000000
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java
+++ /dev/null
@@ -1,165 +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.sparql;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator;
-import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.io.IoCore;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-
-import org.apache.tinkerpop.gremlin.sparql.SparqlToGremlinCompiler;
-
-class ConsoleCompiler {
-
-    public static void main(final String[] args) throws IOException {
-    	//args = "/examples/modern1.sparql";
-        final Options options = new Options();
-        options.addOption("f", "file", true, "a file that contains a SPARQL query");
-        options.addOption("g", "graph", true, "the graph that's used to execute the query [classic|modern|crew|kryo file]");
-        // TODO: add an OLAP option (perhaps: "--olap spark"?)
-
-        final CommandLineParser parser = new DefaultParser();
-        final CommandLine commandLine;
-
-        try {
-            commandLine = parser.parse(options, args);
-        } catch (ParseException e) {
-            System.out.println(e.getMessage());
-            printHelp(1);
-            return;
-        }
-        
-        final InputStream inputStream = commandLine.hasOption("file")
-                ? new FileInputStream(commandLine.getOptionValue("file"))
-                : System.in;
-        final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
-        final StringBuilder queryBuilder = new StringBuilder();
-
-        if (!reader.ready()) {
-            printHelp(1);
-        }
-
-        String line;
-        while (null != (line = reader.readLine())) {
-            queryBuilder.append(System.lineSeparator()).append(line);
-        }
-
-        final String queryString = queryBuilder.toString();
-        Graph graph;
-        
-        if (commandLine.hasOption("graph")) {
-            switch (commandLine.getOptionValue("graph").toLowerCase()) {
-                case "classic":
-                    graph = TinkerFactory.createClassic();
-                    break;
-                case "modern":
-                    graph = TinkerFactory.createModern();
-                    System.out.println("Modern Graph Created");
-                    break;
-                case "crew":
-                    graph = TinkerFactory.createTheCrew();
-                    break;
-                default:
-                    graph = TinkerGraph.open();
-                    System.out.println("Graph Created");
-                    String graphName = commandLine.getOptionValue("graph");
-                    long startTime= System.currentTimeMillis();
-                    if(graphName.endsWith(".graphml"))
-                    	graph.io(IoCore.graphml()).readGraph(graphName);
-                    else if(graphName.endsWith(".kryo")||graphName.endsWith("gryo"))
-                    	graph.io(IoCore.gryo()).readGraph(graphName);
-                    long endTime = System.currentTimeMillis();
-                    System.out.println("Time taken to load graph from kyro file: "+ (endTime-startTime)+" mili seconds");
-                    break;
-            }
-        } else {
- 
-            graph = TinkerFactory.createModern();
-        }
-
-        long startTime = System.currentTimeMillis();
-        final Traversal<Vertex, ?> traversal = SparqlToGremlinCompiler.convertToGremlinTraversal(graph, queryString);
-        long endTime = System.currentTimeMillis();
-        System.out.println("Time traken to convert SPARQL to Gremlin Traversal : "+ (endTime - startTime)+ " miliseconds");
-        
-        printWithHeadline("SPARQL Query", queryString);
-        // printWithHeadline("Traversal (prior execution)", traversal);
-  
-        
-        Bytecode traversalByteCode = traversal.asAdmin().getBytecode();
-        
-        
-//        JavaTranslator.of(graph.traversal()).translate(traversalByteCode);
-//        
-//        System.out.println("the Byte Code : "+ traversalByteCode.toString());
-        printWithHeadline("Result", String.join(System.lineSeparator(),JavaTranslator.of(graph.traversal()).translate(traversalByteCode).toStream().map(Object::toString).collect(Collectors.toList())));
-        // printWithHeadline("Traversal (after execution)", traversal);
-    }
-
-    private static void printHelp(final int exitCode) throws IOException {
-        final Map<String, String> env = System.getenv();
-        final String command = env.containsKey("LAST_COMMAND") ? env.get("LAST_COMMAND") : "sparql-gremlin.sh";
-        printWithHeadline("Usage Examples", String.join("\n",
-                command + " -f examples/modern1.sparql",
-                command + " < examples/modern2.sparql",
-                command + " <<< 'SELECT * WHERE { ?a e:knows ?b }'",
-                command + " -g crew < examples/crew1.sparql"));
-        if (exitCode >= 0) {
-            System.exit(exitCode);
-        }
-    }
-
-    private static void printWithHeadline(final String headline, final Object content) throws IOException {
-        final StringReader sr = new StringReader(content != null ? content.toString() : "null");
-        final BufferedReader br = new BufferedReader(sr);
-        String line;
-        System.out.println();
-        System.out.println( headline ); 
-        System.out.println();
-        boolean skip = true;
-        while (null != (line = br.readLine())) {
-            skip &= line.isEmpty();
-            if (!skip) {
-                System.out.println("  " + line);
-            }
-        }
-        System.out.println();
-        br.close();
-        sr.close();
-    }
-}


[07/50] tinkerpop git commit: Bumped default Xmx on Gremlin Server

Posted by sp...@apache.org.
Bumped default Xmx on Gremlin Server

Seems like the default is too small for anything but the toy graphs and people getting started who aren't JVM experts keep running into problems CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: 2b045f30db0577464f1ff353464c7cf5d3c41746
Parents: 3b8c828
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 07:14:42 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 07:14:42 2018 -0400

----------------------------------------------------------------------
 gremlin-server/src/main/bin/gremlin-server.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2b045f30/gremlin-server/src/main/bin/gremlin-server.sh
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/bin/gremlin-server.sh b/gremlin-server/src/main/bin/gremlin-server.sh
index fcede2b..06b065a 100755
--- a/gremlin-server/src/main/bin/gremlin-server.sh
+++ b/gremlin-server/src/main/bin/gremlin-server.sh
@@ -50,7 +50,7 @@ fi
 
 # Set Java options
 if [ "$JAVA_OPTIONS" = "" ] ; then
-    JAVA_OPTIONS="-Xms32m -Xmx512m"
+    JAVA_OPTIONS="-Xms512m -Xmx4096m"
 fi
 
 # Execute the application and return its exit code


[08/50] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by sp...@apache.org.
Merge branch 'tp32' into tp33

Conflicts:
	gremlin-server/src/main/bin/gremlin-server.sh


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

Branch: refs/heads/TINKERPOP-1878
Commit: 88b6e143dd81134074c17e5fa098f03972514273
Parents: 7985106 2b045f3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 07:16:27 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 07:16:27 2018 -0400

----------------------------------------------------------------------
 gremlin-server/src/main/bin/gremlin-server.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/88b6e143/gremlin-server/src/main/bin/gremlin-server.sh
----------------------------------------------------------------------
diff --cc gremlin-server/src/main/bin/gremlin-server.sh
index fec465c,06b065a..a09e10c
--- a/gremlin-server/src/main/bin/gremlin-server.sh
+++ b/gremlin-server/src/main/bin/gremlin-server.sh
@@@ -90,191 -49,14 +90,191 @@@ els
  fi
  
  # Set Java options
 -if [ "$JAVA_OPTIONS" = "" ] ; then
 +if [[ "$JAVA_OPTIONS" = "" ]] ; then
-     JAVA_OPTIONS="-Xms32m -Xmx512m"
+     JAVA_OPTIONS="-Xms512m -Xmx4096m"
  fi
  
 -# Execute the application and return its exit code
 -if [ "$1" = "-i" ]; then
 -  shift
 -  exec $JAVA -Dlog4j.configuration=conf/log4j-server.properties $JAVA_OPTIONS -cp $CP:$CLASSPATH org.apache.tinkerpop.gremlin.server.util.GremlinServerInstall "$@"
 -else
 -  exec $JAVA -Dlog4j.configuration=conf/log4j-server.properties $JAVA_OPTIONS -cp $CP:$CLASSPATH org.apache.tinkerpop.gremlin.server.GremlinServer "$@"
 -fi
 +# Build Java CLASSPATH
 +CP="$GREMLIN_HOME/conf/"
 +CP="$CP":$( echo $GREMLIN_HOME/lib/*.jar . | sed 's/ /:/g')
 +CP="$CP":$( find -L "$GREMLIN_HOME"/ext -mindepth 1 -maxdepth 1 -type d | \
 +        sort | sed 's/$/\/plugin\/*/' | tr '\n' ':' )
 +
 +CLASSPATH="${CLASSPATH:-}:$CP"
 +
 +GREMLIN_SERVER_CMD=org.apache.tinkerpop.gremlin.server.GremlinServer
 +GREMLIN_INSTALL_CMD=org.apache.tinkerpop.gremlin.server.util.GremlinServerInstall
 +
 +
 +isRunning() {
 +  if [[ -r "$PID_FILE" ]] ; then
 +    PID=$(cat "$PID_FILE")
 +    ps -p "$PID" &> /dev/null
 +    return $?
 +  else
 +    return 1
 +  fi
 +}
 +
 +status() {
 +  isRunning
 +  RUNNING=$?
 +    if [[ $RUNNING -gt 0 ]]; then
 +      echo Server not running
 +    else
 +      echo Server running with PID $(cat "$PID_FILE")
 +    fi
 +}
 +
 +stop() {
 +  isRunning
 +  RUNNING=$?
 +  if [[ $RUNNING -gt 0 ]]; then
 +    echo Server not running
 +    rm -f "$PID_FILE"
 +  else
 +    kill "$PID" &> /dev/null || { echo "Unable to kill server [$PID]"; exit 1; }
 +    for i in $(seq 1 60); do
 +      ps -p "$PID" &> /dev/null || { echo "Server stopped [$PID]"; rm -f "$PID_FILE"; return 0; }
 +      [[ $i -eq 30 ]] && kill "$PID" &> /dev/null
 +      sleep 1
 +    done
 +    echo "Unable to kill server [$PID]";
 +    exit 1;
 +  fi
 +}
 +
 +start() {
 +  isRunning
 +  RUNNING=$?
 +  if [[ $RUNNING -eq 0 ]]; then
 +    echo Server already running with PID $(cat "$PID_FILE").
 +    exit 1
 +  fi
 +
 +  if [[ -z "$RUNAS" ]]; then
 +
 +    mkdir -p "$LOG_DIR" &>/dev/null
 +    if [[ ! -d "$LOG_DIR" ]]; then
 +      echo ERROR: LOG_DIR $LOG_DIR does not exist and could not be created.
 +      exit 1
 +    fi
 +
 +    mkdir -p "$PID_DIR" &>/dev/null
 +    if [[ ! -d "$PID_DIR" ]]; then
 +      echo ERROR: PID_DIR $PID_DIR does not exist and could not be created.
 +      exit 1
 +    fi
 +
 +    $JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_SERVER_CMD "$GREMLIN_YAML" >> "$LOG_FILE" 2>&1 &
 +    PID=$!
 +    disown $PID
 +    echo $PID > "$PID_FILE"
 +  else
 +
 +    su -c "mkdir -p $LOG_DIR &>/dev/null"  "$RUNAS"
 +    if [[ ! -d "$LOG_DIR" ]]; then
 +      echo ERROR: LOG_DIR $LOG_DIR does not exist and could not be created.
 +      exit 1
 +    fi
 +
 +    su -c "mkdir -p $PID_DIR &>/dev/null"  "$RUNAS"
 +    if [[ ! -d "$PID_DIR" ]]; then
 +      echo ERROR: PID_DIR $PID_DIR does not exist and could not be created.
 +      exit 1
 +    fi
 +
 +    su -c "$JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_SERVER_CMD \"$GREMLIN_YAML\" >> \"$LOG_FILE\" 2>&1 & echo \$! "  "$RUNAS" > "$PID_FILE"
 +    chown "$RUNAS" "$PID_FILE"
 +  fi
 +
 +  isRunning
 +  RUNNING=$?
 +  if [[ $RUNNING -eq 0 ]]; then
 +    echo Server started $(cat "$PID_FILE").
 +    exit 0
 +  else
 +    echo Server failed
 +    exit 1
 +  fi
 +
 +}
 +
 +startForeground() {
 +  isRunning
 +  RUNNING=$?
 +  if [[ $RUNNING -eq 0 ]]; then
 +    echo Server already running with PID $(cat "$PID_FILE").
 +    exit 1
 +  fi
 +
 +  if [[ -z "$RUNAS" ]]; then
 +    $JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_SERVER_CMD "$GREMLIN_YAML"
 +    exit 0
 +  else
 +    echo Starting in foreground not supported with RUNAS
 +    exit 1
 +  fi
 +
 +}
 +
 +install() {
 +
 +  isRunning
 +  RUNNING=$?
 +  if [[ $RUNNING -eq 0 ]]; then
 +    echo Server must be stopped before installing.
 +    exit 1
 +  fi
 +
 +  echo Installing dependency $@
 +
 +  DEPS="$@"
 +  if [[ -z "$RUNAS" ]]; then
 +    $JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH  $GREMLIN_INSTALL_CMD $DEPS
 +  else
 +    su -c "$JAVA -Dlog4j.configuration=$LOG4J_CONF $JAVA_OPTIONS -cp $CP:$CLASSPATH $GREMLIN_INSTALL_CMD $DEPS "  "$RUNAS"
 +  fi
 +
 +}
 +
 +case "$1" in
 +  status)
 +    status
 +    ;;
 +  restart)
 +    stop
 +    start
 +    ;;
 +  start)
 +    start
 +    ;;
 +  stop)
 +    stop
 +    ;;
 +  -i)
 +    shift
 +    echo "Redirecting to 'install $@' (-i will be removed in a future release)"
 +    install "$@"
 +    ;;
 +  install)
 +    shift
 +    install "$@"
 +    ;;
 +  console)
 +    startForeground
 +    ;;
 +  *)
 +    if [[ -n "$1" ]] ; then
 +      if [[ -r "$1" ]]; then
 +        GREMLIN_YAML="$1"
 +        startForeground
 +      elif [[ -r "$GREMLIN_HOME/$1" ]] ; then
 +        GREMLIN_YAML="$GREMLIN_HOME/$1"
 +        startForeground
 +      fi
 +      echo Configuration file not found.
 +    fi
 +    echo "Usage: $0 {start|stop|restart|status|console|install <group> <artifact> <version>|<conf file>}"; exit 1;
 +    ;;
 +esac


[31/50] tinkerpop git commit: TINKERPOP-1878 Added basic docs for sparql-gremlin

Posted by sp...@apache.org.
TINKERPOP-1878 Added basic docs for sparql-gremlin


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

Branch: refs/heads/TINKERPOP-1878
Commit: 8e6acf43d0bb5cf6ae7e546d40cb5422f8d17f53
Parents: a816dec
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 29 11:04:23 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 docs/preprocessor/install-plugins.sh    |  2 +-
 docs/src/reference/index.asciidoc       |  2 +
 docs/src/reference/transpilers.asciidoc | 66 ++++++++++++++++++++++++++++
 3 files changed, 69 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e6acf43/docs/preprocessor/install-plugins.sh
----------------------------------------------------------------------
diff --git a/docs/preprocessor/install-plugins.sh b/docs/preprocessor/install-plugins.sh
index 0a7ca31..f1da197 100755
--- a/docs/preprocessor/install-plugins.sh
+++ b/docs/preprocessor/install-plugins.sh
@@ -25,7 +25,7 @@ TMP_DIR=$3
 INSTALL_TEMPLATE="docs/preprocessor/install-plugins.groovy"
 INSTALL_FILE="${TMP_DIR}/install-plugins.groovy"
 
-plugins=("hadoop-gremlin" "spark-gremlin" "neo4j-gremlin")
+plugins=("hadoop-gremlin" "spark-gremlin" "neo4j-gremlin", "sparql-gremlin")
 # plugins=()
 pluginsCount=${#plugins[@]}
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e6acf43/docs/src/reference/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/index.asciidoc b/docs/src/reference/index.asciidoc
index 6e81bf2..02a218b 100644
--- a/docs/src/reference/index.asciidoc
+++ b/docs/src/reference/index.asciidoc
@@ -45,6 +45,8 @@ include::implementations-hadoop-end.asciidoc[]
 
 include::gremlin-variants.asciidoc[]
 
+include::transpilers.asciidoc[]
+
 include::conclusion.asciidoc[]
 
 include::acknowledgements.asciidoc[]

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e6acf43/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
new file mode 100644
index 0000000..305e3dc
--- /dev/null
+++ b/docs/src/reference/transpilers.asciidoc
@@ -0,0 +1,66 @@
+////
+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.
+////
+[[transpilers]]
+= Gremlin Transpilers
+
+There are many languages built to query data. SQL is typically used to query relational data. There is SPARQL for RDF
+data. Cypher is used to do pattern matching in graph data. The list could go on. Transpilers convert languages like
+these to Gremlin so that it becomes possible to use them in any context that Gremlin is used. In other words, a
+Gremlin Transpiler enables a particular query language to work on any TinkerPop-enabled graph system.
+
+== SPARQL-Gremlin
+
+[source,xml]
+----
+<dependency>
+   <groupId>org.apache.tinkerpop</groupId>
+   <artifactId>sparql-gremlin</artifactId>
+   <version>x.y.z</version>
+</dependency>
+----
+
+The SPARQL-Gremlin transpiler converts link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin so that
+they can be executed across any TinkerPop-enabled graph system. To use this transpiler in the Gremlin Console, first
+install and activate the "tinkerpop.sparql" plugin:
+
+[source,text]
+----
+gremlin> :install org.apache.tinkerpop sparql-gremlin x.y.z
+==>Loaded: [org.apache.tinkerpop, sparql-gremlin, x.y.z]
+gremlin> :plugin use tinkerpop.sparql
+==>tinkerpop.sparql activated
+----
+
+Installing this plugin will download appropriate dependencies and import certain classes to the console so that they
+may be used as follows:
+
+[gremlin-groovy,modern]
+----
+graph = TinkerFactory.createModern()
+g = graph.traversal(SparqlTraversalSource)                                                             <1>
+g.sparql("""SELECT ?name ?age
+            WHERE { ?person v:name ?name . ?person v:age ?age }
+            ORDER BY ASC(?age)""")                                                                     <2>
+----
+
+<1> Define `g` as a `TraversalSource` that uses the `SparqlTraversalSource` - by default, the `traversal()` method
+usually returns a `GraphTraversalSource` which includes the standard Gremlin starts steps like `V()` or `E()`. In this
+case, the `SparqlTraversalSource` enables starts steps that are specific to SPARQL only - in this case the `sparql()`
+start step.
+<2> Execute a SPARQL query against the TinkerGraph instance. The `SparqlTraversalSource` uses a
+<<traversalstrategy,TraversalStrategy>> to transparently converts that SPARQL query into a standard Gremlin traversal
+and then when finally iterated, executes that against the TinkerGraph.


[06/50] tinkerpop git commit: Merge branch 'tp33'

Posted by sp...@apache.org.
Merge branch 'tp33'


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

Branch: refs/heads/TINKERPOP-1878
Commit: 6358715e9dfa69627a425e4b930636f271141022
Parents: 9ab5efa 7985106
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 16:29:50 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 16:29:50 2018 -0400

----------------------------------------------------------------------
 docs/src/recipes/element-existence.asciidoc | 91 ++++++++++++++++++++++++
 docs/src/recipes/index.asciidoc             |  2 +
 2 files changed, 93 insertions(+)
----------------------------------------------------------------------



[04/50] tinkerpop git commit: Added "get or create" or "upsert" recipe CTR

Posted by sp...@apache.org.
Added "get or create" or "upsert" recipe CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: 3b8c8280cab1e7a6fd3b273ef0d2cf2c6d00f650
Parents: dde73e4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 16:29:11 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 16:29:11 2018 -0400

----------------------------------------------------------------------
 docs/src/recipes/element-existence.asciidoc | 91 ++++++++++++++++++++++++
 docs/src/recipes/index.asciidoc             |  2 +
 2 files changed, 93 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3b8c8280/docs/src/recipes/element-existence.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/element-existence.asciidoc b/docs/src/recipes/element-existence.asciidoc
new file mode 100644
index 0000000..be6e517
--- /dev/null
+++ b/docs/src/recipes/element-existence.asciidoc
@@ -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.
+////
+[[element-existence]]
+== Element Existence
+
+Checking for whether or not a graph element is present in the graph is simple:
+
+[gremlin-groovy,modern]
+----
+g.V().has('person','name','marko').hasNext()
+g.V().has('person','name','stephen').hasNext()
+----
+
+Knowing that an element exists or not is usually a common point of decision in determining the appropriate path of code
+to take. In the example above, the check is for vertex existence and a typical reason to check for existence is to
+determine whether or not to add a new vertex or to return the one that exists (i.e. "get or create" pattern). This
+entire operation can occur in a single traversal.
+
+[gremlin-groovy,modern]
+----
+g.V().has('person','name','marko').
+  fold().
+  coalesce(unfold(),
+           addV('person').
+             property('name','marko').
+             property('age',29))
+g.V().has('person','name','stephen').
+  fold().
+  coalesce(unfold(), 
+           addV('person').
+             property('name','stephen').
+             property('age',34))
+----
+
+This use of `coalesce()` shown above is the basis for this pattern. Note that at the end of `has()`-step there is
+either a vertex or not. By using `fold()`, "existence" or "not existence" is reduced to a `List` with the vertex or
+a `List` with no values. With a `List` as the traverser flowing into `coalesce()` the first child traversal to return
+something will execute. If the `List` has a vertex then it will `unfold()` and return the existing one. If it is empty,
+then the vertex does not exist and it is added and returned.
+
+This "get or create" logic can be expanded to be "upsert" like functionality as follows:
+
+[gremlin-groovy,modern]
+----
+g.V().has('person','name','marko').
+  fold().
+  coalesce(unfold(),
+           addV('person').property('name','marko')).
+  property('age',29)
+g.V().has('person','name','stephen').
+  fold().
+  coalesce(unfold(),
+           addV('person').property('name','stephen')).
+  property('age',34)
+----
+
+By moving the `property()`-step that set the "age" value outside of `coalesce()`, the property is then set for both
+newly created vertices and for existing ones.
+
+WARNING: Always consider the specific nature of the graph implementation in use when considering these patterns. Some
+graph databases may not treat these traversals as true "upsert" operations and may do a "read before write" in their
+execution.
+
+It is possible to do similar sorts of operations with edges using the same pattern:
+
+[gremlin-groovy,modern]
+----
+g.V().has('person','name','vadas').as('v').
+  V().has('software','name','ripple').
+  coalesce(__.inE('created').where(outV().as('v')),
+           addE('created').from('v').property('weight',0.5))
+----
+
+In this case, the adjacent vertices of the edge are retrieved first and within the `coalesce()`, the existence of
+the edge is checked with `where()` using a matching pattern on the "v" label and returned if found. If the edge is not
+found between these two vertices, then it is created as part of the second traversal given to `coalesce()`.
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3b8c8280/docs/src/recipes/index.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/recipes/index.asciidoc b/docs/src/recipes/index.asciidoc
index c59cc89..8886289 100644
--- a/docs/src/recipes/index.asciidoc
+++ b/docs/src/recipes/index.asciidoc
@@ -50,6 +50,8 @@ include::duplicate-vertex.asciidoc[]
 
 include::edge-move.asciidoc[]
 
+include::element-existence.asciidoc[]
+
 include::if-then-based-grouping.asciidoc[]
 
 include::pagination.asciidoc[]


[41/50] tinkerpop git commit: TINKERPOP-1878 Added a test for ordering and corrected some problems in logic

Posted by sp...@apache.org.
TINKERPOP-1878 Added a test for ordering and corrected some problems in logic

Ordering didn't work - at least not completely. The test, as it is written in this commit, that failed to sort properly. Changed the logic for ordering to track all of the keys specified to ORDER with their appropriate ASC/DESC operators and added all of them to the traversal.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 87ccf5833e84cc490d2aa94d3eac472f4a4288ab
Parents: 456cdcf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 15:41:10 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../sparql/SparqlToGremlinTranspiler.java       | 55 ++++++--------------
 .../dsl/sparql/SparqlTraversalSourceTest.java   | 31 +++++++++--
 2 files changed, 44 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/87ccf583/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
index 9db7d82..ea3f828 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
@@ -21,9 +21,10 @@ package org.apache.tinkerpop.gremlin.sparql;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.jena.graph.Triple;
 import org.apache.jena.query.Query;
 import org.apache.jena.query.QueryFactory;
 import org.apache.jena.query.SortCondition;
@@ -58,8 +59,6 @@ public class SparqlToGremlinTranspiler {
 
     private List<Traversal> traversalList = new ArrayList<>();
 
-    private String sortingVariable = "";
-
 	private SparqlToGremlinTranspiler(final GraphTraversal<Vertex, ?> traversal) {
 		this.traversal = traversal;
 	}
@@ -96,31 +95,18 @@ public class SparqlToGremlinTranspiler {
 		final int numberOfTraversal = traversalList.size();
         final Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
 
-		if (query.hasOrderBy() && !query.hasGroupBy()) {
-            final List<SortCondition> sortingConditions = query.getOrderBy();
-
-			for (SortCondition sortCondition : sortingConditions) {
-                final Expr expr = sortCondition.getExpression();
-				sortingVariable = expr.getVarName();
-			}
-		}
-
 		for (Traversal tempTrav : traversalList) {
 			arrayOfAllTraversals[traversalIndex++] = tempTrav;
 		}
 
-		Order orderDirection = Order.incr;
+		final Map<String, Order> orderingIndex = new HashMap<>();
 		if (query.hasOrderBy()) {
-            int directionOfSort = 0;
             final List<SortCondition> sortingConditions = query.getOrderBy();
 
 			for (SortCondition sortCondition : sortingConditions) {
                 final Expr expr = sortCondition.getExpression();
-				directionOfSort = sortCondition.getDirection();
-				sortingVariable = expr.getVarName();
+                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == 1 ? Order.incr : Order.decr);
 			}
-
-			if (directionOfSort == -1) orderDirection = Order.decr;
 		}
 
 		if (traversalList.size() > 0)
@@ -128,6 +114,8 @@ public class SparqlToGremlinTranspiler {
 
 		final List<String> vars = query.getResultVars();
 		if (!query.isQueryResultStar() && !query.hasGroupBy()) {
+		    // the result sizes have special handling to get the right signatures of select() called. perhaps this
+            // could be refactored to work more nicely
             switch (vars.size()) {
                 case 0:
                     throw new IllegalStateException();
@@ -135,20 +123,16 @@ public class SparqlToGremlinTranspiler {
                     if (query.isDistinct())
                         traversal = traversal.dedup(vars.get(0));
 
-                    if (query.hasOrderBy())
-                        traversal = traversal.order().by(sortingVariable, orderDirection);
-                    else
-                        traversal = traversal.select(vars.get(0));
+                    orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+                    traversal = traversal.select(vars.get(0));
 
                     break;
                 case 2:
                     if (query.isDistinct())
                         traversal = traversal.dedup(vars.get(0), vars.get(1));
 
-                    if (query.hasOrderBy())
-                        traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
-                    else
-                        traversal = traversal.select(vars.get(0), vars.get(1));
+                    orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+                    traversal = traversal.select(vars.get(0), vars.get(1));
 
                     break;
                 default:
@@ -157,11 +141,11 @@ public class SparqlToGremlinTranspiler {
                     if (query.isDistinct())
                         traversal = traversal.dedup(all);
 
+                    orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
+
+                    // just some shenanigans to get the right signature of select() called
                     final String[] others = Arrays.copyOfRange(all, 2, vars.size());
-                    if (query.hasOrderBy())
-                        traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
-                    else
-                        traversal = traversal.select(vars.get(0), vars.get(1), others);
+                    traversal = traversal.select(vars.get(0), vars.get(1), others);
 
                     break;
             }
@@ -202,7 +186,7 @@ public class SparqlToGremlinTranspiler {
 		}
 
 		if (query.hasOrderBy() && query.hasGroupBy())
-			traversal = traversal.order().by(sortingVariable, orderDirection);
+            orderingIndex.forEach((k,v) -> traversal = traversal.order().by(__.select(k), v));
 
 		if (query.hasLimit()) {
 			long limit = query.getLimit(), offset = 0;
@@ -233,14 +217,7 @@ public class SparqlToGremlinTranspiler {
          */
         @Override
         public void visit(final OpBGP opBGP) {
-            final List<Triple> triples = opBGP.getPattern().getList();
-            final Traversal[] matchTraversals = new Traversal[triples.size()];
-            int i = 0;
-            for (final Triple triple : triples) {
-
-                matchTraversals[i++] = TraversalBuilder.transform(triple);
-                traversalList.add(matchTraversals[i - 1]);
-            }
+            opBGP.getPattern().getList().forEach(triple -> traversalList.add(TraversalBuilder.transform(triple)));
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/87ccf583/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
index 9bb6025..2743255 100644
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -27,16 +27,18 @@ import java.util.List;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class SparqlTraversalSourceTest {
 
+    private static final Graph graph = TinkerFactory.createModern();
+    private static final SparqlTraversalSource g = graph.traversal(SparqlTraversalSource.class);
+
     @Test
-    public void shouldDoStuff() {
-        final Graph graph = TinkerFactory.createModern();
-        final SparqlTraversalSource g = graph.traversal(SparqlTraversalSource.class);
+    public void shouldFindAllPersonsNamesAndAges() {
         final List<?> x = g.sparql("SELECT ?name ?age WHERE { ?person v:name ?name . ?person v:age ?age }").toList();
         assertThat(x, containsInAnyOrder(
                 new HashMap<String,Object>(){{
@@ -57,4 +59,27 @@ public class SparqlTraversalSourceTest {
                 }}
         ));
     }
+
+    @Test
+    public void shouldFindAllPersonsNamesAndAgesOrdered() {
+        final List<?> x = g.sparql("SELECT ?name ?age WHERE { ?person v:name ?name . ?person v:age ?age } ORDER BY ASC(?age)").toList();
+        assertThat(x, contains(
+                new HashMap<String,Object>(){{
+                    put("name", "vadas");
+                    put("age", 27);
+                }},
+                new HashMap<String,Object>(){{
+                    put("name", "marko");
+                    put("age", 29);
+                }},
+                new HashMap<String,Object>(){{
+                    put("name", "josh");
+                    put("age", 32);
+                }},
+                new HashMap<String,Object>(){{
+                    put("name", "peter");
+                    put("age", 35);
+                }}
+        ));
+    }
 }


[48/50] tinkerpop git commit: Update compilers.asciidoc

Posted by sp...@apache.org.
Update compilers.asciidoc

Updating documentation:
- fixed optional clause 
- updated optional clause limitation while in nesting with union & order-by
- went through other examples and limitations

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

Branch: refs/heads/TINKERPOP-1878
Commit: fafda957f8d22c399f8c463ae249bdb5bcbfab8d
Parents: 4a08ffc
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Aug 1 11:27:59 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:37:35 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/compilers.asciidoc | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fafda957/docs/src/reference/compilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/compilers.asciidoc b/docs/src/reference/compilers.asciidoc
index e015cc8..5b6ab2e 100644
--- a/docs/src/reference/compilers.asciidoc
+++ b/docs/src/reference/compilers.asciidoc
@@ -206,9 +206,8 @@ WHERE { ?person v:label "person" . ?person v:age ?age . ?person v:name ?name . }
 The the variable encountered first will be the ordering decider, i.e. since we have `?person` being encountered first, the result set will be ordered according to the `?person` variable (which are vertex id).
 
 * OPTIONAL
-....
-currently fixing this...
-....
+In the current implementation, `OPTIONAL` clause doesn't work under nesting with `UNION` clause (i.e. multiple optional clauses with in a union clause) and `ORDER-By` clause (i.e. declaring ordering over triple patterns within optional clauses). Everything else with SPARQL `OPTIONAL` works just fine.
+
 
 [[examples]]
 === Examples


[09/50] tinkerpop git commit: Merge branch 'tp33'

Posted by sp...@apache.org.
Merge branch 'tp33'


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

Branch: refs/heads/TINKERPOP-1878
Commit: 4dccf144c71603612ce976827fd24c3eead4fb24
Parents: 6358715 88b6e14
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 07:16:33 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 07:16:33 2018 -0400

----------------------------------------------------------------------
 gremlin-server/src/main/bin/gremlin-server.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[45/50] tinkerpop git commit: Update transpilers.asciidoc

Posted by sp...@apache.org.
Update transpilers.asciidoc

Changes:
- fixed non-working queries (queries which returned no results)
- updated documentation with more examples in the limitations section
- updated execution tags for queries which are for reference only
- commented out the pattern filter examples for now

To Do:
- fix OPTIONAL queries 
- fix Pattern filter queries
- inspect and patch special cases in code

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

Branch: refs/heads/TINKERPOP-1878
Commit: c322416e27712df797c566622f6272fef2d63565
Parents: 4fc2b0d
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Fri Jun 15 11:24:57 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:07 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 94 +++++++++++++++++++++-------
 1 file changed, 72 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c322416e/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index 3211857..1bb7728 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -131,7 +131,7 @@ The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) do
 * SPARQL queries with variables in the predicate position are not currently covered, with an exception of the following
 case:
 
-[source,groovy]
+[source,text]
 ----
 g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
 ----
@@ -141,24 +141,72 @@ SPARQL query has the same number of patterns on both the side of the union opera
 SPARQL query cannot be mapped using Gremlinator, since a union is executed between different number of graph patterns
 (two patterns `union` 1 pattern).
 
-[source,groovy]
+[source,text]
 ----
-g.sparql("""SELECT * 
-	WHERE {
-	{?person e:created ?software . 
-	?person v:name "daniel" .}
+g.sparql("""SELECT * WHERE {
+	{?person e:created ?software .
+	?person v:name "josh" .}
 	UNION
 	{?software v:lang "java" .} }""")
 ----
 
-* order by
-....
-Adding more here...
-....
+* A non-Group key variable cannot be projected in a SPARQL query. This is a SPARQL langauge limitation rather than that of Gremlin/TinkerPop. Apache Jena throws the exception " Non-group key variable in SELECT" if this occurs.
+For instance, in a SPARQL query with GROUP-BY clause, only the variable on which the grouping is declared, can be projected. The following query is valid:
+
+[source,groovy]
+----
+g.sparql("""SELECT ?age WHERE {
+    ?person v:label "person" .
+    ?person v:age ?age .
+    ?person v:name ?name .} GROUP BY (?age)""")
+----
+
+Whereas, the following SPARQL query will be invalid:
+
+[source,text]
+----
+g.sparql("""SELECT ?person WHERE {
+      ?person v:label "person" .
+      ?person v:age ?age .
+      ?person v:name ?name .} GROUP BY (?age)""")
+----
+
+
+* In a SPARQL query with an ORDER-BY clause, the ordering occurs wrt to the first projected variable in the query. You may choose any number of variable to be projected, however, the first variable in the selection will be the ordering decider.
+For instance, in the query:
+
+
+[source,groovy]
+----
+g.sparql("""SELECT ?name ?age WHERE {
+    ?person v:label "person" .
+    ?person v:age ?age .
+    ?person v:name ?name . } ORDER BY (?age)""")
+----
 
-* group by
+the result set will be ordered according to the `?name` variable (in ascending order by default) despite having passed `?age` in the order by. Whereas, for the following query:
+
+[source,groovy]
+----
+g.sparql("""SELECT ?age ?name WHERE {
+    ?person v:label "person" .
+    ?person v:age ?age .
+    ?person v:name ?name . } ORDER BY (?age)""")
+----
+
+the result set will be ordered according to the `?age` (as it is the first projected variable). Finally, for the select all case (`SELECT *`):
+
+[source,groovy]
+----
+g.sparql("""SELECT *
+WHERE { ?person v:label "person" . ?person v:age ?age . ?person v:name ?name . } ORDER BY (?age)""")
+----
+
+The the variable encountered first will be the ordering decider, i.e. since we have `?person` being encountered first, the result set will be ordered according to the `?person` variable (which are vertex id).
+
+* OPTIONAL
 ....
-Adding more here...
+currently fixing this...
 ....
 
 [[examples]]
@@ -264,6 +312,7 @@ WHERE {
     FILTER (?age > 30 && ?lang = "java") }""")
 ----
 
+////
 [[pattern-filters]]
 ==== Pattern Filter(s)
 
@@ -288,6 +337,7 @@ WHERE {
   ?person v:name ?name .
     FILTER NOT EXISTS { ?person e:created ?project } }""")
 ----
+////
 
 [[union]]
 ==== Union
@@ -325,11 +375,12 @@ Select all vertices with the label `person` and order them by their age.
 
 [gremlin-groovy,existing]
 ----
-g.sparql("""SELECT * 
+g.sparql("""SELECT ?age ?name
 WHERE {
   ?person v:label "person" .
   ?person v:age ?age .
-} ORDER BY (?age)""")
+  ?person v:name ?name .
+} ORDER BY (?age))
 ----
 
 [[group-by]]
@@ -337,9 +388,9 @@ WHERE {
 
 Select all vertices with the label `person` and group them by their age.
 
-[source,groovy]
+[gremlin-groovy,existing]
 ----
-g.sparql("""SELECT * 
+g.sparql("""SELECT ?age 
 WHERE {
   ?person v:label "person" .
   ?person v:age ?age .
@@ -354,7 +405,7 @@ the top two.
 
 [source,groovy]
 ----
-g.sparql("""SELECT COUNT(?project) 
+g.sparql("""SELECT (COUNT(?project) as ?p)
 WHERE {
   ?person v:label "person" .
   ?person v:age ?age . FILTER (?age < 30)
@@ -388,12 +439,11 @@ can be perceived as path queries or neighborhood queries. For instance, getting
 
 [gremlin-groovy,existing]
 ----
-g.sparql("""SELECT ?age ?software ?name ?location ?startTime 
+g.sparql("""SELECT ?age ?software ?lang ?name
 WHERE {
-  ?person v:name "daniel" .
+  ?person v:name "josh" .
   ?person v:age ?age .
   ?person e:created ?software .
-  ?person p:location ?location .
-  ?location v:value ?name .
-  ?location v:startTime ?startTime }""")
+  ?software v:lang ?lang .
+  ?software v:name ?name . }""")
 ----


[43/50] tinkerpop git commit: TINKERPOP-1878 Clean up docs a bit more.

Posted by sp...@apache.org.
TINKERPOP-1878 Clean up docs a bit more.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 5c82aa1d7629bfd3d64fd76257fe19c848c67ebb
Parents: 9d153af
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun May 13 10:53:56 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 36 +++++++++++++---------------
 1 file changed, 16 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5c82aa1d/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index b05be68..390d4f4 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -24,23 +24,20 @@ Gremlin Transpiler enables a particular query language to work on any TinkerPop-
 
 == SPARQL-Gremlin
 
-image:https://raw.githubusercontent.com/LITMUS-Benchmark-Suite/sparql-to-gremlin/master/docs/images/sparql-gremlin-logo.png[gremlinator]
+image::gremlin-standing.png[]
 
-The SPARQL-Gremlin transpiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin traversals. It is based on the  https://jena.apache.org/index.html[Apache Jena] SPARQL processor https://jena.apache.org/documentation/query/index.html[ARQ], which provides access to a syntax tree of a SPARQL query.
+The SPARQL-Gremlin transpiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin
+traversals. It uses the https://jena.apache.org/index.html[Apache Jena] SPARQL processor
+link:https://jena.apache.org/documentation/query/index.html[ARQ], which provides access to a syntax tree of a
+SPARQL query.
 
+The goal of this work is to bridge the query interoperability gap between the two famous, yet fairly disconnected,
+graph communities: Semantic Web (which relies on the RDF data model) and Graph database (which relies on property graph
+data model).
 
-The goal of this work is to bridge the query interoperability gap between the two famous, yet fairly disconnected, graph communities: Semantic Web (which relies on the RDF data model) and Graph database
-(which relies on Property graph data model).
-
-NOTE: The foundational research work on SPARQL-Gremlin transpiler (aka Gremlinator) can be found from -
-https://arxiv.org/pdf/1801.02911.pdf[Gremlinator full paper]. In this
-paper, we present and discuss the notion of graph query language
-semantics of SPARQL and Gremlin, and a formal mapping between SPARQL
-pattern matching graph patterns and Gremlin traversals. Furthermore, we
-point the interested reader to the following resourcesfor a better
-understanding: (1) Gremlinator demonstration -
-(http://gremlinator.iai.uni-bonn.de:8080/Demo/[Public Demo Mirror 1])
-and (http://195.201.31.31:8080/Demo/[Public Demo Mirror 2]); (2) A short video tutorial on how to use the demonstration - https://www.youtube.com/watch?v=Z0ETx2IBamw[here]
+NOTE: The foundational research work on SPARQL-Gremlin transpiler (aka Gremlinator) can be found in the
+link:https://arxiv.org/pdf/1801.02911.pdf[Gremlinator paper]. This paper presents the graph query language semantics of
+SPARQL and Gremlin, and a formal mapping between SPARQL pattern matching graph patterns and Gremlin traversals.
 
 [source,xml]
 ----
@@ -111,9 +108,9 @@ g.sparql("""SELECT ?name ?id ?label
 [[supported-queries]]
 === Supported Queries
 
-The SPARQL-Gremlin transpiler is currently an on-going effort with an aim to cover the entire SPARQL 1.1 query feature
-spectrum, however we currently only support translation of the SPARQL 1.0 specification, especially _SELECT_ queries.
-The supported SPARQL query types are:
+The SPARQL-Gremlin transpiler currently supports translation of the SPARQL 1.0 specification, especially `SELECT`
+queries, though there is an on-going effort to cover the entire SPARQL 1.1 query feature spectrum. The supported
+SPARQL query types are:
 
 * Union 
 * Optional 
@@ -129,8 +126,7 @@ The supported SPARQL query types are:
 [[limitations]]
 === Limitations
 
-The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) does
-not support the following cases: 
+The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) does not support the following cases:
 
 * SPARQL queries with variables in the predicate position are not currently covered, with an exception of the following
 case:
@@ -143,7 +139,7 @@ g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
 * A SPARQL Union query with un-balanced patterns, i.e. a gremlin union traversal can only be generated if the input
 SPARQL query has the same number of patterns on both the side of the union operator. For instance, the following
 SPARQL query cannot be mapped using Gremlinator, since a union is executed between different number of graph patterns
-(two patterns _union_ 1 pattern).
+(two patterns `union` 1 pattern).
 
 [source,groovy]
 ----


[34/50] tinkerpop git commit: TINKERPOP-1878 Fixed up formatting of traspiler section

Posted by sp...@apache.org.
TINKERPOP-1878 Fixed up formatting of traspiler section

There were some examples that didn't return results or generated errors. These will need some review.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 9d153af999298d546bb6feacfc08be1038c4d50e
Parents: 781bfdc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Apr 3 10:52:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 156 ++++++++++++---------------
 1 file changed, 71 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9d153af9/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index 386b4a5..b05be68 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -84,8 +84,7 @@ start step.
 and then when finally iterated, executes that against the TinkerGraph.
 
 [[prefixes]]
-Prefixes
-~~~~~~~~~
+=== Prefixes
 
 The SPARQL-Gremlin transpiler supports the following prefixes to traverse the graph:
 
@@ -110,10 +109,11 @@ g.sparql("""SELECT ?name ?id ?label
 ----
 
 [[supported-queries]]
-Supported Queries
-~~~~~~~~~~~~~~~~~~
+=== Supported Queries
 
-The SPARQL-Gremlin transpiler is currently an on-going effort with an aim to cover the entire SPARQL 1.1 query feature spectrum, however we currently only support translation of the SPARQL 1.0 specification, especially _SELECT_ queries. The supported SPARQL query types are: 
+The SPARQL-Gremlin transpiler is currently an on-going effort with an aim to cover the entire SPARQL 1.1 query feature
+spectrum, however we currently only support translation of the SPARQL 1.0 specification, especially _SELECT_ queries.
+The supported SPARQL query types are:
 
 * Union 
 * Optional 
@@ -127,29 +127,25 @@ The SPARQL-Gremlin transpiler is currently an on-going effort with an aim to cov
 ** OFFSET
 
 [[limitations]]
-Limitations
-~~~~~~~~~~~~
+=== Limitations
 
 The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) does
 not support the following cases: 
 
-* SPARQL queries with variables in the
-predicate position are not currently covered, with an exception of the
-following case:
+* SPARQL queries with variables in the predicate position are not currently covered, with an exception of the following
+case:
 
-[gremlin-groovy,existing]
+[source,groovy]
 ----
 g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
 ----
 
-* A SPARQL Union query with un-balanced patterns, i.e. a gremlin union
-traversal can only be generated if the unput SPARQL query has the same
-number of patterns on both the side of the union operator. For instance,
-the following SPARQL query cannot be mapped using Gremlinator, since a
-union is executed between different number of graph patterns (two
-patterns _union_ 1 pattern).
+* A SPARQL Union query with un-balanced patterns, i.e. a gremlin union traversal can only be generated if the input
+SPARQL query has the same number of patterns on both the side of the union operator. For instance, the following
+SPARQL query cannot be mapped using Gremlinator, since a union is executed between different number of graph patterns
+(two patterns _union_ 1 pattern).
 
-[gremlin-groovy,existing]
+[source,groovy]
 ----
 g.sparql("""SELECT * 
 	WHERE {
@@ -170,16 +166,15 @@ Adding more here...
 ....
 
 [[examples]]
-Examples
-~~~~~~~~~
+=== Examples
 
-The following section presents a comprehensive examples of SPARQL queries that are currently covered by the SPARQL-Gremlin transpiler.
+The following section presents a comprehensive examples of SPARQL queries that are currently covered by the
+SPARQL-Gremlin transpiler.
 
 [[select-all]]
-Select All
-^^^^^^^^^^
+==== Select All
 
-.Select all vertices in the graph.
+Select all vertices in the graph.
 
 [gremlin-groovy,existing]
 ----
@@ -187,10 +182,9 @@ g.sparql("""SELECT * WHERE { }""")
 ----
 
 [[match-constant-values]]
-Match Constant Values
-^^^^^^^^^^^^^^^^^^^^^
+==== Match Constant Values
 
-.Select all vertices with the label `person`.
+Select all vertices with the label `person`.
 
 [gremlin-groovy,existing]
 ----
@@ -198,10 +192,9 @@ g.sparql("""SELECT * WHERE {  ?person v:label "person" .}""")
 ----
 
 [[select-specific-elements]]
-Select Specific Elements
-^^^^^^^^^^^^^^^^^^^^^^^^
+==== Select Specific Elements
 
-.Select the values of the properties `name` and `age` for each `person` vertex.
+Select the values of the properties `name` and `age` for each `person` vertex.
 
 [gremlin-groovy,existing]
 ----
@@ -213,10 +206,9 @@ WHERE {
 ----
 
 [[pattern-matching]]
-Pattern Matching
-^^^^^^^^^^^^^^^^
+==== Pattern Matching
 
-.Select only those persons who created a project.
+Select only those persons who created a project.
 
 [gremlin-groovy,existing]
 ----
@@ -229,10 +221,9 @@ WHERE {
 ----
 
 [[filtering]]
-Filtering
-^^^^^^^^^
+==== Filtering
 
-.Select only those persons who are older than 30.
+Select only those persons who are older than 30.
 
 [gremlin-groovy,existing]
 ----
@@ -241,31 +232,29 @@ WHERE {
   ?person v:label "person" .
   ?person v:name ?name .
   ?person v:age ?age .
-  ?person e:created ?project .
     FILTER (?age > 30) }""")
 ----
 
 [[deduplication]]
-Deduplication
-^^^^^^^^^^^^^
+==== Deduplication
 
-.Select the distinct names of the created projects.
+Select the distinct names of the created projects.
 
 [gremlin-groovy,existing]
 ----
 g.sparql("""SELECT DISTINCT ?name
 WHERE {
   ?person v:label "person" .
+  ?person v:age ?age .
   ?person e:created ?project .
   ?project v:name ?name .
     FILTER (?age > 30)}""")
 ----
 
 [[multiple-filters]]
-Multiple Filters
-^^^^^^^^^^^^^^^^
+==== Multiple Filters
 
-.Select the distinct names of all Java projects.
+Select the distinct names of all Java projects.
 
 [gremlin-groovy,existing]
 ----
@@ -276,14 +265,13 @@ WHERE {
   ?person e:created ?project .
   ?project v:name ?name .
   ?project v:lang ?lang .
-    FILTER (?age > 30 && ?lang == "java") }""")
+    FILTER (?age > 30 && ?lang = "java") }""")
 ----
 
 [[pattern-filters]]
-Pattern Filter(s)
-^^^^^^^^^^^^^^^^^
+==== Pattern Filter(s)
 
-.A different way to filter all person who created a project.
+A different way to filter all person who created a project.
 
 [gremlin-groovy,existing]
 ----
@@ -294,7 +282,7 @@ WHERE {
     FILTER EXISTS { ?person e:created ?project } }""")
 ----
 
-.Filter all person who did not create a project.
+Filter all person who did not create a project.
 
 [gremlin-groovy,existing]
 ----
@@ -305,27 +293,10 @@ WHERE {
     FILTER NOT EXISTS { ?person e:created ?project } }""")
 ----
 
-[[meta-property-access]]
-Meta-Property Access
-^^^^^^^^^^^^^^^^^^^^
-
-.Accessing the Meta-Property of a graph element. Meta-Property can be perceived as the reified statements in an RDF graph.
-
-[gremlin-groovy,existing]
-----
-g.sparql("""SELECT ?name ?startTime
-WHERE {
-  ?person v:name "daniel" .
-  ?person p:location ?location .
-  ?location v:value ?name .
-  ?location v:startTime ?startTime }""")
-----
-
 [[union]]
-Union
-^^^^^
+==== Union
 
-.Select all persons who have developed a software in java using union.
+Select all persons who have developed a software in java using union.
 
 [gremlin-groovy,existing]
 ----
@@ -337,12 +308,11 @@ WHERE {
 ----
 
 [[optional]]
-Optional
-^^^^^^^^
+==== Optional
 
-.Return the names of the persons who have created a software in java and optionally python.
+Return the names of the persons who have created a software in java and optionally python.
 
-[gremlin-groovy,existing]
+[source,groovy]
 ----
 g.sparql("""SELECT ?person 
 WHERE {
@@ -353,10 +323,9 @@ WHERE {
 ----
 
 [[order-by]]
-Order By
-^^^^^^^^
+==== Order By
 
-.Select all vertices with the label `person` and order them by their age.
+Select all vertices with the label `person` and order them by their age.
 
 [gremlin-groovy,existing]
 ----
@@ -368,12 +337,11 @@ WHERE {
 ----
 
 [[group-by]]
-Group By
-^^^^^^^^
+==== Group By
 
-.Select all vertices with the label `person` and group them by their age.
+Select all vertices with the label `person` and group them by their age.
 
-[gremlin-groovy,existing]
+[source,groovy]
 ----
 g.sparql("""SELECT * 
 WHERE {
@@ -383,12 +351,12 @@ WHERE {
 ----
 
 [[mixedcomplexaggregation-based-queries]]
-Mixed/complex/aggregation-based queries
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+==== Mixed/complex/aggregation-based queries
 
-.Count the number of projects which have been created by persons under the age of 30 and group them by age. Return only the top two.
+Count the number of projects which have been created by persons under the age of 30 and group them by age. Return only
+the top two.
 
-[gremlin-groovy,existing]
+[source,groovy]
 ----
 g.sparql("""SELECT COUNT(?project) 
 WHERE {
@@ -398,11 +366,29 @@ WHERE {
 } GROUP BY (?age) LIMIT 2""")
 ----
 
+[[meta-property-access]]
+==== Meta-Property Access
+
+Accessing the Meta-Property of a graph element. Meta-Property can be perceived as the reified statements in an RDF
+graph.
+
+[gremlin-groovy,theCrew]
+----
+g = graph.traversal(SparqlTraversalSource)
+g.sparql("""SELECT ?name ?startTime
+WHERE {
+  ?person v:name "daniel" .
+  ?person p:location ?location .
+  ?location v:value ?name .
+  ?location v:startTime ?startTime }""")
+----
+
 [[star-shaped-queries]]
-STAR-shaped queries
-^^^^^^^^^^^^^^^^^^^
+==== STAR-shaped queries
 
-.STAR-shaped queries are the queries that form/follow a star-shaped execution plan. These in terms of graph traversals can be perceived as path queries or neighbourhood queries. For instance, getting all the information about a specific `person` or `software`.
+STAR-shaped queries are the queries that form/follow a star-shaped execution plan. These in terms of graph traversals
+can be perceived as path queries or neighborhood queries. For instance, getting all the information about a specific
+`person` or `software`.
 
 [gremlin-groovy,existing]
 ----


[22/50] tinkerpop git commit: Initial commit for sparql-gremlin changes

Posted by sp...@apache.org.
Initial commit for sparql-gremlin changes


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

Branch: refs/heads/TINKERPOP-1878
Commit: c4244ce47387fbe45e7ce26915a5ba418fc30725
Parents: b183edd
Author: harsh9t <ha...@gmail.com>
Authored: Thu Jan 18 01:33:29 2018 +0100
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 sparql-gremlin/pom.xml                          |  63 +++
 .../gremlin/sparql/ConsoleCompiler.java         | 165 ++++++++
 .../tinkerpop/gremlin/sparql/Prefixes.java      |  64 ++++
 .../gremlin/sparql/SparqlToGremlinCompiler.java | 381 +++++++++++++++++++
 .../gremlin/sparql/TraversalBuilder.java        |  82 ++++
 .../gremlin/sparql/WhereTraversalBuilder.java   | 134 +++++++
 .../tinkerpop/gremlin/sparql/PrefixesTest.java  |  67 ++++
 .../gremlin/sparql/ResourceHelper.java          |  37 ++
 .../sparql/SparqlToGremlinCompilerTest.java     | 223 +++++++++++
 9 files changed, 1216 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/sparql-gremlin/pom.xml b/sparql-gremlin/pom.xml
new file mode 100644
index 0000000..e134d31
--- /dev/null
+++ b/sparql-gremlin/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    <parent>
+        <artifactId>tinkerpop</artifactId>
+        <groupId>org.apache.tinkerpop</groupId>
+        <version>3.3.2-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>sparql-gremlin</artifactId>
+    <organization>
+        <name>WDAQUA-ITN</name>
+        <url>http://wdaqua.eu</url>
+    </organization>
+    <developers>
+        <developer>
+            <name>Harsh Thakkar</name>
+            <email>harsh9t@gmail.com</email>
+            <organization>University of Bonn</organization>
+            <organizationUrl>http://harshthakkar.in</organizationUrl>
+        </developer>
+        <developer>
+            <name>Dharmen Punjani</name>
+            <email>dharmen.punjani@gmail.com</email>
+            <organization>National and Kapodistrian University of Athens</organization>
+            <organizationUrl>http://wdaqua.eu/students/dharmen-punjani</organizationUrl>
+        </developer>
+    </developers>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <jena.version>3.0.0</jena.version>
+        <query.dir>src/test/resources/sparql/queries</query.dir>
+    </properties>
+
+    <dependencies>
+    <dependency>
+        <groupId>org.apache.jena</groupId>
+        <artifactId>apache-jena-libs</artifactId>
+        <type>pom</type>
+        <version>${jena.version}</version>
+    </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-core</artifactId>
+            <version>3.3.2-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>tinkergraph-gremlin</artifactId>
+            <version>3.3.2-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tinkerpop</groupId>
+            <artifactId>gremlin-test</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java
new file mode 100644
index 0000000..0d50475
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/ConsoleCompiler.java
@@ -0,0 +1,165 @@
+/*
+ * 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.sparql;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+
+import org.apache.tinkerpop.gremlin.sparql.SparqlToGremlinCompiler;
+
+class ConsoleCompiler {
+
+    public static void main(final String[] args) throws IOException {
+    	//args = "/examples/modern1.sparql";
+        final Options options = new Options();
+        options.addOption("f", "file", true, "a file that contains a SPARQL query");
+        options.addOption("g", "graph", true, "the graph that's used to execute the query [classic|modern|crew|kryo file]");
+        // TODO: add an OLAP option (perhaps: "--olap spark"?)
+
+        final CommandLineParser parser = new DefaultParser();
+        final CommandLine commandLine;
+
+        try {
+            commandLine = parser.parse(options, args);
+        } catch (ParseException e) {
+            System.out.println(e.getMessage());
+            printHelp(1);
+            return;
+        }
+        
+        final InputStream inputStream = commandLine.hasOption("file")
+                ? new FileInputStream(commandLine.getOptionValue("file"))
+                : System.in;
+        final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+        final StringBuilder queryBuilder = new StringBuilder();
+
+        if (!reader.ready()) {
+            printHelp(1);
+        }
+
+        String line;
+        while (null != (line = reader.readLine())) {
+            queryBuilder.append(System.lineSeparator()).append(line);
+        }
+
+        final String queryString = queryBuilder.toString();
+        Graph graph;
+        
+        if (commandLine.hasOption("graph")) {
+            switch (commandLine.getOptionValue("graph").toLowerCase()) {
+                case "classic":
+                    graph = TinkerFactory.createClassic();
+                    break;
+                case "modern":
+                    graph = TinkerFactory.createModern();
+                    System.out.println("Modern Graph Created");
+                    break;
+                case "crew":
+                    graph = TinkerFactory.createTheCrew();
+                    break;
+                default:
+                    graph = TinkerGraph.open();
+                    System.out.println("Graph Created");
+                    String graphName = commandLine.getOptionValue("graph");
+                    long startTime= System.currentTimeMillis();
+                    if(graphName.endsWith(".graphml"))
+                    	graph.io(IoCore.graphml()).readGraph(graphName);
+                    else if(graphName.endsWith(".kryo")||graphName.endsWith("gryo"))
+                    	graph.io(IoCore.gryo()).readGraph(graphName);
+                    long endTime = System.currentTimeMillis();
+                    System.out.println("Time taken to load graph from kyro file: "+ (endTime-startTime)+" mili seconds");
+                    break;
+            }
+        } else {
+ 
+            graph = TinkerFactory.createModern();
+        }
+
+        long startTime = System.currentTimeMillis();
+        final Traversal<Vertex, ?> traversal = SparqlToGremlinCompiler.convertToGremlinTraversal(graph, queryString);
+        long endTime = System.currentTimeMillis();
+        System.out.println("Time traken to convert SPARQL to Gremlin Traversal : "+ (endTime - startTime)+ " miliseconds");
+        
+        printWithHeadline("SPARQL Query", queryString);
+        // printWithHeadline("Traversal (prior execution)", traversal);
+  
+        
+        Bytecode traversalByteCode = traversal.asAdmin().getBytecode();
+        
+        
+//        JavaTranslator.of(graph.traversal()).translate(traversalByteCode);
+//        
+//        System.out.println("the Byte Code : "+ traversalByteCode.toString());
+        printWithHeadline("Result", String.join(System.lineSeparator(),JavaTranslator.of(graph.traversal()).translate(traversalByteCode).toStream().map(Object::toString).collect(Collectors.toList())));
+        // printWithHeadline("Traversal (after execution)", traversal);
+    }
+
+    private static void printHelp(final int exitCode) throws IOException {
+        final Map<String, String> env = System.getenv();
+        final String command = env.containsKey("LAST_COMMAND") ? env.get("LAST_COMMAND") : "sparql-gremlin.sh";
+        printWithHeadline("Usage Examples", String.join("\n",
+                command + " -f examples/modern1.sparql",
+                command + " < examples/modern2.sparql",
+                command + " <<< 'SELECT * WHERE { ?a e:knows ?b }'",
+                command + " -g crew < examples/crew1.sparql"));
+        if (exitCode >= 0) {
+            System.exit(exitCode);
+        }
+    }
+
+    private static void printWithHeadline(final String headline, final Object content) throws IOException {
+        final StringReader sr = new StringReader(content != null ? content.toString() : "null");
+        final BufferedReader br = new BufferedReader(sr);
+        String line;
+        System.out.println();
+        System.out.println( headline ); 
+        System.out.println();
+        boolean skip = true;
+        while (null != (line = br.readLine())) {
+            skip &= line.isEmpty();
+            if (!skip) {
+                System.out.println("  " + line);
+            }
+        }
+        System.out.println();
+        br.close();
+        sr.close();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
new file mode 100644
index 0000000..452bf68
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java
@@ -0,0 +1,64 @@
+/*
+ * 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.sparql;
+
+import java.util.Arrays;
+import java.util.List;
+
+
+public class Prefixes {
+
+	// public final static String BASE_URI = "http://northwind.com/model/";
+    public final static String BASE_URI = "http://www.tinkerpop.com/traversal/";
+
+    final static List<String> PREFIXES = Arrays.asList("edge", "property", "value");
+
+    final static String PREFIX_DEFINITIONS;
+
+    static {
+        final StringBuilder builder = new StringBuilder();
+        for (final String prefix : PREFIXES) {
+            builder.append("PREFIX ").append(prefix.substring(0, 1)).append(": <").append(getURI(prefix)).
+                    append(">").append(System.lineSeparator());
+        }
+        PREFIX_DEFINITIONS = builder.toString();
+    }
+
+    public static String getURI(final String prefix) {
+        return BASE_URI + prefix + "#";
+    }
+
+    public static String getURIValue(final String uri) {
+        return uri.substring(uri.indexOf("#") + 1);
+    }
+
+    public static String getPrefix(final String uri) {
+        final String tmp = uri.substring(0, uri.indexOf("#"));
+        return tmp.substring(tmp.lastIndexOf("/") + 1);
+    }
+
+    public static String prepend(final String script) {
+        return PREFIX_DEFINITIONS + script;
+    }
+
+    public static StringBuilder prepend(final StringBuilder scriptBuilder) {
+        return scriptBuilder.insert(0, PREFIX_DEFINITIONS);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
new file mode 100644
index 0000000..adb36e9
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java
@@ -0,0 +1,381 @@
+/*
+ * 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.sparql;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.query.Query;
+import org.apache.jena.query.QueryFactory;
+import org.apache.jena.query.SortCondition;
+import org.apache.jena.query.Syntax;
+import org.apache.jena.sparql.algebra.Algebra;
+import org.apache.jena.sparql.algebra.Op;
+import org.apache.jena.sparql.algebra.OpVisitorBase;
+import org.apache.jena.sparql.algebra.OpWalker;
+import org.apache.jena.sparql.algebra.op.OpBGP;
+import org.apache.jena.sparql.algebra.op.OpFilter;
+import org.apache.jena.sparql.algebra.op.OpLeftJoin;
+import org.apache.jena.sparql.algebra.op.OpUnion;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.core.VarExprList;
+import org.apache.jena.sparql.expr.Expr;
+import org.apache.jena.sparql.expr.ExprAggregator;
+import org.apache.tinkerpop.gremlin.process.traversal.Order;
+import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+// TODO: implement OpVisitor, don't extend OpVisitorBase
+public class SparqlToGremlinCompiler extends OpVisitorBase {
+
+	private GraphTraversal<Vertex, ?> traversal;
+
+	List<Traversal> traversalList = new ArrayList<Traversal>();
+
+	String groupVariable = "";
+	int sortingDirection = 0;
+	long offsetLimit = 0;
+	String sortingVariable = "";
+
+	GraphTraversalSource temp;
+	Graph graph;
+
+	private SparqlToGremlinCompiler(final GraphTraversal<Vertex, ?> traversal) {
+		this.traversal = traversal;
+	}
+
+	private SparqlToGremlinCompiler(final GraphTraversalSource g) {
+		this(g.V());
+		temp = g;
+
+	}
+
+	private SparqlToGremlinCompiler(final Graph g) {
+		this.traversal = (GraphTraversal<Vertex, ?>) g.traversal();
+		graph = g;
+	}
+
+	public String createMatchStep(String step) {
+		String st = "";
+		step = step.substring(1, step.length() - 2);
+		String first = step.substring(0, step.indexOf(","));
+		String second = step.substring(step.indexOf(",") + 1);
+		//System.out.println("First : " + first);
+		//System.out.println("Second : " + second);
+		st = first.substring(first.indexOf("["), first.length() - 1);
+		st = "[" + st + "," + second + "]";
+		return st;
+	}
+
+	GraphTraversal<Vertex, ?> convertToGremlinTraversal(final Query query) {
+		
+		// long startTime = System.currentTimeMillis();
+		// long endTime;
+		final Op op = Algebra.compile(query); // SPARQL query compiles here to
+												// OP
+//		System.out.println("OP Tree: " + op.toString());
+
+		
+		OpWalker.walk(op, this); // OP is being walked here
+		
+		
+		
+		
+		//System.out.println("time taken for opWalker:"+ (endTime-startTime));
+		// startTime = System.currentTimeMillis();
+		int traversalIndex = 0;
+		int numberOfTraversal = traversalList.size();
+		Traversal arrayOfAllTraversals[] = new Traversal[numberOfTraversal];
+
+		if (query.hasOrderBy() && !query.hasGroupBy()) {
+			List<SortCondition> sortingConditions = query.getOrderBy();
+			int directionOfSort = 0;
+
+			for (SortCondition sortCondition : sortingConditions) {
+				Expr expr = sortCondition.getExpression();
+				directionOfSort = sortCondition.getDirection();
+				sortingVariable = expr.getVarName();
+
+			}
+
+			Order orderDirection = Order.incr;
+			if (directionOfSort == -1) {
+				orderDirection = Order.decr;
+			}
+		}
+		for (Traversal tempTrav : traversalList) {
+
+			arrayOfAllTraversals[traversalIndex++] = tempTrav;
+		}
+
+		int directionOfSort = 0;
+		Order orderDirection = Order.incr;
+		if (query.hasOrderBy()) {
+			List<SortCondition> sortingConditions = query.getOrderBy();
+
+			//
+			for (SortCondition sortCondition : sortingConditions) {
+				Expr expr = sortCondition.getExpression();
+				directionOfSort = sortCondition.getDirection();
+				sortingVariable = expr.getVarName();
+//				System.out.println("order by var: "+sortingDirection);
+			}
+			//
+
+			if (directionOfSort == -1) {
+				orderDirection = Order.decr;
+			}
+
+		}
+
+		if (traversalList.size() > 0)
+			traversal = traversal.match(arrayOfAllTraversals);
+
+		final List<String> vars = query.getResultVars();
+		List<ExprAggregator> lstexpr = query.getAggregators();
+		if (!query.isQueryResultStar() && !query.hasGroupBy()) {
+
+			switch (vars.size()) {
+			case 0:
+				throw new IllegalStateException();
+			case 1:
+				if (query.isDistinct()) {
+//					System.out.println("Inside ------------------- >Select 1------------------------> Distinct");
+					traversal = traversal.dedup(vars.get(0));
+				}
+				if (query.hasOrderBy()) {
+//					System.out.println("Inside ------------------- >Select 1");
+					traversal = traversal.order().by(sortingVariable, orderDirection);
+				} else {
+
+					traversal = traversal.select(vars.get(0));
+				}
+				break;
+			case 2:
+				if (query.isDistinct()) {
+					traversal = traversal.dedup(vars.get(0), vars.get(1));
+				}
+				if (query.hasOrderBy()) {
+//					System.out.println("Inside ------------------- >Select 1");
+					traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
+				} else
+					traversal = traversal.select(vars.get(0), vars.get(1));
+				break;
+			default:
+				final String[] all = new String[vars.size()];
+				vars.toArray(all);
+				if (query.isDistinct()) {
+
+					traversal = traversal.dedup(all);
+				}
+				final String[] others = Arrays.copyOfRange(all, 2, vars.size());
+				if (query.hasOrderBy()) {
+
+					traversal = traversal.order().by(__.select(vars.get(0)), orderDirection).by(__.select(vars.get(1)));
+
+				} else
+					traversal = traversal.select(vars.get(0), vars.get(1), others);
+
+				break;
+			}
+
+		}
+		
+		
+		if (query.hasGroupBy()) {
+			VarExprList lstExpr = query.getGroupBy();
+			String grpVar = "";
+			Traversal tempTrav;
+			for (Var expr : lstExpr.getVars()) {
+				grpVar = expr.getName();
+				// System.out.println("The Group by var: " + expr.getName());
+			}
+
+			if (query.hasLimit()) {
+				long limit = query.getLimit(), offset = 0;
+
+				if (query.hasOffset()) {
+					offset = query.getOffset();
+
+				}
+				// if (query.hasGroupBy() && query.hasOrderBy())
+				// traversal = traversal.range( offset, offset + limit);
+				// else
+				// traversal = traversal.range(offset, offset + limit);
+
+			}
+
+			if (!grpVar.isEmpty())
+				traversal = traversal.select(grpVar);
+			if (query.hasAggregators()) {
+				List<ExprAggregator> exprAgg = query.getAggregators();
+				for (ExprAggregator expr : exprAgg) {
+
+//					System.out.println("The Aggregator by var: " + expr.getAggregator().getExprList().toString()
+//							+ " is :" + expr.getAggregator().toString());
+					if (expr.getAggregator().getName().contains("COUNT")) {
+						if (!query.toString().contains("GROUP")) {
+							if (expr.getAggregator().toString().contains("DISTINCT")) {
+								traversal = traversal
+										.dedup(expr.getAggregator().getExprList().get(0).toString().substring(1));
+							} else {
+								traversal = traversal
+										.select(expr.getAggregator().getExprList().get(0).toString().substring(1));
+							}
+							traversal = traversal.count();
+						} else
+							traversal = traversal.groupCount();
+					}
+					if (expr.getAggregator().getName().contains("MAX")) {
+						traversal = traversal.max();
+					}
+				}
+
+			} else {
+
+				traversal = traversal.group();
+			}
+			
+			
+		}
+
+
+		if (query.hasOrderBy() && query.hasGroupBy()) {
+
+			traversal = traversal.order().by(sortingVariable, orderDirection);
+		}
+		if (query.hasLimit()) {
+			long limit = query.getLimit(), offset = 0;
+
+			if (query.hasOffset()) {
+				offset = query.getOffset();
+
+			}
+			if (query.hasGroupBy() && query.hasOrderBy())
+				traversal = traversal.range(Scope.local, offset, offset + limit);
+			else
+				traversal = traversal.range(offset, offset + limit);
+
+		}
+		// endTime = System.currentTimeMillis();
+		// System.out.println("time taken for convertToGremlinTraversal Function : "+ (endTime-startTime)+" mili seconds");
+		
+		return traversal;
+	}
+
+	private static GraphTraversal<Vertex, ?> convertToGremlinTraversal(final GraphTraversalSource g,
+			final Query query) {
+		return new SparqlToGremlinCompiler(g).convertToGremlinTraversal(query);
+	}
+
+	public static GraphTraversal<Vertex, ?> convertToGremlinTraversal(final Graph graph, final String query) {
+		return convertToGremlinTraversal(graph.traversal(),	QueryFactory.create(Prefixes.prepend(query)));
+	}
+
+	public static GraphTraversal<Vertex, ?> convertToGremlinTraversal(final GraphTraversalSource g,
+			final String query) {
+		return convertToGremlinTraversal(g, QueryFactory.create(Prefixes.prepend(query), Syntax.syntaxSPARQL));
+	}
+
+	// VISITING SPARQL ALGEBRA OP BASIC TRIPLE PATTERNS - MAYBE
+	@Override
+	public void visit(final OpBGP opBGP) {
+		{
+			
+			// System.out.println("Inside opBGP ---------------------------------------------->");
+			final List<Triple> triples = opBGP.getPattern().getList();
+			final Traversal[] matchTraversals = new Traversal[triples.size()];
+			int i = 0;
+			for (final Triple triple : triples) {
+
+				matchTraversals[i++] = TraversalBuilder.transform(triple);
+				traversalList.add(matchTraversals[i - 1]);
+			}
+
+		}
+
+	}
+
+	// VISITING SPARQL ALGEBRA OP FILTER - MAYBE
+	@Override
+	public void visit(final OpFilter opFilter) {
+
+		// System.out.println("Inside opFilter ---------------------------------------------->");
+		Traversal traversal = null;
+
+		for (Expr expr : opFilter.getExprs().getList()) {
+			if (expr != null) {
+
+				traversal = __.where(WhereTraversalBuilder.transform(expr));
+				traversalList.add(traversal);
+			}
+		}
+
+	}
+	// TODO: add more functions for operators other than FILTER, such as
+	// OPTIONAL
+	// This can be done by understanding how Jena handles these other
+	// operators/filters inherently and then map them to Gremlin
+
+	public void visit(final OpLeftJoin opLeftJoin) {
+
+//		System.out.println("Inside opOptional ---------------------------------------------->");
+//		System.out.println(opLeftJoin.getRight().toString());
+
+	}
+
+	@Override
+	public void visit(final OpUnion opUnion) {
+
+		// System.out.println("Inside opUnion ---------------------------------------------->");
+		Traversal unionTemp[] = new Traversal[2];
+		Traversal unionTemp1[] = new Traversal[traversalList.size() / 2];
+		Traversal unionTemp2[] = new Traversal[traversalList.size() / 2];
+
+		int count = 0;
+
+		for (int i = 0; i < traversalList.size(); i++) {
+
+			if (i < traversalList.size() / 2) {
+
+				unionTemp1[i] = traversalList.get(i);
+			} else {
+				unionTemp2[count++] = traversalList.get(i);
+			}
+		}
+
+		unionTemp[1] = __.match(unionTemp2);
+		unionTemp[0] = __.match(unionTemp1);
+
+		traversalList.clear();
+		traversal = (GraphTraversal<Vertex, ?>) traversal.union(unionTemp);
+		// System.out.println("Getting out from Union -------------------> :
+		// "+traversal);
+		// traversalList.add(__.union(unionTemp));
+		// traversalList.clear();
+	}
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
new file mode 100644
index 0000000..72a32a5
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/TraversalBuilder.java
@@ -0,0 +1,82 @@
+/*
+ * 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.sparql;
+
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.structure.PropertyType;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+
+class TraversalBuilder {
+
+    public static GraphTraversal<?, ?> transform(final Triple triple) {
+        final GraphTraversal<Vertex, ?> matchTraversal = __.as(triple.getSubject().getName());
+        
+        final Node predicate = triple.getPredicate();
+        final String uri = predicate.getURI();
+        final String uriValue = Prefixes.getURIValue(uri);
+        final String prefix = Prefixes.getPrefix(uri);
+
+        switch (prefix) {
+            case "edge":
+                return matchTraversal.out(uriValue).as(triple.getObject().getName());
+            case "property":
+                return matchProperty(matchTraversal, uriValue, PropertyType.PROPERTY, triple.getObject());
+            case "value":
+                return matchProperty(matchTraversal, uriValue, PropertyType.VALUE, triple.getObject());
+            default:
+                throw new IllegalStateException(String.format("Unexpected predicate: %s", predicate));
+        }
+    }
+
+    private static GraphTraversal<?, ?> matchProperty(final GraphTraversal<?, ?> traversal, final String propertyName,
+                                                      final PropertyType type, final Node object) {
+        switch (propertyName) {
+            case "id":
+         
+                return object.isConcrete()
+                        ? traversal.hasId(object.getLiteralValue())
+                        : traversal.id().as(object.getName());
+            case "label":
+                return object.isConcrete()
+                        ? traversal.hasLabel(object.getLiteralValue().toString())
+                        : traversal.label().as(object.getName());
+            case "key":
+                return object.isConcrete()
+                        ? traversal.hasKey(object.getLiteralValue().toString())
+                        : traversal.key().as(object.getName());
+            case "value":
+                return object.isConcrete()
+                        ? traversal.hasValue(object.getLiteralValue().toString())
+                        : traversal.value().as(object.getName());
+            default:
+                if (type.equals(PropertyType.PROPERTY)) {
+                    return traversal.properties(propertyName).as(object.getName());
+                } else {
+                    return object.isConcrete()
+                            ? traversal.values(propertyName).is(object.getLiteralValue())
+                            : traversal.values(propertyName).as(object.getName());
+                }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
new file mode 100644
index 0000000..f4d49b6
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/WhereTraversalBuilder.java
@@ -0,0 +1,134 @@
+/*
+ * 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.sparql;
+
+import java.util.List;
+
+import org.apache.jena.graph.Triple;
+import org.apache.jena.sparql.algebra.op.OpBGP;
+import org.apache.jena.sparql.expr.E_Equals;
+import org.apache.jena.sparql.expr.E_Exists;
+import org.apache.jena.sparql.expr.E_GreaterThan;
+import org.apache.jena.sparql.expr.E_GreaterThanOrEqual;
+import org.apache.jena.sparql.expr.E_LessThan;
+import org.apache.jena.sparql.expr.E_LessThanOrEqual;
+import org.apache.jena.sparql.expr.E_LogicalAnd;
+import org.apache.jena.sparql.expr.E_LogicalOr;
+import org.apache.jena.sparql.expr.E_NotEquals;
+import org.apache.jena.sparql.expr.E_NotExists;
+import org.apache.jena.sparql.expr.E_StrLength;
+import org.apache.jena.sparql.expr.Expr;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+
+class WhereTraversalBuilder {
+
+    public static GraphTraversal<?, ?> transform(final E_Equals expression) {
+    //	System.out.println("The aggr one : "+expression.getArg1().getClass().getName() + "The aggr one :"+expression.getArg2().getClass().getName());
+        final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
+        return __.as(expression.getArg1().getVarName()).is(P.eq(value));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_NotEquals expression) {
+        final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
+        return __.as(expression.getArg1().getVarName()).is(P.neq(value));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_LessThan expression) {
+    //	System.out.println("The aggr one : "+expression.getArg1().getClass().getName() + "The aggr one :"+expression.getArg2().getClass().getName());
+    	final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
+        return __.as(expression.getArg1().getVarName()).is(P.lt(value));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_LessThanOrEqual expression) {
+    //	System.out.println("The aggr one : "+expression.getArg1().getClass().getName() + "The aggr one :"+expression.getArg2().getClass().getName());
+        final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
+        return __.as(expression.getArg1().getVarName()).is(P.lte(value));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_GreaterThan expression) {
+        final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
+        return __.as(expression.getArg1().getVarName()).is(P.gt(value));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_GreaterThanOrEqual expression) {
+        final Object value = expression.getArg2().getConstant().getNode().getLiteralValue();
+        return __.as(expression.getArg1().getVarName()).is(P.gte(value));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_LogicalAnd expression) {
+        return __.and(
+                transform(expression.getArg1()),
+                transform(expression.getArg2()));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_LogicalOr expression) {
+        return __.or(
+                transform(expression.getArg1()),
+                transform(expression.getArg2()));
+    }
+
+    public static GraphTraversal<?, ?> transform(final E_Exists expression) {
+        final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
+        final List<Triple> triples = opBGP.getPattern().getList();
+        if (triples.size() != 1) throw new IllegalStateException("Unhandled EXISTS pattern");
+        final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0));
+        final Step endStep = traversal.asAdmin().getEndStep();
+        final String label = (String) endStep.getLabels().iterator().next();
+        endStep.removeLabel(label);
+        return traversal;
+    }
+    
+
+    public static GraphTraversal<?, ?> transform(final E_NotExists expression) {
+        final OpBGP opBGP = (OpBGP) expression.getGraphPattern();
+        final List<Triple> triples = opBGP.getPattern().getList();
+        if (triples.size() != 1) throw new IllegalStateException("Unhandled NOT EXISTS pattern");
+        final GraphTraversal<?, ?> traversal = TraversalBuilder.transform(triples.get(0));
+        final Step endStep = traversal.asAdmin().getEndStep();
+        final String label = (String) endStep.getLabels().iterator().next();
+        endStep.removeLabel(label);
+        return __.not(traversal);
+    }
+    
+    public static int getStrLength(final E_StrLength expression){
+    	
+    	return expression.getArg().toString().length();
+    	
+    }
+    
+    
+    //what does <?, ?> signify? possibly <S,E>
+    public static GraphTraversal<?, ?> transform(final Expr expression) {
+        if (expression instanceof E_Equals) return transform((E_Equals) expression);
+        if (expression instanceof E_NotEquals) return transform((E_NotEquals) expression);
+        if (expression instanceof E_LessThan) return transform((E_LessThan) expression);
+        if (expression instanceof E_LessThanOrEqual) return transform((E_LessThanOrEqual) expression);
+        if (expression instanceof E_GreaterThan) return transform((E_GreaterThan) expression);
+        if (expression instanceof E_GreaterThanOrEqual) return transform((E_GreaterThanOrEqual) expression);
+        if (expression instanceof E_LogicalAnd) return transform((E_LogicalAnd) expression);
+        if (expression instanceof E_LogicalOr) return transform((E_LogicalOr) expression);
+        if (expression instanceof E_Exists) return transform((E_Exists) expression);
+        if (expression instanceof E_NotExists) return transform((E_NotExists) expression);
+        throw new IllegalStateException(String.format("Unhandled expression: %s", expression));
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/PrefixesTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/PrefixesTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/PrefixesTest.java
new file mode 100644
index 0000000..155680b
--- /dev/null
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/PrefixesTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.sparql;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class PrefixesTest {
+
+    final static String TEST_QUERY = String.join(System.lineSeparator(), "SELECT *", "WHERE {}");
+    final static String PREFIXED_QUERY = String.join(System.lineSeparator(),
+            "PREFIX e: <" + Prefixes.BASE_URI + "edge#>",
+            "PREFIX p: <" + Prefixes.BASE_URI + "property#>",
+            "PREFIX v: <" + Prefixes.BASE_URI + "value#>",
+            TEST_QUERY);
+
+    @Test
+    public void testGetURI() throws Exception {
+        final String prefix = "test";
+        final String uri = Prefixes.BASE_URI + prefix + "#";
+        assertEquals(uri, Prefixes.getURI(prefix));
+    }
+
+    @Test
+    public void testGetURIValue() throws Exception {
+        final String prefix = "test";
+        final String value = "value";
+        final String uri = Prefixes.getURI(prefix) + value;
+        assertEquals(value, Prefixes.getURIValue(uri));
+    }
+
+    @Test
+    public void testGetPrefix() throws Exception {
+        final String prefix = "test";
+        final String uri = Prefixes.getURI(prefix);
+        assertEquals(prefix, Prefixes.getPrefix(uri));
+    }
+
+    @Test
+    public void testPrependString() throws Exception {
+        assertEquals(PREFIXED_QUERY, Prefixes.prepend(TEST_QUERY));
+    }
+
+    @Test
+    public void testPrependStringBuilder() throws Exception {
+        final StringBuilder builder = new StringBuilder(TEST_QUERY);
+        assertEquals(PREFIXED_QUERY, Prefixes.prepend(builder).toString());
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java
new file mode 100644
index 0000000..4f58e61
--- /dev/null
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java
@@ -0,0 +1,37 @@
+/*
+ * 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.sparql;
+
+import org.apache.commons.io.IOUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Daniel Kuppitz (http://gremlin.guru)
+ */
+public class ResourceHelper {
+
+    public static String loadQuery(final String prefix, final int number) throws IOException {
+        final String path = "/queries/" + prefix + number + ".sparql";
+        final InputStream stream = ResourceHelper.class.getResourceAsStream(path);
+        return IOUtils.toString(stream, "UTF-8");
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c4244ce4/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java
new file mode 100644
index 0000000..3fb49e8
--- /dev/null
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java
@@ -0,0 +1,223 @@
+/*
+ * 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.sparql;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import static org.apache.tinkerpop.gremlin.sparql.SparqlToGremlinCompiler.convertToGremlinTraversal;
+import static org.junit.Assert.assertEquals;
+
+
+import java.io.IOException;
+
+import static org.apache.tinkerpop.gremlin.sparql.ResourceHelper.loadQuery;
+
+
+public class SparqlToGremlinCompilerTest {
+
+    private Graph modern, crew;
+    private GraphTraversalSource mg, cg;
+    private GraphTraversalSource mc, cc;
+/*
+    @Before
+    public void setUp() throws Exception {
+        modern = TinkerFactory.createModern();
+        mg = modern.traversal();
+        mc = modern.traversal(computer());
+        crew = TinkerFactory.createTheCrew();
+        cg = modern.traversal();
+        cc = modern.traversal(computer());
+    }
+
+    @Ignore
+    @Test
+    public void play() throws IOException {
+        final String query = loadQuery("modern", 11);
+        final Traversal traversal = convertToGremlinTraversal(modern, query);
+        System.out.println(traversal);
+        System.out.println(traversal.toList());
+        System.out.println(traversal);
+    }
+
+    /* Modern */
+
+ /*   @Test
+    public void testModern1() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").hasLabel("person"),
+                as("a").out("knows").as("b"),
+                as("a").out("created").as("c"),
+                as("b").out("created").as("c"),
+                as("a").values("age").as("d")).where(as("d").is(lt(30))).
+                select("a", "b", "c");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 1)));
+    }
+
+    @Test
+    public void testModern2() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").hasLabel("person"),
+                as("a").out("knows").as("b"),
+                as("a").out("created").as("c"),
+                as("b").out("created").as("c"),
+                as("a").values("age").as("d")).where(as("d").is(lt(30)));
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 2)));
+    }
+
+    @Test
+    public void testModern3() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("person").values("name").as("name"),
+                as("person").values("age").as("age")).select("name", "age");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 3)));
+    }
+
+    @Test
+    public void testModern4() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("person").values("name").as("name"),
+                as("person").values("age").as("age"),
+                as("person").out("created").as("project"),
+                as("project").values("name").is("lop")).select("name", "age");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 4)));
+    }
+
+    @Test
+    public void testModern5() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("person").values("name").as("name"),
+                as("person").values("age").is(29)).select("name");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 5)));
+    }
+
+    @Test
+    public void testModern6() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("person").values("name").as("name"),
+                as("person").values("age").as("age")).where(and(as("age").is(gt(30)), as("age").is(lt(40)))).
+                select("name", "age");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 6)));
+    }
+
+    @Test
+    public void testModern7() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("person").values("name").as("name"),
+                as("person").values("age").as("age")).where(or(as("age").is(lt(30)), as("age").is(gt(40)))).
+                select("name", "age");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 7)));
+    }
+
+    @Test
+    public void testModern8() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("person").values("name").as("name"),
+                as("person").values("age").as("age")).where(
+                or(and(as("age").is(gt(30)), as("age").is(lt(40))), as("name").is("marko"))).
+                select("name", "age");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 8)));
+    }
+
+    @Test
+    public void testModern9() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").values("name").as("name")).where(as("a").values("age")).
+                select("name");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 9)));
+    }
+
+    @Test
+    public void testModern10() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").values("name").as("name")).where(__.not(as("a").values("age"))).
+                select("name");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 10)));
+    }
+
+    @Test
+    public void testModern11() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").out("created").as("b"),
+                as("a").values("name").as("name")).dedup("name").select("name");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 11)));
+    }
+
+    @Test
+    public void testModern12() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").out("created").as("b"),
+                as("b").values("name").as("name")).dedup();
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 12)));
+    }
+
+    @Test
+    public void testModern13() throws Exception {
+        final GraphTraversal expected = mg.V().match(
+                as("a").out("created").as("b"),
+                as("a").values("name").as("c")).dedup("a", "b", "c").select("a", "b", "c");
+        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 13)));
+    }
+
+    /* The Crew */
+
+ /*   @Test
+    public void testCrew1() throws Exception {
+        final GraphTraversal expected = cg.V().match(
+                as("a").values("name").is("daniel"),
+                as("a").properties("location").as("b"),
+                as("b").value().as("c"),
+                as("b").values("startTime").as("d")).
+                select("c", "d");
+        assertEquals(expected, convertToGremlinTraversal(crew, loadQuery("crew", 1)));
+    }
+
+    /* Computer Mode */
+
+  /*  @Test
+    public void testModernInComputerMode() throws Exception {
+        final GraphTraversal expected = mc.V().match(
+                as("a").hasLabel("person"),
+                as("a").out("knows").as("b"),
+                as("a").out("created").as("c"),
+                as("b").out("created").as("c"),
+                as("a").values("age").as("d")).where(as("d").is(lt(30))).
+                select("a", "b", "c");
+        assertEquals(expected, convertToGremlinTraversal(mc, loadQuery("modern", 1)));
+    }
+
+    @Test
+    public void testCrewInComputerMode() throws Exception {
+        final GraphTraversal expected = cc.V().match(
+                as("a").values("name").is("daniel"),
+                as("a").properties("location").as("b"),
+                as("b").value().as("c"),
+                as("b").values("startTime").as("d")).
+                select("c", "d");
+        assertEquals(expected, convertToGremlinTraversal(crew, loadQuery("crew", 1)));
+    } */
+}
\ No newline at end of file


[11/50] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by sp...@apache.org.
Merge branch 'tp32' into tp33


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

Branch: refs/heads/TINKERPOP-1878
Commit: ddc66941ed6340edd9009f0aa277aa8326255c68
Parents: 88b6e14 00a085a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 11:41:21 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 11:41:21 2018 -0400

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ddc66941/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java
----------------------------------------------------------------------


[12/50] tinkerpop git commit: Merge branch 'tp33'

Posted by sp...@apache.org.
Merge branch 'tp33'


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

Branch: refs/heads/TINKERPOP-1878
Commit: 7d21ee0b8b8770a68e6b5fb6f84500170f6c2a82
Parents: 4dccf14 ddc6694
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jul 30 11:41:28 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jul 30 11:41:28 2018 -0400

----------------------------------------------------------------------
 .../org/apache/tinkerpop/gremlin/process/remote/RemoteGraph.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[29/50] tinkerpop git commit: TINKERPOP-1878 Testing for DISTINCT

Posted by sp...@apache.org.
TINKERPOP-1878 Testing for DISTINCT

Refactoring around the distinct and ordering - much less code there now.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 960b0455e4d320a600dae9642ca371abacc12ddd
Parents: 35f5fc5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 16:56:14 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../sparql/SparqlToGremlinTranspiler.java       | 44 ++++++++------------
 .../dsl/sparql/SparqlTraversalSourceTest.java   | 23 ++++++++++
 2 files changed, 41 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/960b0455/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
index 1b28a1d..67ac1e1 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinTranspiler.java
@@ -107,39 +107,28 @@ public class SparqlToGremlinTranspiler {
 
         final List<String> vars = query.getResultVars();
         if (!query.isQueryResultStar() && !query.hasGroupBy()) {
-            // the result sizes have special handling to get the right signatures of select() called. perhaps this
-            // could be refactored to work more nicely
-            switch (vars.size()) {
+            final String[] all = new String[vars.size()];
+            vars.toArray(all);
+            if (query.isDistinct()) {
+                traversal = traversal.dedup(all);
+            }
+
+            // apply ordering from ORDER BY
+            orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
+
+            // the result sizes have special handling to get the right signatures of select() called.
+            switch (all.length) {
                 case 0:
                     throw new IllegalStateException();
                 case 1:
-                    if (query.isDistinct())
-                        traversal = traversal.dedup(vars.get(0));
-
-                    orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
-                    traversal = traversal.select(vars.get(0));
-
+                    traversal = traversal.select(all[0]);
                     break;
                 case 2:
-                    if (query.isDistinct())
-                        traversal = traversal.dedup(vars.get(0), vars.get(1));
-
-                    orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
-                    traversal = traversal.select(vars.get(0), vars.get(1));
-
+                    traversal = traversal.select(all[0], all[1]);
                     break;
                 default:
-                    final String[] all = new String[vars.size()];
-                    vars.toArray(all);
-                    if (query.isDistinct())
-                        traversal = traversal.dedup(all);
-
-                    orderingIndex.forEach((k, v) -> traversal = traversal.order().by(__.select(k), v));
-
-                    // just some shenanigans to get the right signature of select() called
                     final String[] others = Arrays.copyOfRange(all, 2, vars.size());
-                    traversal = traversal.select(vars.get(0), vars.get(1), others);
-
+                    traversal = traversal.select(all[0], all[1], others);
                     break;
             }
         }
@@ -207,7 +196,10 @@ public class SparqlToGremlinTranspiler {
 
             for (SortCondition sortCondition : sortingConditions) {
                 final Expr expr = sortCondition.getExpression();
-                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == 1 ? Order.incr : Order.decr);
+
+                // by default, the sort will be ascending. getDirection() returns -2 if the DESC/ASC isn't
+                // supplied - weird
+                orderingIndex.put(expr.getVarName(), sortCondition.getDirection() == -1 ? Order.decr : Order.incr);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/960b0455/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
index 4092e58..56d62c9 100644
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -111,4 +111,27 @@ public class SparqlTraversalSourceTest {
         assertEquals(x.get("b"), _g.V(4).next());
         assertEquals(x.get("c"), _g.V(3).next());
     }
+
+    @Test
+    public void shouldDistinct() {
+        final List<?> x = g.sparql(
+                "SELECT DISTINCT ?name\n" +
+                "WHERE {\n" +
+                "    ?a e:created ?b .\n" +
+                "    ?a v:name ?name .\n" +
+                "}").toList();
+        assertThat(x, containsInAnyOrder("marko", "josh", "peter"));
+    }
+
+    @Test
+    public void shouldDistinctAndOrder() {
+        final List<?> x = g.sparql(
+                "SELECT DISTINCT ?name\n" +
+                        "WHERE {\n" +
+                        "    ?a e:created ?b .\n" +
+                        "    ?a v:name ?name .\n" +
+                        "}" +
+                        "ORDER BY ?name").toList();
+        assertThat(x, contains("josh", "marko", "peter"));
+    }
 }


[13/50] tinkerpop git commit: Merge branch 'TINKERPOP-1996'

Posted by sp...@apache.org.
Merge branch 'TINKERPOP-1996'


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

Branch: refs/heads/TINKERPOP-1878
Commit: edd8234684bedb7c073479724b2ee645a801cbc5
Parents: 7d21ee0 10478be
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 31 07:35:52 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 31 07:35:52 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   4 +
 docs/src/recipes/centrality.asciidoc            |   2 +-
 .../reference/implementations-neo4j.asciidoc    |   5 +-
 .../implementations-tinkergraph.asciidoc        |   8 +-
 docs/src/reference/the-graph.asciidoc           | 370 -------------------
 docs/src/reference/the-traversal.asciidoc       | 186 +++++++++-
 docs/src/upgrade/release-3.4.x.asciidoc         |  49 ++-
 .../tinkerpop/gremlin/jsr223/CoreImports.java   |   2 +
 .../step/map/TraversalVertexProgramStep.java    |   4 -
 .../decoration/VertexProgramStrategy.java       |  11 +-
 .../tinkerpop/gremlin/process/traversal/IO.java |  83 +++++
 .../traversal/dsl/graph/GraphTraversal.java     |  37 ++
 .../dsl/graph/GraphTraversalSource.java         |  22 ++
 .../process/traversal/step/ReadWriting.java     |  48 +++
 .../traversal/step/sideEffect/IoStep.java       | 254 +++++++++++++
 .../process/traversal/step/util/Parameters.java |   4 +-
 .../ComputerVerificationStrategy.java           |   3 +-
 .../StandardVerificationStrategy.java           |   9 +
 .../tinkerpop/gremlin/structure/Graph.java      |  30 ++
 .../tinkerpop/gremlin/structure/io/IoCore.java  |   3 +
 .../traversal/dsl/graph/GraphTraversalTest.java |   5 +-
 .../decoration/VertexProgramStrategyTest.java   |   2 +-
 .../StandardVerificationStrategyTest.java       |  13 +-
 .../glv/GraphTraversalSource.template           |   4 +-
 gremlin-dotnet/glv/IO.template                  |  46 +++
 gremlin-dotnet/glv/generate.groovy              |  13 +-
 .../Process/Traversal/GraphTraversal.cs         |  15 +-
 .../Process/Traversal/GraphTraversalSource.cs   |  11 +
 .../src/Gremlin.Net/Process/Traversal/IO.cs     |  56 +++
 .../Gherkin/TraversalEvaluation/IOParameter.cs  |  82 ++++
 .../TraversalEvaluation/TraversalParser.cs      |   7 +
 .../groovy/jsr223/GroovyTranslatorProvider.java |   6 +
 gremlin-javascript/glv/TraversalSource.template |   9 +
 gremlin-javascript/glv/generate.groovy          |   4 +
 .../lib/process/graph-traversal.js              |  30 ++
 .../gremlin-javascript/lib/process/traversal.js |  29 ++
 .../test/cucumber/feature-steps.js              |   2 +
 gremlin-python/glv/TraversalSource.template     |  11 +
 gremlin-python/glv/generate.groovy              |   4 +
 .../gremlin_python/process/graph_traversal.py   |  13 +
 .../jython/gremlin_python/process/traversal.py  |  21 ++
 .../src/main/jython/radish/feature_steps.py     |   5 +-
 gremlin-test/features/sideEffect/Read.feature   |  84 +++++
 gremlin-test/features/sideEffect/Write.feature  |  60 +++
 .../gremlin/AbstractGraphProvider.java          |  22 +-
 .../apache/tinkerpop/gremlin/TestHelper.java    |  24 +-
 .../gremlin/process/ProcessComputerSuite.java   |   4 +
 .../gremlin/process/ProcessStandardSuite.java   |   4 +
 .../process/traversal/step/map/ReadTest.java    | 188 ++++++++++
 .../process/traversal/step/map/WriteTest.java   | 183 +++++++++
 .../ElementIdStrategyProcessTest.java           |   1 -
 .../gremlin/structure/io/util/CustomId.java     |  39 ++
 .../gremlin/process/FeatureCoverageTest.java    |   6 +-
 .../traversal/step/sideEffect/HadoopIoStep.java | 188 ++++++++++
 .../traversal/strategy/HadoopIoStrategy.java    |  83 +++++
 .../gremlin/hadoop/structure/HadoopGraph.java   |  24 ++
 .../step/sideEffect/TinkerGraphIoStepTest.java  |  98 +++++
 .../structure/TinkerGraphPlayTest.java          |   6 +-
 ...ctTinkerGraphGraphSONTranslatorProvider.java |   5 +
 .../gryo/TinkerGraphGryoTranslatorProvider.java |   7 +-
 60 files changed, 2121 insertions(+), 427 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/docs/src/upgrade/release-3.4.x.asciidoc
----------------------------------------------------------------------
diff --cc docs/src/upgrade/release-3.4.x.asciidoc
index 2d699dc,8d87397..9951024
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@@ -31,12 -31,12 +31,12 @@@ Please see the link:https://github.com/
  
  ==== with() Step
  
 -This version of TinkerPop introduces the `with()` step to Gremlin. It isn't really a step but is instead a step
 +This version of TinkerPop introduces the `with()`-step to Gremlin. It isn't really a step but is instead a step
  modulator. This modulator allows the step it is modifying to accept configurations that can be used to alter the
 -behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()` step
 +behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()`-step
  which now uses `with()` to replace the old `by()` options:
  
- [groovy]
+ [source,groovy]
  ----
  g.V().hasLabel('person').
    pageRank().
@@@ -47,9 -47,9 +47,9 @@@
    valueMap('name','friendRank')
  ----
  
 -A similar change was made for `peerPressure()` step:
 +A similar change was made for `peerPressure()`-step:
  
- [groovy]
+ [source,groovy]
  ----
  g.V().hasLabel('person').
    peerPressure().

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/edd82346/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------


[02/50] tinkerpop git commit: Merge branch 'tp33'

Posted by sp...@apache.org.
Merge branch 'tp33'


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

Branch: refs/heads/TINKERPOP-1878
Commit: 13ff64c8b1230cb886b28d294f31cce064f4b52d
Parents: a17bb40 9b693c0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 07:18:45 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 07:18:45 2018 -0400

----------------------------------------------------------------------
 docs/src/dev/developer/for-committers.asciidoc    |  2 +-
 docs/src/recipes/between-vertices.asciidoc        |  6 +++---
 docs/src/recipes/collections.asciidoc             | 18 +++++++++---------
 docs/src/recipes/pagination.asciidoc              |  2 +-
 .../recipes/traversal-component-reuse.asciidoc    |  4 ++--
 docs/src/recipes/tree.asciidoc                    |  2 +-
 docs/src/reference/the-traversal.asciidoc         |  2 +-
 docs/src/tutorials/getting-started/index.asciidoc | 10 +++++-----
 .../src/tutorials/gremlins-anatomy/index.asciidoc | 16 ++++++++--------
 .../tutorials/the-gremlin-console/index.asciidoc  |  2 +-
 docs/src/upgrade/release-3.3.x.asciidoc           |  4 ++--
 11 files changed, 34 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13ff64c8/docs/src/reference/the-traversal.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13ff64c8/docs/src/tutorials/getting-started/index.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/13ff64c8/docs/src/tutorials/the-gremlin-console/index.asciidoc
----------------------------------------------------------------------


[20/50] tinkerpop git commit: TINKERPOP-1878 Added a basics for sparql execution in a traversal

Posted by sp...@apache.org.
TINKERPOP-1878 Added a basics for sparql execution in a traversal


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

Branch: refs/heads/TINKERPOP-1878
Commit: c9401171ccf923661295f4c7feddb7df94925d66
Parents: eadb8b9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 14:46:31 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 .../traversal/step/map/ConstantStep.java        |  4 ++
 .../traversal/strategy/SparqlStrategy.java      | 56 +++++++++++++++++++-
 .../dsl/sparql/SparqlTraversalSourceTest.java   | 39 ++++++++++++++
 .../src/test/resources/log4j-silent.properties  | 23 ++++++++
 .../src/test/resources/log4j-test.properties    | 23 ++++++++
 5 files changed, 144 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c9401171/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConstantStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConstantStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConstantStep.java
index 5d02e28..749de31 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConstantStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConstantStep.java
@@ -36,6 +36,10 @@ public class ConstantStep<S, E> extends MapStep<S, E> {
         this.constant = constant;
     }
 
+    public E getConstant() {
+        return this.constant;
+    }
+
     @Override
     protected E map(final Traverser.Admin<S> traverser) {
         return this.constant;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c9401171/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
index 6440127..07ac4cf 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
@@ -18,8 +18,62 @@
  */
 package org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy;
 
+import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalMapStep;
+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.sparql.SparqlToGremlinCompiler;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+
+import java.util.Collections;
+import java.util.Set;
+
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class SparqlStrategy {
+public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy>
+        implements TraversalStrategy.DecorationStrategy {
+    private static final SparqlStrategy INSTANCE = new SparqlStrategy();
+
+    private static final Set<Class<? extends DecorationStrategy>> POSTS = Collections.singleton(VertexProgramStrategy.class);
+
+    private SparqlStrategy() {}
+
+    public static SparqlStrategy instance() {
+        return INSTANCE;
+    }
+
+    @Override
+    public Set<Class<? extends DecorationStrategy>> applyPost() {
+        return POSTS;
+    }
+
+
+    @Override
+    public void apply(final Traversal.Admin<?, ?> traversal) {
+        if (!(traversal.getParent() instanceof EmptyStep))
+            return;
+
+        if (traversal.getSteps().size() == 1 && traversal.getEndStep() instanceof ConstantStep) {
+            final ConstantStep stepWithSparql = (ConstantStep) traversal.getEndStep();
+            final Object constant = stepWithSparql.getConstant();
+            if (constant instanceof String) {
+                final String sparql = (String) constant;
+                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinCompiler.convertToGremlinTraversal(
+                        traversal.getGraph().get(), sparql);
+                TraversalHelper.removeAllSteps(traversal);
+                sparqlTraversal.asAdmin().getSteps().forEach(s -> traversal.addStep(s));
+            } else {
+                // The ConstantStep expects a string value
+                throw new IllegalStateException("SparqlStrategy cannot be applied to this traversal");
+            }
+        } else {
+            // SparqlStrategy requires that there be one step and it be a ConstantStep that contains some SPARQL
+            throw new IllegalStateException("SparqlStrategy cannot be applied to this traversal");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c9401171/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
new file mode 100644
index 0000000..9e5ffc0
--- /dev/null
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.sparql.process.traversal.dsl.sparql;
+
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
+import org.junit.Test;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class SparqlTraversalSourceTest {
+
+    @Test
+    public void shouldDoStuff() {
+        final Graph graph = TinkerFactory.createModern();
+        final SparqlTraversalSource g = graph.traversal(SparqlTraversalSource.class).
+                                                withStrategies(SparqlStrategy.instance());
+        final Object x = g.sparql("SELECT ?name ?age WHERE { ?person v:name ?name . ?person v:age ?age }").toList();
+        System.out.println(x);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c9401171/sparql-gremlin/src/test/resources/log4j-silent.properties
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/resources/log4j-silent.properties b/sparql-gremlin/src/test/resources/log4j-silent.properties
new file mode 100644
index 0000000..1825bb0
--- /dev/null
+++ b/sparql-gremlin/src/test/resources/log4j-silent.properties
@@ -0,0 +1,23 @@
+# 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.
+
+# this file should always have logging set to OFF.  it seems, however, that an appender of some sort is
+# required or else some logs throw error and use other log4j.properties files on the path.
+log4j.rootLogger=OFF, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c9401171/sparql-gremlin/src/test/resources/log4j-test.properties
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/resources/log4j-test.properties b/sparql-gremlin/src/test/resources/log4j-test.properties
new file mode 100644
index 0000000..79038b1
--- /dev/null
+++ b/sparql-gremlin/src/test/resources/log4j-test.properties
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+log4j.rootLogger=WARN, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%p] %C - %m%n
\ No newline at end of file


[16/50] tinkerpop git commit: Merge branch 'tp33'

Posted by sp...@apache.org.
Merge branch 'tp33'


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

Branch: refs/heads/TINKERPOP-1878
Commit: a2db39cc710dd2809bab3fb6b2db44257458dcc8
Parents: edd8234 c49c0cc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 31 08:35:34 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 31 08:35:34 2018 -0400

----------------------------------------------------------------------
 docs/src/dev/developer/development-environment.asciidoc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------



[37/50] tinkerpop git commit: updating the reference documentation

Posted by sp...@apache.org.
updating the reference documentation

added the following:
- fix the logo
- added prefixes
- added limitations
- added examples

todo:
- cover all limitations and special cases with examples

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

Branch: refs/heads/TINKERPOP-1878
Commit: 781bfdca4659510792cd2991b3595cbe99a682c8
Parents: 8e60e91
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Mar 28 17:27:32 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 355 ++++++++++++++++++++++++++-
 1 file changed, 351 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/781bfdca/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index 9100f84..386b4a5 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -17,10 +17,6 @@ limitations under the License.
 [[transpilers]]
 = Gremlin Transpilers
 
-![gremlinator][SPARQL-Gremlin]
-
-[SPARQL-Gremlin]: https://raw.githubusercontent.com/LITMUS-Benchmark-Suite/sparql-to-gremlin/master/docs/images/sparql-gremlin-logo.png
-
 There are many languages built to query data. SQL is typically used to query relational data. There is SPARQL for RDF
 data. Cypher is used to do pattern matching in graph data. The list could go on. Transpilers convert languages like
 these to Gremlin so that it becomes possible to use them in any context that Gremlin is used. In other words, a
@@ -28,6 +24,24 @@ Gremlin Transpiler enables a particular query language to work on any TinkerPop-
 
 == SPARQL-Gremlin
 
+image:https://raw.githubusercontent.com/LITMUS-Benchmark-Suite/sparql-to-gremlin/master/docs/images/sparql-gremlin-logo.png[gremlinator]
+
+The SPARQL-Gremlin transpiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin traversals. It is based on the  https://jena.apache.org/index.html[Apache Jena] SPARQL processor https://jena.apache.org/documentation/query/index.html[ARQ], which provides access to a syntax tree of a SPARQL query.
+
+
+The goal of this work is to bridge the query interoperability gap between the two famous, yet fairly disconnected, graph communities: Semantic Web (which relies on the RDF data model) and Graph database
+(which relies on Property graph data model).
+
+NOTE: The foundational research work on SPARQL-Gremlin transpiler (aka Gremlinator) can be found from -
+https://arxiv.org/pdf/1801.02911.pdf[Gremlinator full paper]. In this
+paper, we present and discuss the notion of graph query language
+semantics of SPARQL and Gremlin, and a formal mapping between SPARQL
+pattern matching graph patterns and Gremlin traversals. Furthermore, we
+point the interested reader to the following resourcesfor a better
+understanding: (1) Gremlinator demonstration -
+(http://gremlinator.iai.uni-bonn.de:8080/Demo/[Public Demo Mirror 1])
+and (http://195.201.31.31:8080/Demo/[Public Demo Mirror 2]); (2) A short video tutorial on how to use the demonstration - https://www.youtube.com/watch?v=Z0ETx2IBamw[here]
+
 [source,xml]
 ----
 <dependency>
@@ -68,3 +82,336 @@ start step.
 <2> Execute a SPARQL query against the TinkerGraph instance. The `SparqlTraversalSource` uses a
 <<traversalstrategy,TraversalStrategy>> to transparently converts that SPARQL query into a standard Gremlin traversal
 and then when finally iterated, executes that against the TinkerGraph.
+
+[[prefixes]]
+Prefixes
+~~~~~~~~~
+
+The SPARQL-Gremlin transpiler supports the following prefixes to traverse the graph:
+
+[cols=",",options="header",]
+|====================================
+|Prefix |Purpose
+|`v:<label>` |label-access traversal
+|`e:<label>` |out-edge traversal
+|`p:<name>` |property traversal
+|`v:<name>` |property-value traversal
+|====================================
+
+Note that element IDs and labels are treated like normal properties, hence they can be accessed using the same pattern:
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?id ?label 
+	WHERE { 
+	?element v:name ?name . 
+	?element v:id ?id . 
+	?element v:label ?label .}""")
+----
+
+[[supported-queries]]
+Supported Queries
+~~~~~~~~~~~~~~~~~~
+
+The SPARQL-Gremlin transpiler is currently an on-going effort with an aim to cover the entire SPARQL 1.1 query feature spectrum, however we currently only support translation of the SPARQL 1.0 specification, especially _SELECT_ queries. The supported SPARQL query types are: 
+
+* Union 
+* Optional 
+* Order-By 
+* Group-By 
+* STAR-shaped or _neighbourhood queries_ 
+* Query modifiers, such as: 
+** Filter with _restrictions_ 
+** Count 
+** LIMIT 
+** OFFSET
+
+[[limitations]]
+Limitations
+~~~~~~~~~~~~
+
+The current implementation of SPARQL-Gremlin transpiler (i.e. SPARQL-Gremlin) does
+not support the following cases: 
+
+* SPARQL queries with variables in the
+predicate position are not currently covered, with an exception of the
+following case:
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * WHERE { ?x ?y ?z . }""")
+----
+
+* A SPARQL Union query with un-balanced patterns, i.e. a gremlin union
+traversal can only be generated if the unput SPARQL query has the same
+number of patterns on both the side of the union operator. For instance,
+the following SPARQL query cannot be mapped using Gremlinator, since a
+union is executed between different number of graph patterns (two
+patterns _union_ 1 pattern).
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * 
+	WHERE {
+	{?person e:created ?software . 
+	?person v:name "daniel" .}
+	UNION
+	{?software v:lang "java" .} }""")
+----
+
+* order by
+....
+Adding more here...
+....
+
+* group by
+....
+Adding more here...
+....
+
+[[examples]]
+Examples
+~~~~~~~~~
+
+The following section presents a comprehensive examples of SPARQL queries that are currently covered by the SPARQL-Gremlin transpiler.
+
+[[select-all]]
+Select All
+^^^^^^^^^^
+
+.Select all vertices in the graph.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * WHERE { }""")
+----
+
+[[match-constant-values]]
+Match Constant Values
+^^^^^^^^^^^^^^^^^^^^^
+
+.Select all vertices with the label `person`.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * WHERE {  ?person v:label "person" .}""")
+----
+
+[[select-specific-elements]]
+Select Specific Elements
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+.Select the values of the properties `name` and `age` for each `person` vertex.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?age
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+  ?person v:age ?age . }""")
+----
+
+[[pattern-matching]]
+Pattern Matching
+^^^^^^^^^^^^^^^^
+
+.Select only those persons who created a project.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?age
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+  ?person v:age ?age .
+  ?person e:created ?project . }""")
+----
+
+[[filtering]]
+Filtering
+^^^^^^^^^
+
+.Select only those persons who are older than 30.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?age
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+  ?person v:age ?age .
+  ?person e:created ?project .
+    FILTER (?age > 30) }""")
+----
+
+[[deduplication]]
+Deduplication
+^^^^^^^^^^^^^
+
+.Select the distinct names of the created projects.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT DISTINCT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person e:created ?project .
+  ?project v:name ?name .
+    FILTER (?age > 30)}""")
+----
+
+[[multiple-filters]]
+Multiple Filters
+^^^^^^^^^^^^^^^^
+
+.Select the distinct names of all Java projects.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT DISTINCT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+  ?person e:created ?project .
+  ?project v:name ?name .
+  ?project v:lang ?lang .
+    FILTER (?age > 30 && ?lang == "java") }""")
+----
+
+[[pattern-filters]]
+Pattern Filter(s)
+^^^^^^^^^^^^^^^^^
+
+.A different way to filter all person who created a project.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+    FILTER EXISTS { ?person e:created ?project } }""")
+----
+
+.Filter all person who did not create a project.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name
+WHERE {
+  ?person v:label "person" .
+  ?person v:name ?name .
+    FILTER NOT EXISTS { ?person e:created ?project } }""")
+----
+
+[[meta-property-access]]
+Meta-Property Access
+^^^^^^^^^^^^^^^^^^^^
+
+.Accessing the Meta-Property of a graph element. Meta-Property can be perceived as the reified statements in an RDF graph.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?name ?startTime
+WHERE {
+  ?person v:name "daniel" .
+  ?person p:location ?location .
+  ?location v:value ?name .
+  ?location v:startTime ?startTime }""")
+----
+
+[[union]]
+Union
+^^^^^
+
+.Select all persons who have developed a software in java using union.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * 
+WHERE {
+  {?person e:created ?software .}
+  UNION
+  {?software v:lang "java" .} }""")
+----
+
+[[optional]]
+Optional
+^^^^^^^^
+
+.Return the names of the persons who have created a software in java and optionally python.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?person 
+WHERE {
+  ?person v:label "person" .
+  ?person e:created ?software .
+  ?software v:lang "java" .
+  OPTIONAL {?software v:lang "python" . }}""")
+----
+
+[[order-by]]
+Order By
+^^^^^^^^
+
+.Select all vertices with the label `person` and order them by their age.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * 
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+} ORDER BY (?age)""")
+----
+
+[[group-by]]
+Group By
+^^^^^^^^
+
+.Select all vertices with the label `person` and group them by their age.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT * 
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age .
+} GROUP BY (?age)""")
+----
+
+[[mixedcomplexaggregation-based-queries]]
+Mixed/complex/aggregation-based queries
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.Count the number of projects which have been created by persons under the age of 30 and group them by age. Return only the top two.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT COUNT(?project) 
+WHERE {
+  ?person v:label "person" .
+  ?person v:age ?age . FILTER (?age < 30)
+  ?person e:created ?project .
+} GROUP BY (?age) LIMIT 2""")
+----
+
+[[star-shaped-queries]]
+STAR-shaped queries
+^^^^^^^^^^^^^^^^^^^
+
+.STAR-shaped queries are the queries that form/follow a star-shaped execution plan. These in terms of graph traversals can be perceived as path queries or neighbourhood queries. For instance, getting all the information about a specific `person` or `software`.
+
+[gremlin-groovy,existing]
+----
+g.sparql("""SELECT ?age ?software ?name ?location ?startTime 
+WHERE {
+  ?person v:name "daniel" .
+  ?person v:age ?age .
+  ?person e:created ?software .
+  ?person p:location ?location .
+  ?location v:value ?name .
+  ?location v:startTime ?startTime }""")
+----


[21/50] tinkerpop git commit: TINKERPOP-1878 sparql-gremlin is now building

Posted by sp...@apache.org.
TINKERPOP-1878 sparql-gremlin is now building

Fixed some basic pom.xml issues and resolved dependency conflicts.


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

Branch: refs/heads/TINKERPOP-1878
Commit: b0f8a612c5026421e3f67311e039afcce0f64964
Parents: c4244ce
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jan 24 15:23:57 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 pom.xml                | 18 ++++++++++++++++
 sparql-gremlin/pom.xml | 52 ++++++++++++++++++---------------------------
 2 files changed, 39 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0f8a612/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4badaa1..197d8dc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,18 @@ limitations under the License.
             <email>twilmes@gmail.com</email>
             <url>https://github.com/twilmes</url>
         </contributor>
+        <contributor>
+            <name>Harsh Thakkar</name>
+            <email>harsh9t@gmail.com</email>
+            <organization>University of Bonn</organization>
+            <organizationUrl>http://harshthakkar.in</organizationUrl>
+        </contributor>
+        <contributor>
+            <name>Dharmen Punjani</name>
+            <email>dharmen.punjani@gmail.com</email>
+            <organization>National and Kapodistrian University of Athens</organization>
+            <organizationUrl>http://wdaqua.eu/students/dharmen-punjani</organizationUrl>
+        </contributor>
     </contributors>
     <prerequisites>
         <maven>3.1.0</maven>
@@ -124,6 +136,7 @@ limitations under the License.
         <module>hadoop-gremlin</module>
         <module>spark-gremlin</module>
         <module>neo4j-gremlin</module>
+        <module>sparql-gremlin</module>
         <module>gremlin-driver</module>
         <module>gremlin-console</module>
         <module>gremlin-server</module>
@@ -680,6 +693,11 @@ limitations under the License.
                 </exclusions>
             </dependency>
             <dependency>
+                <groupId>org.apache.httpcomponents</groupId>
+                <artifactId>httpclient</artifactId>
+                <version>4.5.1</version>
+            </dependency>
+            <dependency>
                 <groupId>commons-httpclient</groupId>
                 <artifactId>commons-httpclient</artifactId>
                 <version>3.1</version>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b0f8a612/sparql-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/sparql-gremlin/pom.xml b/sparql-gremlin/pom.xml
index e134d31..d38a85d 100644
--- a/sparql-gremlin/pom.xml
+++ b/sparql-gremlin/pom.xml
@@ -2,55 +2,46 @@
 <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>
         <artifactId>tinkerpop</artifactId>
         <groupId>org.apache.tinkerpop</groupId>
         <version>3.3.2-SNAPSHOT</version>
     </parent>
-    <modelVersion>4.0.0</modelVersion>
-
     <artifactId>sparql-gremlin</artifactId>
-    <organization>
-        <name>WDAQUA-ITN</name>
-        <url>http://wdaqua.eu</url>
-    </organization>
-    <developers>
-        <developer>
-            <name>Harsh Thakkar</name>
-            <email>harsh9t@gmail.com</email>
-            <organization>University of Bonn</organization>
-            <organizationUrl>http://harshthakkar.in</organizationUrl>
-        </developer>
-        <developer>
-            <name>Dharmen Punjani</name>
-            <email>dharmen.punjani@gmail.com</email>
-            <organization>National and Kapodistrian University of Athens</organization>
-            <organizationUrl>http://wdaqua.eu/students/dharmen-punjani</organizationUrl>
-        </developer>
-    </developers>
+    <name>Apache TinkerPop :: SPARQL Gremlin</name>
 
     <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <jena.version>3.0.0</jena.version>
         <query.dir>src/test/resources/sparql/queries</query.dir>
     </properties>
 
     <dependencies>
-    <dependency>
-        <groupId>org.apache.jena</groupId>
-        <artifactId>apache-jena-libs</artifactId>
-        <type>pom</type>
-        <version>${jena.version}</version>
-    </dependency>
+        <dependency>
+            <groupId>org.apache.jena</groupId>
+            <artifactId>apache-jena-libs</artifactId>
+            <type>pom</type>
+            <version>3.0.0</version>
+            <exclusions>
+                <!-- self-conflict -->
+                <exclusion>
+                    <groupId>org.apache.httpcomponents</groupId>
+                    <artifactId>httpclient</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>gremlin-core</artifactId>
-            <version>3.3.2-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
             <artifactId>tinkergraph-gremlin</artifactId>
-            <version>3.3.2-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.tinkerpop</groupId>
@@ -59,5 +50,4 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
-
 </project>
\ No newline at end of file


[18/50] tinkerpop git commit: Merge branch 'tp33'

Posted by sp...@apache.org.
Merge branch 'tp33'


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

Branch: refs/heads/TINKERPOP-1878
Commit: f50aeb6d62009845f42d9558b7cc8e576c91cf4e
Parents: a2db39c dfe79c2
Author: Robert Dale <ro...@gmail.com>
Authored: Tue Jul 31 13:12:40 2018 -0400
Committer: Robert Dale <ro...@gmail.com>
Committed: Tue Jul 31 13:12:40 2018 -0400

----------------------------------------------------------------------
 pom.xml | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f50aeb6d/pom.xml
----------------------------------------------------------------------


[23/50] tinkerpop git commit: TINKERPOP-1878 Added some Traversal infrastructure

Posted by sp...@apache.org.
TINKERPOP-1878 Added some Traversal infrastructure

This is the start of getting Sparql working as a DSL in TinkerPop


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

Branch: refs/heads/TINKERPOP-1878
Commit: eadb8b947823878748b09b27e2e5f06a7379ecc2
Parents: b0f8a61
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jan 24 17:04:27 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 .../dsl/sparql/DefaultSparqlTraversal.java      |  55 ++++++++
 .../traversal/dsl/sparql/SparqlTraversal.java   |  68 +++++++++
 .../dsl/sparql/SparqlTraversalSource.java       | 138 +++++++++++++++++++
 .../traversal/strategy/SparqlStrategy.java      |  25 ++++
 4 files changed, 286 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eadb8b94/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/DefaultSparqlTraversal.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/DefaultSparqlTraversal.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/DefaultSparqlTraversal.java
new file mode 100644
index 0000000..133d4be
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/DefaultSparqlTraversal.java
@@ -0,0 +1,55 @@
+/*
+ * 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.sparql.process.traversal.dsl.sparql;
+
+import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class DefaultSparqlTraversal<S, E> extends DefaultTraversal<S, E> implements SparqlTraversal.Admin<S, E> {
+
+    public DefaultSparqlTraversal() {
+        super();
+    }
+
+    public DefaultSparqlTraversal(final SparqlTraversalSource sparqlTraversalSource) {
+        super(sparqlTraversalSource);
+    }
+
+    public DefaultSparqlTraversal(final Graph graph) {
+        super(graph);
+    }
+
+    @Override
+    public SparqlTraversal.Admin<S, E> asAdmin() {
+        return this;
+    }
+
+    @Override
+    public SparqlTraversal<S, E> iterate() {
+        return SparqlTraversal.Admin.super.iterate();
+    }
+
+    @Override
+    public DefaultSparqlTraversal<S, E> clone() {
+        return (DefaultSparqlTraversal<S, E>) super.clone();
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eadb8b94/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
new file mode 100644
index 0000000..efa9489
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
@@ -0,0 +1,68 @@
+/*
+ * 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.sparql.process.traversal.dsl.sparql;
+
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
+import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface SparqlTraversal<S, E> extends Traversal<S, E> {
+    public interface Admin<S, E> extends Traversal.Admin<S, E>, SparqlTraversal<S, E> {
+
+        @Override
+        public default <E2> SparqlTraversal.Admin<S, E2> addStep(final Step<?, E2> step) {
+            return (SparqlTraversal.Admin<S, E2>) Traversal.Admin.super.addStep((Step) step);
+        }
+
+        @Override
+        public default SparqlTraversal<S, E> iterate() {
+            return SparqlTraversal.super.iterate();
+        }
+
+        @Override
+        public SparqlTraversal.Admin<S, E> clone();
+    }
+
+    @Override
+    public default SparqlTraversal.Admin<S, E> asAdmin() {
+        return (SparqlTraversal.Admin<S, E>) this;
+    }
+
+    ////
+
+    /**
+     * Iterates the traversal presumably for the generation of side-effects.
+     */
+    @Override
+    public default SparqlTraversal<S, E> iterate() {
+        Traversal.super.iterate();
+        return this;
+    }
+
+    public static final class Symbols {
+
+        private Symbols() {
+            // static fields only
+        }
+
+        public static final String sparql = "sparql";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eadb8b94/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
new file mode 100644
index 0000000..3596716
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
@@ -0,0 +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.
+ */
+package org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.process.remote.RemoteConnection;
+import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.decoration.RemoteStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Transaction;
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class SparqlTraversalSource implements TraversalSource {
+    protected transient RemoteConnection connection;
+    protected final Graph graph;
+    protected TraversalStrategies strategies;
+    protected Bytecode bytecode = new Bytecode();
+
+    public SparqlTraversalSource(final Graph graph, final TraversalStrategies traversalStrategies) {
+        this.graph = graph;
+        this.strategies = traversalStrategies;
+    }
+
+    public SparqlTraversalSource(final Graph graph) {
+        this(graph, TraversalStrategies.GlobalCache.getStrategies(graph.getClass()));
+    }
+
+    @Override
+    public TraversalStrategies getStrategies() {
+        return this.strategies;
+    }
+
+    @Override
+    public Graph getGraph() {
+        return this.graph;
+    }
+
+    @Override
+    public Bytecode getBytecode() {
+        return this.bytecode;
+    }
+
+    @SuppressWarnings("CloneDoesntDeclareCloneNotSupportedException")
+    public SparqlTraversalSource clone() {
+        try {
+            final SparqlTraversalSource clone = (SparqlTraversalSource) super.clone();
+            clone.strategies = this.strategies.clone();
+            clone.bytecode = this.bytecode.clone();
+            return clone;
+        } catch (final CloneNotSupportedException e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+
+    //// CONFIGURATIONS
+
+    @Override
+    public SparqlTraversalSource withStrategies(final TraversalStrategy... traversalStrategies) {
+        return (SparqlTraversalSource) TraversalSource.super.withStrategies(traversalStrategies);
+    }
+
+    @Override
+    @SuppressWarnings({"unchecked"})
+    public SparqlTraversalSource withoutStrategies(final Class<? extends TraversalStrategy>... traversalStrategyClasses) {
+        return (SparqlTraversalSource) TraversalSource.super.withoutStrategies(traversalStrategyClasses);
+    }
+
+    @Override
+    public SparqlTraversalSource withRemote(final Configuration conf) {
+        return (SparqlTraversalSource) TraversalSource.super.withRemote(conf);
+    }
+
+    @Override
+    public SparqlTraversalSource withRemote(final String configFile) throws Exception {
+        return (SparqlTraversalSource) TraversalSource.super.withRemote(configFile);
+    }
+
+    @Override
+    public SparqlTraversalSource withRemote(final RemoteConnection connection) {
+        try {
+            // check if someone called withRemote() more than once, so just release resources on the initial
+            // connection as you can't have more than one. maybe better to toss IllegalStateException??
+            if (this.connection != null)
+                this.connection.close();
+        } catch (Exception ignored) {
+            // not sure there's anything to do here
+        }
+
+        this.connection = connection;
+        final TraversalSource clone = this.clone();
+        clone.getStrategies().addStrategies(new RemoteStrategy(connection));
+        return (SparqlTraversalSource) clone;
+    }
+
+    public <S> SparqlTraversal<S,String> sparql(final String query) {
+        final SparqlTraversalSource clone = this.clone();
+        clone.bytecode.addStep(SparqlTraversal.Symbols.sparql, query);
+        final SparqlTraversal.Admin<S, S> traversal = new DefaultSparqlTraversal<>(clone);
+        return traversal.addStep(new ConstantStep<S,String>(traversal, query));
+    }
+
+    public Transaction tx() {
+        return this.graph.tx();
+    }
+
+    @Override
+    public void close() throws Exception {
+        if (connection != null) connection.close();
+    }
+
+    @Override
+    public String toString() {
+        return StringFactory.traversalSourceString(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/eadb8b94/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
new file mode 100644
index 0000000..6440127
--- /dev/null
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
@@ -0,0 +1,25 @@
+/*
+ * 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.sparql.process.traversal.strategy;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class SparqlStrategy {
+}


[39/50] tinkerpop git commit: TINKERPOP-1878 Test for FILTER

Posted by sp...@apache.org.
TINKERPOP-1878 Test for FILTER

Also fixed how the SparqlStrategy was being added to the TraversalStrategies in SparqlTraversalSource...it was adding it globally and all spawned TraversalSource instances were getting that strategy.


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

Branch: refs/heads/TINKERPOP-1878
Commit: 35f5fc52d5d1cd96f3137caf1bf21323ac384c95
Parents: fceea43
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 16:29:55 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:06 2018 -0400

----------------------------------------------------------------------
 .../dsl/sparql/SparqlTraversalSource.java       |  2 +-
 .../dsl/sparql/SparqlTraversalSourceTest.java   | 23 ++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/35f5fc52/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
index cc54aa5..f78708b 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
@@ -47,7 +47,6 @@ public class SparqlTraversalSource implements TraversalSource {
     public SparqlTraversalSource(final Graph graph, final TraversalStrategies traversalStrategies) {
         this.graph = graph;
         this.strategies = traversalStrategies;
-        this.strategies.addStrategies(SparqlStrategy.instance());
     }
 
     public SparqlTraversalSource(final Graph graph) {
@@ -126,6 +125,7 @@ public class SparqlTraversalSource implements TraversalSource {
      */
     public <S> SparqlTraversal<S,?> sparql(final String query) {
         final SparqlTraversalSource clone = this.clone();
+        clone.getStrategies().addStrategies(SparqlStrategy.instance());
 
         // this is a bit of a hack to get remote traversals to work cleanly. on the remote side, we'd expect a
         // GraphTraversalSource not a SparqlTraversalSource (given that sparql-gremlin is to be implemented in the

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/35f5fc52/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
index 1b39813..4092e58 100644
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -18,16 +18,21 @@
  */
 package org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql;
 
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
 import org.junit.Test;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
 import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
+import static org.junit.Assert.assertEquals;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -36,6 +41,7 @@ public class SparqlTraversalSourceTest {
 
     private static final Graph graph = TinkerFactory.createModern();
     private static final SparqlTraversalSource g = graph.traversal(SparqlTraversalSource.class);
+    private static final GraphTraversalSource _g = graph.traversal();
 
     @Test
     public void shouldFindAllPersonsNamesAndAges() {
@@ -88,4 +94,21 @@ public class SparqlTraversalSourceTest {
         final List<?> x = g.sparql("SELECT ?name WHERE { ?person v:name ?name } ORDER BY DESC(?name)").toList();
         assertThat(x, contains("vadas", "ripple", "peter", "marko", "lop", "josh"));
     }
+
+    @Test
+    public void shouldFilter() {
+        final Map<String,Vertex> x = (Map) g.sparql(  "SELECT ?a ?b ?c\n" +
+                                                            "WHERE {\n" +
+                                                            "  ?a v:label \"person\" .\n" +
+                                                            "  ?a e:knows ?b .\n" +
+                                                            "  ?a e:created ?c .\n" +
+                                                            "  ?b e:created ?c .\n" +
+                                                            "  ?a v:age ?d .\n" +
+                                                            "    FILTER (?d < 30)\n" +
+                                                            "}").next();
+
+        assertEquals(x.get("a"), _g.V(1).next());
+        assertEquals(x.get("b"), _g.V(4).next());
+        assertEquals(x.get("c"), _g.V(3).next());
+    }
 }


[28/50] tinkerpop git commit: TINKERPOP-1878 Test cleanup for sparql-gremlin

Posted by sp...@apache.org.
TINKERPOP-1878 Test cleanup for sparql-gremlin


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

Branch: refs/heads/TINKERPOP-1878
Commit: 3bf92605e42c62c566e8062ebc0207a6d9adafe5
Parents: 492db18
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 08:10:48 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 sparql-gremlin/pom.xml                          |  10 +-
 .../dsl/sparql/SparqlTraversalSource.java       |   4 +-
 .../gremlin/sparql/ResourceHelper.java          |  37 ---
 .../sparql/SparqlToGremlinCompilerTest.java     | 223 -------------------
 .../dsl/sparql/SparqlTraversalSourceTest.java   |  31 ++-
 5 files changed, 36 insertions(+), 269 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3bf92605/sparql-gremlin/pom.xml
----------------------------------------------------------------------
diff --git a/sparql-gremlin/pom.xml b/sparql-gremlin/pom.xml
index 0e3da38..731b822 100644
--- a/sparql-gremlin/pom.xml
+++ b/sparql-gremlin/pom.xml
@@ -41,9 +41,13 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.tinkerpop</groupId>
-            <artifactId>gremlin-test</artifactId>
-            <version>${project.version}</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-all</artifactId>
             <scope>test</scope>
         </dependency>
     </dependencies>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3bf92605/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
index deb16f7..cc54aa5 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
@@ -28,6 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
@@ -46,6 +47,7 @@ public class SparqlTraversalSource implements TraversalSource {
     public SparqlTraversalSource(final Graph graph, final TraversalStrategies traversalStrategies) {
         this.graph = graph;
         this.strategies = traversalStrategies;
+        this.strategies.addStrategies(SparqlStrategy.instance());
     }
 
     public SparqlTraversalSource(final Graph graph) {
@@ -122,7 +124,7 @@ public class SparqlTraversalSource implements TraversalSource {
     /**
      * The start step for a SPARQL based traversal that accepts a string representation of the query to execute.
      */
-    public <S> SparqlTraversal<S,String> sparql(final String query) {
+    public <S> SparqlTraversal<S,?> sparql(final String query) {
         final SparqlTraversalSource clone = this.clone();
 
         // this is a bit of a hack to get remote traversals to work cleanly. on the remote side, we'd expect a

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3bf92605/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java
deleted file mode 100644
index 4f58e61..0000000
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/ResourceHelper.java
+++ /dev/null
@@ -1,37 +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.sparql;
-
-import org.apache.commons.io.IOUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author Daniel Kuppitz (http://gremlin.guru)
- */
-public class ResourceHelper {
-
-    public static String loadQuery(final String prefix, final int number) throws IOException {
-        final String path = "/queries/" + prefix + number + ".sparql";
-        final InputStream stream = ResourceHelper.class.getResourceAsStream(path);
-        return IOUtils.toString(stream, "UTF-8");
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3bf92605/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java
deleted file mode 100644
index 3fb49e8..0000000
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompilerTest.java
+++ /dev/null
@@ -1,223 +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.sparql;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.apache.tinkerpop.gremlin.process.computer.Computer;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import static org.apache.tinkerpop.gremlin.sparql.SparqlToGremlinCompiler.convertToGremlinTraversal;
-import static org.junit.Assert.assertEquals;
-
-
-import java.io.IOException;
-
-import static org.apache.tinkerpop.gremlin.sparql.ResourceHelper.loadQuery;
-
-
-public class SparqlToGremlinCompilerTest {
-
-    private Graph modern, crew;
-    private GraphTraversalSource mg, cg;
-    private GraphTraversalSource mc, cc;
-/*
-    @Before
-    public void setUp() throws Exception {
-        modern = TinkerFactory.createModern();
-        mg = modern.traversal();
-        mc = modern.traversal(computer());
-        crew = TinkerFactory.createTheCrew();
-        cg = modern.traversal();
-        cc = modern.traversal(computer());
-    }
-
-    @Ignore
-    @Test
-    public void play() throws IOException {
-        final String query = loadQuery("modern", 11);
-        final Traversal traversal = convertToGremlinTraversal(modern, query);
-        System.out.println(traversal);
-        System.out.println(traversal.toList());
-        System.out.println(traversal);
-    }
-
-    /* Modern */
-
- /*   @Test
-    public void testModern1() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").hasLabel("person"),
-                as("a").out("knows").as("b"),
-                as("a").out("created").as("c"),
-                as("b").out("created").as("c"),
-                as("a").values("age").as("d")).where(as("d").is(lt(30))).
-                select("a", "b", "c");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 1)));
-    }
-
-    @Test
-    public void testModern2() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").hasLabel("person"),
-                as("a").out("knows").as("b"),
-                as("a").out("created").as("c"),
-                as("b").out("created").as("c"),
-                as("a").values("age").as("d")).where(as("d").is(lt(30)));
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 2)));
-    }
-
-    @Test
-    public void testModern3() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("person").values("name").as("name"),
-                as("person").values("age").as("age")).select("name", "age");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 3)));
-    }
-
-    @Test
-    public void testModern4() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("person").values("name").as("name"),
-                as("person").values("age").as("age"),
-                as("person").out("created").as("project"),
-                as("project").values("name").is("lop")).select("name", "age");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 4)));
-    }
-
-    @Test
-    public void testModern5() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("person").values("name").as("name"),
-                as("person").values("age").is(29)).select("name");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 5)));
-    }
-
-    @Test
-    public void testModern6() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("person").values("name").as("name"),
-                as("person").values("age").as("age")).where(and(as("age").is(gt(30)), as("age").is(lt(40)))).
-                select("name", "age");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 6)));
-    }
-
-    @Test
-    public void testModern7() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("person").values("name").as("name"),
-                as("person").values("age").as("age")).where(or(as("age").is(lt(30)), as("age").is(gt(40)))).
-                select("name", "age");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 7)));
-    }
-
-    @Test
-    public void testModern8() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("person").values("name").as("name"),
-                as("person").values("age").as("age")).where(
-                or(and(as("age").is(gt(30)), as("age").is(lt(40))), as("name").is("marko"))).
-                select("name", "age");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 8)));
-    }
-
-    @Test
-    public void testModern9() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").values("name").as("name")).where(as("a").values("age")).
-                select("name");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 9)));
-    }
-
-    @Test
-    public void testModern10() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").values("name").as("name")).where(__.not(as("a").values("age"))).
-                select("name");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 10)));
-    }
-
-    @Test
-    public void testModern11() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").out("created").as("b"),
-                as("a").values("name").as("name")).dedup("name").select("name");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 11)));
-    }
-
-    @Test
-    public void testModern12() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").out("created").as("b"),
-                as("b").values("name").as("name")).dedup();
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 12)));
-    }
-
-    @Test
-    public void testModern13() throws Exception {
-        final GraphTraversal expected = mg.V().match(
-                as("a").out("created").as("b"),
-                as("a").values("name").as("c")).dedup("a", "b", "c").select("a", "b", "c");
-        assertEquals(expected, convertToGremlinTraversal(modern, loadQuery("modern", 13)));
-    }
-
-    /* The Crew */
-
- /*   @Test
-    public void testCrew1() throws Exception {
-        final GraphTraversal expected = cg.V().match(
-                as("a").values("name").is("daniel"),
-                as("a").properties("location").as("b"),
-                as("b").value().as("c"),
-                as("b").values("startTime").as("d")).
-                select("c", "d");
-        assertEquals(expected, convertToGremlinTraversal(crew, loadQuery("crew", 1)));
-    }
-
-    /* Computer Mode */
-
-  /*  @Test
-    public void testModernInComputerMode() throws Exception {
-        final GraphTraversal expected = mc.V().match(
-                as("a").hasLabel("person"),
-                as("a").out("knows").as("b"),
-                as("a").out("created").as("c"),
-                as("b").out("created").as("c"),
-                as("a").values("age").as("d")).where(as("d").is(lt(30))).
-                select("a", "b", "c");
-        assertEquals(expected, convertToGremlinTraversal(mc, loadQuery("modern", 1)));
-    }
-
-    @Test
-    public void testCrewInComputerMode() throws Exception {
-        final GraphTraversal expected = cc.V().match(
-                as("a").values("name").is("daniel"),
-                as("a").properties("location").as("b"),
-                as("b").value().as("c"),
-                as("b").values("startTime").as("d")).
-                select("c", "d");
-        assertEquals(expected, convertToGremlinTraversal(crew, loadQuery("crew", 1)));
-    } */
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3bf92605/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
index 9e5ffc0..9bb6025 100644
--- a/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
+++ b/sparql-gremlin/src/test/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSourceTest.java
@@ -18,11 +18,16 @@
  */
 package org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql;
 
-import org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
 import org.junit.Test;
 
+import java.util.HashMap;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
+
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -31,9 +36,25 @@ public class SparqlTraversalSourceTest {
     @Test
     public void shouldDoStuff() {
         final Graph graph = TinkerFactory.createModern();
-        final SparqlTraversalSource g = graph.traversal(SparqlTraversalSource.class).
-                                                withStrategies(SparqlStrategy.instance());
-        final Object x = g.sparql("SELECT ?name ?age WHERE { ?person v:name ?name . ?person v:age ?age }").toList();
-        System.out.println(x);
+        final SparqlTraversalSource g = graph.traversal(SparqlTraversalSource.class);
+        final List<?> x = g.sparql("SELECT ?name ?age WHERE { ?person v:name ?name . ?person v:age ?age }").toList();
+        assertThat(x, containsInAnyOrder(
+                new HashMap<String,Object>(){{
+                    put("name", "marko");
+                    put("age", 29);
+                }},
+                new HashMap<String,Object>(){{
+                    put("name", "vadas");
+                    put("age", 27);
+                }},
+                new HashMap<String,Object>(){{
+                    put("name", "josh");
+                    put("age", 32);
+                }},
+                new HashMap<String,Object>(){{
+                    put("name", "peter");
+                    put("age", 35);
+                }}
+        ));
     }
 }


[05/50] tinkerpop git commit: Merge branch 'tp32' into tp33

Posted by sp...@apache.org.
Merge branch 'tp32' into tp33


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

Branch: refs/heads/TINKERPOP-1878
Commit: 798510679b5af84ffc1ecdfa5ef86d52229cbc99
Parents: 9b693c0 3b8c828
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 16:29:37 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 16:29:37 2018 -0400

----------------------------------------------------------------------
 docs/src/recipes/element-existence.asciidoc | 91 ++++++++++++++++++++++++
 docs/src/recipes/index.asciidoc             |  2 +
 2 files changed, 93 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/79851067/docs/src/recipes/index.asciidoc
----------------------------------------------------------------------


[03/50] tinkerpop git commit: Consistent use of hyphen in step references CTR

Posted by sp...@apache.org.
Consistent use of hyphen in step references CTR


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

Branch: refs/heads/TINKERPOP-1878
Commit: 9ab5efa6772bb831238f6c9a4e46fc925a45ddaa
Parents: 13ff64c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 27 07:19:12 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 27 07:19:12 2018 -0400

----------------------------------------------------------------------
 docs/src/upgrade/release-3.4.x.asciidoc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9ab5efa6/docs/src/upgrade/release-3.4.x.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.4.x.asciidoc b/docs/src/upgrade/release-3.4.x.asciidoc
index 97e14e3..2d699dc 100644
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@ -31,9 +31,9 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.4.0/CHANGELOG.asc
 
 ==== with() Step
 
-This version of TinkerPop introduces the `with()` step to Gremlin. It isn't really a step but is instead a step
+This version of TinkerPop introduces the `with()`-step to Gremlin. It isn't really a step but is instead a step
 modulator. This modulator allows the step it is modifying to accept configurations that can be used to alter the
-behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()` step
+behavior of the step itself. A good example of its usage is shown with the revised syntax of the `pageRank()`-step
 which now uses `with()` to replace the old `by()` options:
 
 [groovy]
@@ -47,7 +47,7 @@ g.V().hasLabel('person').
   valueMap('name','friendRank')
 ----
 
-A similar change was made for `peerPressure()` step:
+A similar change was made for `peerPressure()`-step:
 
 [groovy]
 ----
@@ -306,7 +306,7 @@ See: link:https://issues.apache.org/jira/browse/TINKERPOP-1518[TINKERPOP-1518]
 ===== Configuring Interface
 
 There were some changes to interfaces that were related to `Step`. A new `Configuring` interface was added that was
-helpful in the implementation of the `with()` step modulator. This new interface extends the `Parameterizing` interface
+helpful in the implementation of the `with()`-step modulator. This new interface extends the `Parameterizing` interface
 (which moved to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with the other step interfaces) and
 in turn is extended by the `Mutating` interface. Making this change meant that the `Mutating.addPropertyMutations()`
 method could be removed in favor of the new `Configuring.configure()` method.


[47/50] tinkerpop git commit: TINKERPOP-1878 Fixed up formatting of sparql-gremlin image

Posted by sp...@apache.org.
TINKERPOP-1878 Fixed up formatting of sparql-gremlin image


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

Branch: refs/heads/TINKERPOP-1878
Commit: 8732c6b5505646ab8d22902176c2afe20f4e7d17
Parents: 5c82aa1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun May 13 11:02:26 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:35:07 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/transpilers.asciidoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8732c6b5/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
index 390d4f4..3211857 100644
--- a/docs/src/reference/transpilers.asciidoc
+++ b/docs/src/reference/transpilers.asciidoc
@@ -24,7 +24,7 @@ Gremlin Transpiler enables a particular query language to work on any TinkerPop-
 
 == SPARQL-Gremlin
 
-image::gremlin-standing.png[]
+image::gremlintron.png[width=225]
 
 The SPARQL-Gremlin transpiler, transforms link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin
 traversals. It uses the https://jena.apache.org/index.html[Apache Jena] SPARQL processor


[24/50] tinkerpop git commit: TINKERPOP-1878 Minor javadoc and code cleanup

Posted by sp...@apache.org.
TINKERPOP-1878 Minor javadoc and code cleanup


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

Branch: refs/heads/TINKERPOP-1878
Commit: 48ae8aa2bd5db3f8a060f11bab8bf5d848d12c27
Parents: ad8bba6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 15:36:53 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Aug 1 09:32:58 2018 -0400

----------------------------------------------------------------------
 .../process/traversal/dsl/sparql/SparqlTraversal.java   | 12 +++---------
 .../traversal/dsl/sparql/SparqlTraversalSource.java     |  8 +++++++-
 .../process/traversal/strategy/SparqlStrategy.java      | 11 ++++++++---
 3 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/48ae8aa2/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
index efa9489..843267d 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversal.java
@@ -22,6 +22,9 @@ import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 
 /**
+ * The {@code SparqlTraversal} has no additional traversal steps. The only step available for "SPARQL" is the
+ * {@link SparqlTraversalSource#sparql(String)} start step.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public interface SparqlTraversal<S, E> extends Traversal<S, E> {
@@ -56,13 +59,4 @@ public interface SparqlTraversal<S, E> extends Traversal<S, E> {
         Traversal.super.iterate();
         return this;
     }
-
-    public static final class Symbols {
-
-        private Symbols() {
-            // static fields only
-        }
-
-        public static final String sparql = "sparql";
-    }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/48ae8aa2/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
index 3596716..b156ed1 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/dsl/sparql/SparqlTraversalSource.java
@@ -25,12 +25,15 @@ import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 
 /**
+ * A {@link TraversalSource} implementation that spawns {@link SparqlTraversal} instances.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class SparqlTraversalSource implements TraversalSource {
@@ -115,9 +118,12 @@ public class SparqlTraversalSource implements TraversalSource {
         return (SparqlTraversalSource) clone;
     }
 
+    /**
+     * The start step for a SPARQL based traversal that accepts a string representation of the query to execute.
+     */
     public <S> SparqlTraversal<S,String> sparql(final String query) {
         final SparqlTraversalSource clone = this.clone();
-        clone.bytecode.addStep(SparqlTraversal.Symbols.sparql, query);
+        clone.bytecode.addStep(GraphTraversal.Symbols.constant, query);
         final SparqlTraversal.Admin<S, S> traversal = new DefaultSparqlTraversal<>(clone);
         return traversal.addStep(new ConstantStep<S,String>(traversal, query));
     }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/48ae8aa2/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
----------------------------------------------------------------------
diff --git a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
index 07ac4cf..bb0b326 100644
--- a/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
+++ b/sparql-gremlin/src/main/java/org/apache/tinkerpop/gremlin/sparql/process/traversal/strategy/SparqlStrategy.java
@@ -22,17 +22,22 @@ import org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decorati
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalMapStep;
 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.sparql.SparqlToGremlinCompiler;
+import org.apache.tinkerpop.gremlin.sparql.process.traversal.dsl.sparql.SparqlTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 
 import java.util.Collections;
 import java.util.Set;
 
 /**
+ * This {@link TraversalStrategy} is used in conjunction with the {@link SparqlTraversalSource} which has a single
+ * {@code sparql()} start step. That step adds a {@link ConstantStep} to the traversal with the SPARQL query within
+ * it as a string value. This strategy finds that step and transpiles it to a Gremlin traversal which then replaces
+ * the {@link ConstantStep}.
+ *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.DecorationStrategy>
@@ -69,11 +74,11 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
                 sparqlTraversal.asAdmin().getSteps().forEach(s -> traversal.addStep(s));
             } else {
                 // The ConstantStep expects a string value
-                throw new IllegalStateException("SparqlStrategy cannot be applied to this traversal");
+                throw new IllegalStateException("SparqlStrategy cannot be applied to a traversal that does not consist of a single ConstantStep<?,String>");
             }
         } else {
             // SparqlStrategy requires that there be one step and it be a ConstantStep that contains some SPARQL
-            throw new IllegalStateException("SparqlStrategy cannot be applied to this traversal");
+            throw new IllegalStateException("SparqlStrategy cannot be applied to a traversal that does not consist of a single ConstantStep<?,String>");
         }
     }
 }