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/16 16:57:49 UTC

[01/50] tinkerpop git commit: Merge branch 'tp32' into tp33 [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1342 046747b22 -> ee270e9ec (forced update)


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/25ae7551
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/25ae7551
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/25ae7551

Branch: refs/heads/TINKERPOP-1342
Commit: 25ae755118cc5d968652d4fd36bccb4d78ce9a7d
Parents: 5676e86 ea18963
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Aug 13 19:23:39 2018 +0200
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Mon Aug 13 19:23:39 2018 +0200

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 gremlin-dotnet/glv/Gremlin.Net.csproj.template  |   3 +-
 .../src/Gremlin.Net/Gremlin.Net.csproj          |   3 +-
 .../IO/GraphSON/BigIntegerDeserializer.cs       |  38 +++++++
 .../IO/GraphSON/BigIntegerSerializer.cs         |  37 +++++++
 .../IO/GraphSON/ByteBufferDeserializer.cs       |  36 +++++++
 .../IO/GraphSON/ByteBufferSerializer.cs         |  36 +++++++
 .../Structure/IO/GraphSON/ByteConverter.cs      |  33 ++++++
 .../Structure/IO/GraphSON/CharConverter.cs      |  34 ++++++
 .../Structure/IO/GraphSON/DateDeserializer.cs   |  38 +++++++
 .../Structure/IO/GraphSON/DateSerializer.cs     |   9 +-
 .../IO/GraphSON/DurationDeserializer.cs         |  37 +++++++
 .../Structure/IO/GraphSON/DurationSerializer.cs |  38 +++++++
 .../Structure/IO/GraphSON/GraphSONReader.cs     |  14 ++-
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  13 ++-
 .../Structure/IO/GraphSON/Int16Converter.cs     |  34 ++++++
 .../Gremlin.Net.UnitTest.csproj                 |   1 +
 .../IO/GraphSON/GraphSONReaderTests.cs          | 108 +++++++++++++++++++
 .../IO/GraphSON/GraphSONWriterTests.cs          |  65 +++++++++++
 19 files changed, 563 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/25ae7551/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/25ae7551/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs
index 94fcd8d,d11b14c..5ced99a
--- a/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs
+++ b/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONReader.cs
@@@ -52,8 -49,15 +52,16 @@@ namespace Gremlin.Net.Structure.IO.Grap
                  {"g:Property", new PropertyDeserializer()},
                  {"g:VertexProperty", new VertexPropertyDeserializer()},
                  {"g:Path", new PathDeserializer()},
 +                {"g:T", new TDeserializer()},
-                 {"gx:BigDecimal", new DecimalConverter()}
+ 
+                 //Extended
+                 {"gx:BigDecimal", new DecimalConverter()},
+                 {"gx:Duration", new DurationDeserializer()},
+                 {"gx:BigInteger", new BigIntegerDeserializer()},
+                 {"gx:Byte", new ByteConverter()},
+                 {"gx:ByteBuffer", new ByteBufferDeserializer()},
+                 {"gx:Char", new CharConverter()},
+                 {"gx:Int16", new Int16Converter() }
              };
  
          /// <summary>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/25ae7551/gremlin-dotnet/src/Gremlin.Net/Structure/IO/GraphSON/GraphSONWriter.cs
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/25ae7551/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
index c93630f,74bf385..00cf853
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
@@@ -34,32 -36,22 +35,43 @@@ namespace Gremlin.Net.UnitTest.Structur
  {
      public class GraphSONReaderTests
      {
 -        private GraphSONReader CreateStandardGraphSONReader()
 -        {
 -            return new GraphSONReader();
 +        /// <summary>
 +        /// Parameters for each test supporting multiple versions of GraphSON
 +        /// </summary>
 +        public static IEnumerable<object[]> Versions => new []
 +        {
 +            new object[] { 2 },
 +            new object[] { 3 }
 +        };
 +        
 +        /// <summary>
 +        /// Parameters for each collections test supporting multiple versions of GraphSON
 +        /// </summary>
 +        public static IEnumerable<object[]> VersionsSupportingCollections => new []
 +        {
 +            new object[] { 3 }
 +        };
 +        
 +        private GraphSONReader CreateStandardGraphSONReader(int version)
 +        {
 +            if (version == 3)
 +            {
 +                return new GraphSON3Reader();
 +            }
 +            return new GraphSON2Reader();
          }
  
+         //During CI, we encountered a case where Newtonsoft.Json version 9.0.0
+         //was loaded although there is no obvious direct nor indirect dependency
+         //on that version of the library. An explicit reference to version
+         //11.0.0 from Gremlin.Net.UnitTest fixes that, however, it is
+         //still unclear what causes the downgrade. Until resolution, we keep this test.
+         [Fact]
+         public void NewtonsoftJsonVersionShouldSupportReallyBigIntegers()
+         {
+             Assert.Equal(new Version(11, 0, 0, 0), typeof(JToken).Assembly.GetName().Version);
+         }
+ 
          [Fact]
          public void ShouldDeserializeWithCustomDeserializerForNewType()
          {
@@@ -416,6 -334,102 +428,102 @@@
              Assert.NotNull(d);
              Assert.Equal("g:Traverser", (string)d["@type"]);
          }
+ 
 -        [Fact]
 -        public void ShouldDeserializeDurationToTimeSpan()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeDurationToTimeSpan(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:Duration\",\"@value\":\"PT120H\"}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             TimeSpan deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(TimeSpan.FromDays(5), deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeBigInteger()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeBigInteger(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:BigInteger\",\"@value\":123456789}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             BigInteger deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(BigInteger.Parse("123456789"), deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeBigIntegerValueAsString()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeBigIntegerValueAsString(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:BigInteger\",\"@value\":\"123456789\"}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             BigInteger deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(BigInteger.Parse("123456789"), deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeReallyBigIntegerValue()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeReallyBigIntegerValue(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:BigInteger\",\"@value\":123456789987654321123456789987654321}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             BigInteger deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(BigInteger.Parse("123456789987654321123456789987654321"), deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeByte()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeByte(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:Byte\",\"@value\":1}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             var deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(1, deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeByteBuffer()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeByteBuffer(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:ByteBuffer\",\"@value\":\"c29tZSBieXRlcyBmb3IgeW91\"}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             var deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(Convert.FromBase64String("c29tZSBieXRlcyBmb3IgeW91"), deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeChar()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeChar(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:Char\",\"@value\":\"x\"}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             var deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal('x', deserializedValue);
+         }
+ 
 -        [Fact]
 -        public void ShouldDeserializeInt16()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldDeserializeInt16(int version)
+         {
+             var serializedValue = "{\"@type\":\"gx:Int16\",\"@value\":100}";
 -            var reader = CreateStandardGraphSONReader();
++            var reader = CreateStandardGraphSONReader(version);
+ 
+             var jObject = JObject.Parse(serializedValue);
+             var deserializedValue = reader.ToObject(jObject);
+ 
+             Assert.Equal(100, deserializedValue);
+         }
      }
  
      internal class TestGraphSONDeserializer : IGraphSONDeserializer

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/25ae7551/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
----------------------------------------------------------------------
diff --cc gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
index 9f62abe,a544fb3..2d30fa1
--- a/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONWriterTests.cs
@@@ -406,6 -347,70 +407,70 @@@ namespace Gremlin.Net.UnitTest.Structur
                  "{\"@type\":\"g:Lambda\",\"@value\":{\"script\":\"{ it.get() }\",\"language\":\"gremlin-groovy\",\"arguments\":-1}}";
              Assert.Equal(expected, graphSon);
          }
+ 
 -        [Fact]
 -        public void ShouldSerializeTimeSpan()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeTimeSpan(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+             var timeSpan = new TimeSpan(5, 4, 3, 2, 1);
+ 
+             var graphSon = writer.WriteObject(timeSpan);
+ 
+             const string expected = "{\"@type\":\"gx:Duration\",\"@value\":\"P5DT4H3M2.001S\"}";
+             Assert.Equal(expected, graphSon);
+         }
+ 
 -        [Fact]
 -        public void ShouldSerializeBigInteger()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeBigInteger(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+             var bigInteger = BigInteger.Parse("123456789987654321123456789987654321");
+ 
+             var graphSon = writer.WriteObject(bigInteger);
+ 
+             const string expected = "{\"@type\":\"gx:BigInteger\",\"@value\":\"123456789987654321123456789987654321\"}";
+             Assert.Equal(expected, graphSon);
+         }
+ 
 -        [Fact]
 -        public void ShouldSerializeByte()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeByte(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+ 
+             var graphSon = writer.WriteObject((byte)1);
+ 
+             Assert.Equal("{\"@type\":\"gx:Byte\",\"@value\":1}", graphSon);
+         }
+ 
 -        [Fact]
 -        public void ShouldSerializeByteBuffer()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeByteBuffer(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+ 
+             var graphSon = writer.WriteObject(Convert.FromBase64String("c29tZSBieXRlcyBmb3IgeW91"));
+ 
+             Assert.Equal("{\"@type\":\"gx:ByteBuffer\",\"@value\":\"c29tZSBieXRlcyBmb3IgeW91\"}", graphSon);
+         }
+ 
 -        [Fact]
 -        public void ShouldSerializeChar()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeChar(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+ 
+             var graphSon = writer.WriteObject('x');
+ 
+             Assert.Equal("{\"@type\":\"gx:Char\",\"@value\":\"x\"}", graphSon);
+         }
+ 
 -        [Fact]
 -        public void ShouldSerializeInt16()
++        [Theory, MemberData(nameof(Versions))]
++        public void ShouldSerializeInt16(int version)
+         {
 -            var writer = CreateStandardGraphSONWriter();
++            var writer = CreateGraphSONWriter(version);
+ 
+             var graphSon = writer.WriteObject((short)100);
+ 
+             Assert.Equal("{\"@type\":\"gx:Int16\",\"@value\":100}", graphSon);
+         }
      }
  
      internal class TestGraphSONSerializer : IGraphSONSerializer


[11/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/7dcfd7ec
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7dcfd7ec
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7dcfd7ec

Branch: refs/heads/TINKERPOP-1342
Commit: 7dcfd7eca1d2d49f41fc1300dc43160491e218cf
Parents: bd1b8c0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 15:36:53 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/7dcfd7ec/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/7dcfd7ec/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/7dcfd7ec/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>");
         }
     }
 }


[09/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/a0ffa546
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a0ffa546
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a0ffa546

Branch: refs/heads/TINKERPOP-1342
Commit: a0ffa54635dca9397000cc51f7e6c54ad6efbb28
Parents: ff3a2e0
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jan 24 15:23:57 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/a0ffa546/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a3496f3..dfb5824 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/a0ffa546/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


[04/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/ff3a2e02
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ff3a2e02
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ff3a2e02

Branch: refs/heads/TINKERPOP-1342
Commit: ff3a2e02fc0fb374a8db192f78e6e94d5e192b22
Parents: edf1ddc
Author: harsh9t <ha...@gmail.com>
Authored: Thu Jan 18 01:33:29 2018 +0100
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:19 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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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/ff3a2e02/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


[21/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/973d8cfc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/973d8cfc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/973d8cfc

Branch: refs/heads/TINKERPOP-1342
Commit: 973d8cfc457de12c4430d0fe73756a3e2912682a
Parents: 5967cca
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 29 09:37:15 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/973d8cfc/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/973d8cfc/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


[14/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/3b337501
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3b337501
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3b337501

Branch: refs/heads/TINKERPOP-1342
Commit: 3b3375018e8fe6a1982144a9a158c5741b689681
Parents: a8e25a8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 15:41:10 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:22 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/3b337501/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/3b337501/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);
+                }}
+        ));
+    }
 }


[27/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/95b445f9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/95b445f9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/95b445f9

Branch: refs/heads/TINKERPOP-1342
Commit: 95b445f9f0a512e3bc4c1760a71e7ed672442abe
Parents: 0c815eb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun May 13 11:07:10 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/95b445f9/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>


[23/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/4e114bb2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4e114bb2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4e114bb2

Branch: refs/heads/TINKERPOP-1342
Commit: 4e114bb22b167c48260801d66bdda2b966fa7c2e
Parents: 7343ca8
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Mar 28 10:29:43 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4e114bb2/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


[24/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/510bbea9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/510bbea9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/510bbea9

Branch: refs/heads/TINKERPOP-1342
Commit: 510bbea9b137da0d0f802a90faef9138c959089a
Parents: 46e8532
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun May 13 10:53:56 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/510bbea9/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]
 ----


[33/50] tinkerpop git commit: TINKERPOP-1878 Minor formatting fix

Posted by sp...@apache.org.
TINKERPOP-1878 Minor formatting fix


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

Branch: refs/heads/TINKERPOP-1342
Commit: 85ea6eaa5a9c95da9be34475340058548e294991
Parents: 05a7995
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 1 10:01:51 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/sparql/SparqlToGremlinCompiler.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/85ea6eaa/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 e3b4ecb..4e00045 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,7 +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.OpLeftJoin;
 import org.apache.jena.sparql.algebra.op.OpUnion;
 import org.apache.jena.sparql.core.Var;
 import org.apache.jena.sparql.core.VarExprList;


[30/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/9d96a7f3
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9d96a7f3
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9d96a7f3

Branch: refs/heads/TINKERPOP-1342
Commit: 9d96a7f35e2c55478dffb6a0fe29a834f226024f
Parents: 4f45cde
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jun 20 07:25:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/9d96a7f3/docs/site/home/index.html
----------------------------------------------------------------------
diff --git a/docs/site/home/index.html b/docs/site/home/index.html
index 472e77a..bbba419 100644
--- a/docs/site/home/index.html
+++ b/docs/site/home/index.html
@@ -259,6 +259,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/9d96a7f3/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/9d96a7f3/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/9d96a7f3/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/9d96a7f3/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/9d96a7f3/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/9d96a7f3/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));


[32/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/f02333a8
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f02333a8
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f02333a8

Branch: refs/heads/TINKERPOP-1342
Commit: f02333a8f71296443f723d0dfaa31ed7902fd9e0
Parents: 627c9a1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 16:29:55 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/f02333a8/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/f02333a8/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());
+    }
 }


[16/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/6211e76c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6211e76c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6211e76c

Branch: refs/heads/TINKERPOP-1342
Commit: 6211e76cee0f6a93cd781f9d6b65be4264072e53
Parents: b853042
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 09:39:28 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:22 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/6211e76c/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);
     }
 }


[47/50] tinkerpop git commit: Fixed up pageRank() tests to be more GLV compliant CTR

Posted by sp...@apache.org.
Fixed up pageRank() tests to be more GLV compliant CTR


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

Branch: refs/heads/TINKERPOP-1342
Commit: 69d46f7335fac24e2210987eefa16036ceea8d46
Parents: bdda913
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Aug 14 12:51:07 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Aug 14 12:51:07 2018 -0400

----------------------------------------------------------------------
 .../test/cucumber/feature-steps.js              |  6 +-
 gremlin-test/features/map/PageRank.feature      | 47 +++++++++++-----
 .../traversal/step/map/PageRankTest.java        | 59 ++++++++++----------
 3 files changed, 63 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/69d46f73/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 0cddc02..8a14112 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -67,9 +67,9 @@ const ignoredScenarios = {
   'g_V_outXcreatedX_pageRank_byXbothEX_byXprojectRankX_timesX0X_valueMapXname_projectRankX': new IgnoreError(ignoreReason.computerNotSupported),
   'g_V_pageRank_order_byXpageRank_decrX_byXnameX_name': new IgnoreError(ignoreReason.computerNotSupported),
   'g_V_pageRank_order_byXpageRank_decrX_name_limitX2X': new IgnoreError(ignoreReason.computerNotSupported),
-  'g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX': new IgnoreError(ignoreReason.computerNotSupported),
-  'g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX': new IgnoreError(ignoreReason.computerNotSupported),
-  'g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX': new IgnoreError(ignoreReason.computerNotSupported),
+  'g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_project_byXnameX_byXvaluesXfriendRankX_mathX': new IgnoreError(ignoreReason.computerNotSupported),
+  'g_V_hasLabelXpersonX_pageRank_byXpageRankX_project_byXnameX_byXvaluesXpageRankX_mathX': new IgnoreError(ignoreReason.computerNotSupported),
+  'g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX_by_byXmathX': new IgnoreError(ignoreReason.computerNotSupported),
   'g_V_hasLabelXsoftwareX_hasXname_rippleX_pageRankX1X_byXinEXcreatedXX_timesX1X_byXpriorsX_inXcreatedX_unionXboth__identityX_valueMapXname_priorsX': new IgnoreError(ignoreReason.computerNotSupported),
   'g_V_outXcreatedX_groupXmX_byXlabelX_pageRankX1X_byXpageRankX_byXinEX_timesX1X_inXcreatedX_groupXmX_byXpageRankX_capXmX': new IgnoreError(ignoreReason.computerNotSupported),
   'g_V_peerPressure_hasXclusterX': new IgnoreError(ignoreReason.computerNotSupported),

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/69d46f73/gremlin-test/features/map/PageRank.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/PageRank.feature b/gremlin-test/features/map/PageRank.feature
index 24a19ec..bd3fc6b 100644
--- a/gremlin-test/features/map/PageRank.feature
+++ b/gremlin-test/features/map/PageRank.feature
@@ -76,30 +76,47 @@ Feature: Step - pageRank()
       | lop    |
       | ripple |
 
-  Scenario: g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX
+  Scenario: g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_project_byXnameX_byXvaluesXfriendRankX_mathX
     Given the modern graph
-    Given an unsupported test
-    Then nothing should happen because
+    And the traversal of
       """
-      The result is not completely deterministic with respect to the decimals that pageRank() produces and the
-      GLV framework does not have a notion for asserting anything beyond an equals() sort of state.
+      g.withComputer().V().pageRank().by(__.outE("knows")).by("friendRank").project("name", "friendRank").by("name").by(__.values("friendRank").math("ceil(_ * 100)"))
       """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | m[{"name": "marko", "friendRank": 15.0}] |
+      | m[{"name": "vadas", "friendRank": 21.0}] |
+      | m[{"name": "lop", "friendRank": 15.0}] |
+      | m[{"name": "josh", "friendRank": 21.0}] |
+      | m[{"name": "ripple", "friendRank": 15.0}] |
+      | m[{"name": "peter", "friendRank": 15.0}] |
 
-  Scenario: g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX
-    Given an unsupported test
-    Then nothing should happen because
+  Scenario: g_V_hasLabelXpersonX_pageRank_byXpageRankX_project_byXnameX_byXvaluesXpageRankX_mathX
+    Given the modern graph
+    And the traversal of
       """
-      The result is not completely deterministic with respect to the decimals that pageRank() produces and the
-      GLV framework does not have a notion for asserting anything beyond an equals() sort of state.
+      g.withComputer().V().hasLabel("person").pageRank().by("pageRank").project("name", "pageRank").by("name").by(__.values("pageRank").math("ceil(_ * 100)"))
       """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | m[{"name": "marko", "pageRank": 46.0}] |
+      | m[{"name": "vadas", "pageRank": 59.0}] |
+      | m[{"name": "josh", "pageRank": 59.0}] |
+      | m[{"name": "peter", "pageRank": 46.0}] |
 
-  Scenario: g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX
-    Given an unsupported test
-    Then nothing should happen because
+  Scenario: g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX_by_byXmathX
+    Given the modern graph
+    And the traversal of
       """
-      The result is not completely deterministic with respect to the decimals that pageRank() produces and the
-      GLV framework does not have a notion for asserting anything beyond an equals() sort of state.
+      g.withComputer().V().pageRank().by("pageRank").as("a").out("knows").values("pageRank").as("b").select("a", "b").by().by(__.math("ceil(_ * 100)"))
       """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | m[{"a": "v[marko]", "b": 15.0}] |
+      | m[{"a": "v[marko]", "b": 15.0}] |
 
   Scenario: g_V_hasLabelXsoftwareX_hasXname_rippleX_pageRankX1X_byXinEXcreatedXX_timesX1X_byXpriorsX_inXcreatedX_unionXboth__identityX_valueMapXname_priorsX
     Given the modern graph

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/69d46f73/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PageRankTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PageRankTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PageRankTest.java
index 620d0e3..3eb06c4 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PageRankTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PageRankTest.java
@@ -56,11 +56,11 @@ public abstract class PageRankTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, String> get_g_V_pageRank_order_byXpageRank_descX_name_limitX2X();
 
-    public abstract Traversal<Vertex, Map<String, List<Object>>> get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX();
+    public abstract Traversal<Vertex, Map<String, Object>> get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_project_byXnameX_byXvaluesXfriendRankX_mathX();
 
-    public abstract Traversal<Vertex, Map<String, List<Object>>> get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX();
+    public abstract Traversal<Vertex, Map<String, Object>> get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_project_byXnameX_byXvaluesXpageRankX_mathX();
 
-    public abstract Traversal<Vertex, Map<String, Object>> get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX();
+    public abstract Traversal<Vertex, Map<String, Object>> get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX_by_byXmathX();
 
     public abstract Traversal<Vertex, Map<String, List<Object>>> get_g_V_hasLabelXsoftwareX_hasXname_rippleX_pageRankX1X_byXinEXcreatedXX_timesX1X_byXpriorsX_inXcreatedX_unionXboth__identityX_valueMapXname_priorsX();
 
@@ -109,21 +109,19 @@ public abstract class PageRankTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX() {
-        final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX();
+    public void g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_project_byXnameX_byXvaluesXfriendRankX_mathX() {
+        final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_project_byXnameX_byXvaluesXfriendRankX_mathX();
         printTraversalForm(traversal);
         int counter = 0;
         while (traversal.hasNext()) {
-            final Map<String, List<Object>> map = traversal.next();
+            final Map<String, Object> map = traversal.next();
             assertEquals(2, map.size());
-            assertEquals(1, map.get("name").size());
-            assertEquals(1, map.get("friendRank").size());
-            String name = (String) map.get("name").get(0);
-            Double friendRank = (Double) map.get("friendRank").get(0);
+            final String name = (String) map.get("name");
+            final Double friendRank = (Double) map.get("friendRank");
             if (name.equals("lop") || name.equals("ripple") || name.equals("peter") || name.equals("marko"))
-                assertEquals(0.15, friendRank, 0.01);
+                assertEquals(15.0, friendRank, 0.01);
             else
-                assertEquals(0.21375, friendRank, 0.01);
+                assertEquals(21.0, friendRank, 0.01);
 
             counter++;
         }
@@ -143,21 +141,20 @@ public abstract class PageRankTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX() {
-        final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX();
+    public void g_V_hasLabelXpersonX_pageRank_byXpageRankX_project_byXnameX_byXvaluesXpageRankX_mathX() {
+        final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_project_byXnameX_byXvaluesXpageRankX_mathX();
         printTraversalForm(traversal);
         int counter = 0;
-        double lastPageRank = Double.MIN_VALUE;
         while (traversal.hasNext()) {
-            final Map<String, List<Object>> map = traversal.next();
+            final Map<String, Object> map = traversal.next();
             assertEquals(2, map.size());
-            assertEquals(1, map.get("name").size());
-            assertEquals(1, map.get("pageRank").size());
-            String name = (String) map.get("name").get(0);
-            double pageRank = (Double) map.get("pageRank").get(0);
-            assertTrue(pageRank >= lastPageRank);
-            lastPageRank = pageRank;
-            assertFalse(name.equals("lop") || name.equals("ripple"));
+            final String name = (String) map.get("name");
+            final Double pageRank = (Double) map.get("pageRank");
+            if (name.equals("marko") || name.equals("peter"))
+                assertEquals(46.0, pageRank, 0.01);
+            else
+                assertEquals(59.0, pageRank, 0.01);
+
             counter++;
         }
         assertEquals(4, counter);
@@ -165,8 +162,8 @@ public abstract class PageRankTest extends AbstractGremlinProcessTest {
 
     @Test
     @LoadGraphWith(MODERN)
-    public void g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX() {
-        final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX();
+    public void g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX_by_byXmathX() {
+        final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX_by_byXmathX();
         printTraversalForm(traversal);
         int counter = 0;
         while (traversal.hasNext()) {
@@ -246,8 +243,8 @@ public abstract class PageRankTest extends AbstractGremlinProcessTest {
         }
 
         @Override
-        public Traversal<Vertex, Map<String, List<Object>>> get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX() {
-            return g.V().pageRank().by(__.outE("knows")).by("friendRank").valueMap("name", "friendRank");
+        public Traversal<Vertex, Map<String, Object>> get_g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_project_byXnameX_byXvaluesXfriendRankX_mathX() {
+            return g.V().pageRank().by(__.outE("knows")).by("friendRank").project("name", "friendRank").by("name").by(__.values("friendRank").math("ceil(_ * 100)"));
         }
 
         @Override
@@ -261,13 +258,13 @@ public abstract class PageRankTest extends AbstractGremlinProcessTest {
         }
 
         @Override
-        public Traversal<Vertex, Map<String, List<Object>>> get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX() {
-            return g.V().hasLabel("person").pageRank().by("pageRank").order().by("pageRank").valueMap("name", "pageRank");
+        public Traversal<Vertex, Map<String, Object>> get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_project_byXnameX_byXvaluesXpageRankX_mathX() {
+            return g.V().hasLabel("person").pageRank().by("pageRank").project("name", "pageRank").by("name").by(__.values("pageRank").math("ceil(_ * 100)"));
         }
 
         @Override
-        public Traversal<Vertex, Map<String, Object>> get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX() {
-            return g.V().pageRank().by("pageRank").as("a").out("knows").values("pageRank").as("b").select("a", "b");
+        public Traversal<Vertex, Map<String, Object>> get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX_by_byXmathX() {
+            return g.V().pageRank().by("pageRank").as("a").out("knows").values("pageRank").as("b").select("a", "b").by().by(__.math("ceil(_ * 100)"));
         }
 
         @Override


[35/50] tinkerpop git commit: TINKERPOP-1878 Removed the old sparql-gremlin link

Posted by sp...@apache.org.
TINKERPOP-1878 Removed the old sparql-gremlin link


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

Branch: refs/heads/TINKERPOP-1342
Commit: 30c2033f02d2c02560147889d796116168d50666
Parents: 20cb3f8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Aug 10 15:11:55 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 docs/site/home/index.html | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/30c2033f/docs/site/home/index.html
----------------------------------------------------------------------
diff --git a/docs/site/home/index.html b/docs/site/home/index.html
index bbba419..6576c7d 100644
--- a/docs/site/home/index.html
+++ b/docs/site/home/index.html
@@ -260,7 +260,6 @@ limitations under the License.
             <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>
          </ul>


[25/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/46e8532b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/46e8532b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/46e8532b

Branch: refs/heads/TINKERPOP-1342
Commit: 46e8532beb40e9e20c82c99da8dd8a7b8922c0b3
Parents: 04e0ca5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Apr 3 10:52:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/46e8532b/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]
 ----


[34/50] tinkerpop git commit: TINKERPOP-1878 Updated changelog

Posted by sp...@apache.org.
TINKERPOP-1878 Updated changelog


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

Branch: refs/heads/TINKERPOP-1342
Commit: 12d282a9cb2c784930136abca6022ff352c2e598
Parents: 85ea6ea
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 8 07:28:11 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/12d282a9/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 987ab31..1f27ef1 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,8 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Deprecated `Graph.io()` and related infrastructure.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
+* Added sparql-gremlin.
+* Fixed a bug in dynamic Gryo registration where registrations that did not have serializers would fail.
 * Moved `Parameterizing` interface to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with other marker interfaces of its type.
 * Replaced `Parameterizing.addPropertyMutations()` with `Configuring.configure()`.
 * Changed interface hierarchy for `Parameterizing` and `Mutating` interfaces as they are tightly related.
@@ -113,7 +115,6 @@ 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`.
 


[41/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/2da92334
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2da92334
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2da92334

Branch: refs/heads/TINKERPOP-1342
Commit: 2da92334a1c36ca8abd7dc76c8a8198506341d90
Parents: 9d96a7f
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Aug 1 11:14:54 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2da92334/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.
          */


[45/50] tinkerpop git commit: Ignored pageRank() test for decimal assertion problems in GLVs CTR

Posted by sp...@apache.org.
Ignored pageRank() test for decimal assertion problems in GLVs CTR


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

Branch: refs/heads/TINKERPOP-1342
Commit: bdda91355f91fe5074424a0396e346577d08a8a4
Parents: 25ae755
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Aug 14 07:07:49 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Aug 14 07:07:49 2018 -0400

----------------------------------------------------------------------
 gremlin-test/features/map/PageRank.feature | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bdda9135/gremlin-test/features/map/PageRank.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/PageRank.feature b/gremlin-test/features/map/PageRank.feature
index 8ead2d4..24a19ec 100644
--- a/gremlin-test/features/map/PageRank.feature
+++ b/gremlin-test/features/map/PageRank.feature
@@ -78,19 +78,12 @@ Feature: Step - pageRank()
 
   Scenario: g_V_pageRank_byXoutEXknowsXX_byXfriendRankX_valueMapXname_friendRankX
     Given the modern graph
-    And the traversal of
+    Given an unsupported test
+    Then nothing should happen because
       """
-      g.withComputer().V().pageRank().by(__.outE("knows")).by("friendRank").valueMap("name", "friendRank")
+      The result is not completely deterministic with respect to the decimals that pageRank() produces and the
+      GLV framework does not have a notion for asserting anything beyond an equals() sort of state.
       """
-    When iterated to list
-    Then the result should be unordered
-      | result |
-      | m[{"name": ["marko"], "friendRank": [0.14598537777608422]}] |
-      | m[{"name": ["vadas"], "friendRank": [0.20802924444783155]}] |
-      | m[{"name": ["lop"], "friendRank": [0.14598537777608422]}] |
-      | m[{"name": ["josh"], "friendRank": [0.20802924444783155]}] |
-      | m[{"name": ["ripple"], "friendRank": [0.14598537777608422]}] |
-      | m[{"name": ["peter"], "friendRank": [0.14598537777608422]}] |
 
   Scenario: g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX
     Given an unsupported test


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

Posted by sp...@apache.org.
TINKERPOP-1878 Added upgrade 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/20cb3f8d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/20cb3f8d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/20cb3f8d

Branch: refs/heads/TINKERPOP-1342
Commit: 20cb3f8de5b79b1bfad37be18bc5a7aaaaba1a0c
Parents: 12d282a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 8 07:42:13 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/20cb3f8d/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 00f2635..e722601 100644
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@ -29,6 +29,23 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.4.0/CHANGELOG.asc
 
 === Upgrading for Users
 
+==== sparql-gremlin
+
+The `sparql-gremlin` module is a link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] to Gremlin compiler, which allows
+SPARQL to be executed over any TinkerPop-enabled graph system.
+
+[source,groovy]
+----
+graph = TinkerFactory.createModern()
+g = graph.traversal(SparqlTraversalSource)
+g.sparql("""SELECT ?name ?age
+            WHERE { ?person v:name ?name . ?person v:age ?age }
+            ORDER BY ASC(?age)""")
+----
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1878[TINKERPOP-1878],
+link:http://tinkerpop.apache.org/docs/3.4.0/reference/#sparql-gremlin[Reference Documentation]
+
 ==== with() Step
 
 This version of TinkerPop introduces the `with()`-step to Gremlin. It isn't really a step but is instead a step


[28/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/627c9a11
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/627c9a11
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/627c9a11

Branch: refs/heads/TINKERPOP-1342
Commit: 627c9a11a370683e1bb49508e07f306abdd8f841
Parents: bea09c5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 16:03:49 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/627c9a11/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


[29/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/07683e3d
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/07683e3d
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/07683e3d

Branch: refs/heads/TINKERPOP-1342
Commit: 07683e3ddf64e4bd615dbb5a2c16acf362029d7a
Parents: 95b445f
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Fri Jun 15 11:24:57 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/07683e3d/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 . }""")
 ----


[07/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/69c21a19
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/69c21a19
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/69c21a19

Branch: refs/heads/TINKERPOP-1342
Commit: 69c21a199cc4dfcd232f0b28dcaacbebfe711653
Parents: 7dcfd7e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 17:00:54 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/69c21a19/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 6d55704..fa7347c 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
@@ -404,6 +404,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);
         }};
     }
 
@@ -593,7 +596,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/69c21a19/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/69c21a19/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/69c21a19/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) {


[05/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/f1e17cb4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f1e17cb4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f1e17cb4

Branch: refs/heads/TINKERPOP-1342
Commit: f1e17cb458310600f6ca5ee09fed0f8074489cf2
Parents: 518d7fd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 08:10:48 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/f1e17cb4/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/f1e17cb4/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/f1e17cb4/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/f1e17cb4/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/f1e17cb4/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);
+                }}
+        ));
     }
 }


[22/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/04e0ca5c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/04e0ca5c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/04e0ca5c

Branch: refs/heads/TINKERPOP-1342
Commit: 04e0ca5c674c3bc3108fc200c99f033e63f88c3c
Parents: 4e114bb
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Mar 28 17:27:32 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/04e0ca5c/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 }""")
+----


[49/50] tinkerpop git commit: TINKERPOP-1342 Allow better per-request settings in driver

Posted by sp...@apache.org.
TINKERPOP-1342 Allow better per-request settings in driver


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

Branch: refs/heads/TINKERPOP-1342
Commit: ccb5bcc148faafd1a7b74b20b0d9f78429bf8598
Parents: 1250129
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 8 15:56:38 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Aug 16 12:11:32 2018 -0400

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/driver/Client.java | 148 ++++++++++---------
 .../gremlin/driver/RequestOptions.java          | 120 +++++++++++++++
 .../server/GremlinDriverIntegrateTest.java      |  21 +++
 3 files changed, 216 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ccb5bcc1/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
index 6e604cb..c6ccf7e 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/Client.java
@@ -67,7 +67,7 @@ public abstract class Client {
     }
 
     /**
-     * Makes any final changes to the builder and returns the constructed {@link RequestMessage}.  Implementers
+     * Makes any initial changes to the builder and returns the constructed {@link RequestMessage}.  Implementers
      * may choose to override this message to append data to the request before sending.  By default, this method
      * will simply return the {@code builder} passed in by the caller.
      */
@@ -184,7 +184,7 @@ public abstract class Client {
      * @param gremlin the gremlin script to execute
      */
     public ResultSet submit(final String gremlin) {
-        return submit(gremlin, null);
+        return submit(gremlin, RequestOptions.EMPTY);
     }
 
     /**
@@ -205,13 +205,28 @@ public abstract class Client {
     }
 
     /**
+     * Submits a Gremlin script to the server and returns a {@link ResultSet} once the write of the request is
+     * complete.
+     *
+     * @param gremlin the gremlin script to execute
+     * @param options for the request
+     */
+    public ResultSet submit(final String gremlin, final RequestOptions options) {
+        try {
+            return submitAsync(gremlin, options).get();
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    /**
      * The asynchronous version of {@link #submit(String)} where the returned future will complete when the
      * write of the request completes.
      *
      * @param gremlin the gremlin script to execute
      */
     public CompletableFuture<ResultSet> submitAsync(final String gremlin) {
-        return submitAsync(gremlin, null);
+        return submitAsync(gremlin, RequestOptions.build().create());
     }
 
     /**
@@ -222,13 +237,12 @@ public abstract class Client {
      * @param parameters a map of parameters that will be bound to the script on execution
      */
     public CompletableFuture<ResultSet> submitAsync(final String gremlin, final Map<String, Object> parameters) {
-        final RequestMessage.Builder request = RequestMessage.build(Tokens.OPS_EVAL)
-                .add(Tokens.ARGS_GREMLIN, gremlin)
-                .add(Tokens.ARGS_BATCH_SIZE, cluster.connectionPoolSettings().resultIterationBatchSize);
-
-        Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
+        final RequestOptions.Builder options = RequestOptions.build();
+        if (parameters != null && !parameters.isEmpty()) {
+            parameters.forEach(options::addParameter);
+        }
 
-        return submitAsync(buildMessage(request).create());
+        return submitAsync(gremlin, options.create());
     }
 
     /**
@@ -238,19 +252,17 @@ public abstract class Client {
      * @param gremlin the gremlin script to execute
      * @param parameters a map of parameters that will be bound to the script on execution
      * @param graphOrTraversalSource rebinds the specified global Gremlin Server variable to "g"
+     * @deprecated As of release 3.4.0, replaced by {@link #submitAsync(String, RequestOptions)}.
      */
+    @Deprecated
     public CompletableFuture<ResultSet> submitAsync(final String gremlin, final String graphOrTraversalSource,
                                                     final Map<String, Object> parameters) {
-        final RequestMessage.Builder request = RequestMessage.build(Tokens.OPS_EVAL)
-                .add(Tokens.ARGS_GREMLIN, gremlin)
-                .add(Tokens.ARGS_BATCH_SIZE, cluster.connectionPoolSettings().resultIterationBatchSize);
-
-        Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
-
-        if (graphOrTraversalSource != null && !graphOrTraversalSource.isEmpty())
-            request.addArg(Tokens.ARGS_ALIASES, makeDefaultAliasMap(graphOrTraversalSource));
+        Map<String,String> aliases = null;
+        if (graphOrTraversalSource != null && !graphOrTraversalSource.isEmpty()) {
+            aliases = makeDefaultAliasMap(graphOrTraversalSource);
+        }
 
-        return submitAsync(buildMessage(request).create());
+        return submitAsync(gremlin, aliases, parameters);
     }
 
     /**
@@ -262,19 +274,47 @@ public abstract class Client {
      * @param aliases aliases the specified global Gremlin Server variable some other name that then be used in the
      *                script where the key is the alias name and the value represents the global variable on the
      *                server
+     * @deprecated As of release 3.4.0, replaced by {@link #submitAsync(String, RequestOptions)}.
      */
+    @Deprecated
     public CompletableFuture<ResultSet> submitAsync(final String gremlin, final Map<String,String> aliases,
                                                     final Map<String, Object> parameters) {
-        final RequestMessage.Builder request = RequestMessage.build(Tokens.OPS_EVAL)
-                .add(Tokens.ARGS_GREMLIN, gremlin)
-                .add(Tokens.ARGS_BATCH_SIZE, cluster.connectionPoolSettings().resultIterationBatchSize);
+        final RequestOptions.Builder options = RequestOptions.build();
+        if (aliases != null && !aliases.isEmpty()) {
+            aliases.forEach(options::addAlias);
+        }
+
+        if (parameters != null && !parameters.isEmpty()) {
+            parameters.forEach(options::addParameter);
+        }
+
+        options.batchSize(cluster.connectionPoolSettings().resultIterationBatchSize);
+
+        return submitAsync(gremlin, options.create());
+    }
+
+    /**
+     * The asynchronous version of {@link #submit(String, RequestOptions)}} where the returned future will complete when the
+     * write of the request completes.
+     *
+     * @param gremlin the gremlin script to execute
+     * @param options the options to supply for this request
+     */
+    public CompletableFuture<ResultSet> submitAsync(final String gremlin, final RequestOptions options) {
+        final int batchSize = options.getBatchSize().orElse(cluster.connectionPoolSettings().resultIterationBatchSize);
 
-        Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
+        // need to call buildMessage() right away to get client specific configurations, that way request specific
+        // ones can override as needed
+        final RequestMessage.Builder request = buildMessage(RequestMessage.build(Tokens.OPS_EVAL))
+                .add(Tokens.ARGS_GREMLIN, gremlin)
+                .add(Tokens.ARGS_BATCH_SIZE, batchSize);
 
-        if (aliases != null && !aliases.isEmpty())
-            request.addArg(Tokens.ARGS_ALIASES, aliases);
+        // apply settings if they were made available
+        options.getTimeout().ifPresent(timeout -> request.add(Tokens.ARGS_SCRIPT_EVAL_TIMEOUT, timeout));
+        options.getParameters().ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, params));
+        options.getAliases().ifPresent(aliases -> request.addArg(Tokens.ARGS_ALIASES, aliases));
 
-        return submitAsync(buildMessage(request).create());
+        return submitAsync(request.create());
     }
 
     /**
@@ -384,52 +424,6 @@ public abstract class Client {
         }
 
         /**
-         * The asynchronous version of {@link #submit(String, Map)}} where the returned future will complete when the
-         * write of the request completes.
-         *
-         * @param gremlin the gremlin script to execute
-         * @param parameters a map of parameters that will be bound to the script on execution
-         * @param graphOrTraversalSource rebinds the specified global Gremlin Server variable to "g"
-         */
-        public CompletableFuture<ResultSet> submitAsync(final String gremlin, final String graphOrTraversalSource,
-                                                        final Map<String, Object> parameters) {
-            final RequestMessage.Builder request = RequestMessage.build(Tokens.OPS_EVAL)
-                    .add(Tokens.ARGS_GREMLIN, gremlin)
-                    .add(Tokens.ARGS_BATCH_SIZE, cluster.connectionPoolSettings().resultIterationBatchSize);
-
-            Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
-
-            if (graphOrTraversalSource != null && !graphOrTraversalSource.isEmpty())
-                request.addArg(Tokens.ARGS_ALIASES, makeDefaultAliasMap(graphOrTraversalSource));
-
-            return submitAsync(buildMessage(request).create());
-        }
-
-        /**
-         * The asynchronous version of {@link #submit(String, Map)}} where the returned future will complete when the
-         * write of the request completes.
-         *
-         * @param gremlin the gremlin script to execute
-         * @param parameters a map of parameters that will be bound to the script on execution
-         * @param aliases aliases the specified global Gremlin Server variable some other name that then be used in the
-         *                script where the key is the alias name and the value represents the global variable on the
-         *                server
-         */
-        public CompletableFuture<ResultSet> submitAsync(final String gremlin, final Map<String,String> aliases,
-                                                        final Map<String, Object> parameters) {
-            final RequestMessage.Builder request = RequestMessage.build(Tokens.OPS_EVAL)
-                    .add(Tokens.ARGS_GREMLIN, gremlin)
-                    .add(Tokens.ARGS_BATCH_SIZE, cluster.connectionPoolSettings().resultIterationBatchSize);
-
-            Optional.ofNullable(parameters).ifPresent(params -> request.addArg(Tokens.ARGS_BINDINGS, parameters));
-
-            if (aliases != null && !aliases.isEmpty())
-                request.addArg(Tokens.ARGS_ALIASES, aliases);
-
-            return submitAsync(buildMessage(request).create());
-        }
-
-        /**
          * {@inheritDoc}
          */
         @Override
@@ -535,8 +529,16 @@ public abstract class Client {
         @Override
         public CompletableFuture<ResultSet> submitAsync(final RequestMessage msg) {
             final RequestMessage.Builder builder = RequestMessage.from(msg);
-            if (!aliases.isEmpty())
-                builder.addArg(Tokens.ARGS_ALIASES, aliases);
+
+            // only add aliases which aren't already present. if they are present then they represent request level
+            // overrides which should be mucked with
+            if (!aliases.isEmpty()) {
+                final Map original = (Map) msg.getArgs().getOrDefault(Tokens.ARGS_ALIASES, Collections.emptyMap());
+                aliases.forEach((k,v) -> {
+                    if (!original.containsKey(k))
+                        builder.addArg(Tokens.ARGS_ALIASES, aliases);
+                });
+            }
 
             return super.submitAsync(builder.create());
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ccb5bcc1/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java
new file mode 100644
index 0000000..20c5ab2
--- /dev/null
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/RequestOptions.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.driver;
+
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Options that can be supplied on a per request basis.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class RequestOptions {
+
+    public static final RequestOptions EMPTY = RequestOptions.build().create();
+
+    private final Map<String,String> aliases;
+    private final Map<String, Object> parameters;
+    private final Integer batchSize;
+    private final Long timeout;
+
+    private RequestOptions(final Builder builder) {
+        this.aliases = builder.aliases;
+        this.parameters = builder.parameters;
+        this.batchSize = builder.batchSize;
+        this.timeout = builder.timeout;
+    }
+
+    public Optional<Map<String, String>> getAliases() {
+        return Optional.ofNullable(aliases);
+    }
+
+    public Optional<Map<String, Object>> getParameters() {
+        return Optional.ofNullable(parameters);
+    }
+
+    public Optional<Integer> getBatchSize() {
+        return Optional.ofNullable(batchSize);
+    }
+
+    public Optional<Long> getTimeout() {
+        return Optional.ofNullable(timeout);
+    }
+
+    public static Builder build() {
+        return new Builder();
+    }
+
+    public static final class Builder {
+        private Map<String,String> aliases = null;
+        private Map<String, Object> parameters = null;
+        private Integer batchSize = null;
+        private Long timeout = null;
+
+        /**
+         * The aliases to set on the request.
+         */
+        public Builder addAlias(final String aliasName, final String actualName) {
+            if (null == aliases)
+                aliases = new HashMap<>();
+
+            aliases.put(aliasName, actualName);
+            return this;
+        }
+
+        /**
+         * The parameters to pass on the request.
+         */
+        public Builder addParameter(final String name, final Object value) {
+            if (null == parameters)
+                parameters = new HashMap<>();
+
+            parameters.put(name, value);
+            return this;
+        }
+
+        /**
+         * The per client request override for the client and server configured {@code resultIterationBatchSize}. If
+         * this value is not set, then the configuration for the {@link Cluster} is used unless the
+         * {@link RequestMessage} is configured completely by the user.
+         */
+        public Builder batchSize(final int batchSize) {
+            this.batchSize = batchSize;
+            return this;
+        }
+
+        /**
+         * The per client request override in milliseconds for the server configured {@code scriptEvaluationTimeout}.
+         * If this value is not set, then the configuration for the server is used.
+         */
+        public Builder timeout(final long timeout) {
+            this.timeout = timeout;
+            return this;
+        }
+
+        public RequestOptions create() {
+            return new RequestOptions(this);
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ccb5bcc1/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index c7e7bb2..6343e4d 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.driver.Channelizer;
 import org.apache.tinkerpop.gremlin.driver.Client;
 import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.RequestOptions;
 import org.apache.tinkerpop.gremlin.driver.Result;
 import org.apache.tinkerpop.gremlin.driver.ResultSet;
 import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
@@ -179,12 +180,32 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
             case "shouldProcessEvalInterruption":
                 settings.scriptEvaluationTimeout = 1500;
                 break;
+            case "shouldProcessEvalTimeoutOverride":
+                settings.scriptEvaluationTimeout = 15000;
+                break;
         }
 
         return settings;
     }
 
     @Test
+    public void shouldProcessEvalTimeoutOverride() throws Exception {
+        final Cluster cluster = TestClientFactory.open();
+        final Client client = cluster.connect();
+        final RequestOptions options = RequestOptions.build().timeout(500).create();
+
+        try {
+            client.submit("Thread.sleep(5000);'done'", options).all().get();
+            fail("Should have timed out");
+        } catch (Exception ex) {
+            final ResponseException re = (ResponseException) ex.getCause();
+            assertEquals(ResponseStatusCode.SERVER_ERROR_TIMEOUT, re.getResponseStatusCode());
+        }
+
+        cluster.close();
+    }
+
+    @Test
     public void shouldProcessTraversalInterruption() throws Exception {
         final Cluster cluster = TestClientFactory.open();
         final Client client = cluster.connect();


[46/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/a8a6c09c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a8a6c09c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a8a6c09c

Branch: refs/heads/TINKERPOP-1342
Commit: a8a6c09cbe84e41ed028262fb79fc78910827d76
Parents: b4c64fc bdda913
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Aug 14 07:08:32 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Aug 14 07:08:32 2018 -0400

----------------------------------------------------------------------
 gremlin-test/features/map/PageRank.feature | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
----------------------------------------------------------------------



[12/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/bd1b8c0f
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/bd1b8c0f
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/bd1b8c0f

Branch: refs/heads/TINKERPOP-1342
Commit: bd1b8c0f92aeea02a8aed3072df3ec5130218763
Parents: 49b20a1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 14:49:18 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/bd1b8c0f/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/bd1b8c0f/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();
-    }
-}


[44/50] tinkerpop git commit: TINKERPOP-1878 Fix gryo identifiers after rebase on master

Posted by sp...@apache.org.
TINKERPOP-1878 Fix gryo identifiers after rebase on master


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

Branch: refs/heads/TINKERPOP-1342
Commit: b4c64fc610cdb5d0a866066c098b3a0de646290f
Parents: c619e89
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 13 14:42:08 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:42:08 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/b4c64fc6/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 9c0ef8a..6d2d676 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
@@ -357,7 +357,7 @@ public enum GryoVersion {
             add(GryoTypeReg.of(MapReduce.NullObject.class, 74));
             add(GryoTypeReg.of(AtomicLong.class, 79));
             add(GryoTypeReg.of(Pair.class, 88, new UtilSerializers.PairSerializer()));
-            add(GryoTypeReg.of(Triplet.class, 183, new UtilSerializers.TripletSerializer()));                 // ***LAST ID***
+            add(GryoTypeReg.of(Triplet.class, 183, new UtilSerializers.TripletSerializer()));
             add(GryoTypeReg.of(TraversalExplanation.class, 106, new JavaSerializer()));
 
             add(GryoTypeReg.of(Duration.class, 93, new JavaTimeSerializers.DurationSerializer()));
@@ -406,7 +406,7 @@ public enum GryoVersion {
                     "org.apache.tinkerpop.gremlin.driver.ser.ResponseMessageGryoSerializer", 169);
 
             tryAddDynamicType(this, "org.apache.tinkerpop.gremlin.sparql.process.traversal.strategy.SparqlStrategy",
-                    null, 183);   // ***LAST ID***
+                    null, 184);   // ***LAST ID***
         }};
     }
 


[48/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/12501298
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/12501298
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/12501298

Branch: refs/heads/TINKERPOP-1342
Commit: 1250129880292d9ee5de2a853a198c866661a1f6
Parents: a8a6c09 69d46f7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Aug 14 12:51:34 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Aug 14 12:51:34 2018 -0400

----------------------------------------------------------------------
 .../test/cucumber/feature-steps.js              |  6 +-
 gremlin-test/features/map/PageRank.feature      | 47 +++++++++++-----
 .../traversal/step/map/PageRankTest.java        | 59 ++++++++++----------
 3 files changed, 63 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/12501298/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/PageRankTest.java
----------------------------------------------------------------------


[13/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/bea09c5b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/bea09c5b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/bea09c5b

Branch: refs/heads/TINKERPOP-1342
Commit: bea09c5bb57e9e69ee0c2686b3c164fb30eca8d6
Parents: 3b33750
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 15:56:55 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:22 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/bea09c5b/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/bea09c5b/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"));
+    }
 }


[38/50] tinkerpop git commit: TINKERPOP-1878 Used just inject() step to hold sparql

Posted by sp...@apache.org.
TINKERPOP-1878 Used just inject() step to hold sparql


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

Branch: refs/heads/TINKERPOP-1342
Commit: 2fbae88f1bcf8d39b22ae81e1edc8ca6f3bf475f
Parents: 30c2033
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 13 13:07:34 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 .../traversal/dsl/sparql/SparqlTraversalSource.java  | 12 +++---------
 .../process/traversal/strategy/SparqlStrategy.java   | 15 ++++++++-------
 ...bstractTinkerGraphGraphSONTranslatorProvider.java |  4 ----
 3 files changed, 11 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fbae88f/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 f78708b..d96f427 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
@@ -127,16 +127,10 @@ public class SparqlTraversalSource implements TraversalSource {
         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
-        // 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);
+        // the inject() holds the sparql which the SparqlStrategy then detects and converts to a traversal
+        clone.bytecode.addStep(GraphTraversal.Symbols.inject, 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));
+        return traversal.addStep(new InjectStep<>(traversal, query));
     }
 
     public Transaction tx() {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fbae88f/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 b21c348..38956f8 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,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.remote.traversal.strategy.decoration
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ConstantStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectStep;
 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;
@@ -63,22 +64,22 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
         if (!(traversal.getParent() instanceof EmptyStep))
             return;
 
-        if (traversal.getSteps().size() == 2 && traversal.getEndStep() instanceof ConstantStep) {
-            final ConstantStep stepWithSparql = (ConstantStep) traversal.getEndStep();
-            final Object constant = stepWithSparql.getConstant();
-            if (constant instanceof String) {
-                final String sparql = (String) constant;
+        if (traversal.getSteps().size() == 1 && traversal.getEndStep() instanceof InjectStep) {
+            final InjectStep stepWithSparql = (InjectStep) traversal.getEndStep();
+            final Object[] injections = stepWithSparql.getInjections();
+            if (injections.length == 1 && injections[0] instanceof String) {
+                final String sparql = (String) injections[0];
                 final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinCompiler.transpile(
                         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 a traversal that does not consist of a single ConstantStep<?,String>");
+                throw new IllegalStateException("SparqlStrategy cannot be applied to a traversal that does not consist of a single InjectStep<String> with one injection");
             }
         } 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 a traversal that does not consist of a single ConstantStep<?,String>");
+            throw new IllegalStateException("SparqlStrategy cannot be applied to a traversal that does not consist of a single InjectStep<String> with one injection");
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2fbae88f/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
index 8462781..223f4d2 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/io/graphson/AbstractTinkerGraphGraphSONTranslatorProvider.java
@@ -22,18 +22,14 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure.io.graphson;
 import org.apache.tinkerpop.gremlin.GraphProvider;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.jsr223.JavaTranslator;
-import org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionComputerTest;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalInterruptionTest;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.PageRankTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ProgramTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.ReadTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.WriteTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ElementIdStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.EventStrategyProcessTest;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategyProcessTest;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;


[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/1a7d50ee
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1a7d50ee
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1a7d50ee

Branch: refs/heads/TINKERPOP-1342
Commit: 1a7d50eea6790e6c0298eef750ba1c3b54165e0b
Parents: 0be7864 25ae755
Author: Florian Hockmann <fh...@florian-hockmann.de>
Authored: Mon Aug 13 19:30:07 2018 +0200
Committer: Florian Hockmann <fh...@florian-hockmann.de>
Committed: Mon Aug 13 19:30:07 2018 +0200

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 gremlin-dotnet/glv/Gremlin.Net.csproj.template  |   3 +-
 .../src/Gremlin.Net/Gremlin.Net.csproj          |   3 +-
 .../IO/GraphSON/BigIntegerDeserializer.cs       |  38 +++++++
 .../IO/GraphSON/BigIntegerSerializer.cs         |  37 +++++++
 .../IO/GraphSON/ByteBufferDeserializer.cs       |  36 +++++++
 .../IO/GraphSON/ByteBufferSerializer.cs         |  36 +++++++
 .../Structure/IO/GraphSON/ByteConverter.cs      |  33 ++++++
 .../Structure/IO/GraphSON/CharConverter.cs      |  34 ++++++
 .../Structure/IO/GraphSON/DateDeserializer.cs   |  38 +++++++
 .../Structure/IO/GraphSON/DateSerializer.cs     |   9 +-
 .../IO/GraphSON/DurationDeserializer.cs         |  37 +++++++
 .../Structure/IO/GraphSON/DurationSerializer.cs |  38 +++++++
 .../Structure/IO/GraphSON/GraphSONReader.cs     |  14 ++-
 .../Structure/IO/GraphSON/GraphSONWriter.cs     |  13 ++-
 .../Structure/IO/GraphSON/Int16Converter.cs     |  34 ++++++
 .../Gremlin.Net.UnitTest.csproj                 |   1 +
 .../IO/GraphSON/GraphSONReaderTests.cs          | 108 +++++++++++++++++++
 .../IO/GraphSON/GraphSONWriterTests.cs          |  65 +++++++++++
 19 files changed, 563 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


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

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1a7d50ee/gremlin-dotnet/src/Gremlin.Net/Gremlin.Net.csproj
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1a7d50ee/gremlin-dotnet/test/Gremlin.Net.UnitTest/Structure/IO/GraphSON/GraphSONReaderTests.cs
----------------------------------------------------------------------


[15/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/a8e25a84
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a8e25a84
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a8e25a84

Branch: refs/heads/TINKERPOP-1342
Commit: a8e25a8461c9a34f01eca561bd15e84bf84abdd4
Parents: 6211e76
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 13:36:29 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:22 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/a8e25a84/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/a8e25a84/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/a8e25a84/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/a8e25a84/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/a8e25a84/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));


[06/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/518d7fdf
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/518d7fdf
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/518d7fdf

Branch: refs/heads/TINKERPOP-1342
Commit: 518d7fdf173e541e9ba402a812624313553c69ef
Parents: 69c21a1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 17:09:17 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/518d7fdf/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 8b51a1d..987ab31 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -113,6 +113,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/518d7fdf/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);


[10/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/91fbf22c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/91fbf22c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/91fbf22c

Branch: refs/heads/TINKERPOP-1342
Commit: 91fbf22ca6340139107c3ddf29627de3a311adc9
Parents: a0ffa54
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jan 24 17:04:27 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/91fbf22c/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/91fbf22c/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/91fbf22c/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/91fbf22c/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 {
+}


[50/50] tinkerpop git commit: TINKERPOP-1342 Added documentation for RequestOptions

Posted by sp...@apache.org.
TINKERPOP-1342 Added documentation for RequestOptions


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

Branch: refs/heads/TINKERPOP-1342
Commit: ee270e9ecd058144d45f9f3f1551687d19a8db1e
Parents: ccb5bcc
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Aug 9 13:19:55 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Aug 16 12:11:53 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                               |  2 ++
 docs/src/reference/gremlin-applications.asciidoc | 15 +++++++++++++++
 docs/src/upgrade/release-3.4.x.asciidoc          | 16 ++++++++++++++++
 3 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee270e9e/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 1f27ef1..a55465c 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -32,6 +32,8 @@ This release also includes changes from <<release-3-3-3, 3.3.3>>.
 * Deprecated `Graph.io()` and related infrastructure.
 * Bumped to Netty 4.1.25.
 * Bumped to Spark 2.3.1.
+* Deprecated two `submit()`-related methods on the Java driver `Client` class.
+* Added `Client.submit()` overloads that accept per-request `RequestOptions`.
 * Added sparql-gremlin.
 * Fixed a bug in dynamic Gryo registration where registrations that did not have serializers would fail.
 * Moved `Parameterizing` interface to the `org.apache.tinkerpop.gremlin.process.traversal.step` package with other marker interfaces of its type.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee270e9e/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index 1a7de96..234bf3f 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -827,6 +827,21 @@ The above code demonstrates using the `TitanIoRegistry` which is an `IoRegistry`
 what classes (from Titan in this case) to auto-register during serialization.  Gremlin Server roughly uses this same
 approach when it configures it's serializers, so using this same model will ensure compatibility when making requests.
 
+==== Per Request Settings
+
+There are a number of overloads to `Client.submit()` that accept a `RequestOptions` object. The `RequestOptions`
+provide a way to include options that are specific to the request made with the call to `submit()`. A good use-case for
+this feature is to set a per-request override to the `scriptEvaluationTimeout` so that it only applies to the current
+request.
+
+[source,java]
+----
+Cluster cluster = Cluster.open();
+Client client = cluster.connect();
+RequestOptions options = RequestOptions.build().timeout(500).create();
+List<Result> result = client.submit("g.V()", options).all().get();
+----
+
 [[connecting-via-python]]
 === Connecting via Python
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ee270e9e/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 e722601..a9ef4ef 100644
--- a/docs/src/upgrade/release-3.4.x.asciidoc
+++ b/docs/src/upgrade/release-3.4.x.asciidoc
@@ -141,6 +141,22 @@ efficiencies there.
 See: link:https://issues.apache.org/jira/browse/TINKERPOP-1996[TINKERPOP-1996],
 link:http://tinkerpop.apache.org/docs/3.4.0/reference/#io-step[Reference Documentation]
 
+==== Per Request Options
+
+The Java driver now allows for various options to be set on a per-request basis via new overloads to `submit()` that
+accept `RequestOption` instances. A good use-case for this feature is to set a per-request override to the
+`scriptEvaluationTimeout` so that it only applies to the current request.
+
+[source,java]
+----
+Cluster cluster = Cluster.open();
+Client client = cluster.connect();
+RequestOptions options = RequestOptions.build().timeout(500).create();
+List<Result> result = client.submit("g.V()", options).all().get();
+----
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1342[TINKERPOP-1342]
+
 ==== Removal of Giraph Support
 
 Support for Giraph has been removed as of this version. There were a number of reasons for this decision which were


[42/50] tinkerpop git commit: TINKERPOP-1878 Minor formatting/edits to compilers doc for sparql-gremlin

Posted by sp...@apache.org.
TINKERPOP-1878 Minor formatting/edits to compilers doc 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/05a79954
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/05a79954
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/05a79954

Branch: refs/heads/TINKERPOP-1342
Commit: 05a7995452bc02fa1bb8f1227e59233515c76e8a
Parents: fb5df62
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Aug 1 09:59:19 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 docs/src/reference/compilers.asciidoc | 129 +++++++++++------------------
 1 file changed, 48 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/05a79954/docs/src/reference/compilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/compilers.asciidoc b/docs/src/reference/compilers.asciidoc
index 5b6ab2e..2a8d561 100644
--- a/docs/src/reference/compilers.asciidoc
+++ b/docs/src/reference/compilers.asciidoc
@@ -18,9 +18,9 @@ limitations under the License.
 = 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
+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.
+Gremlin Compiler enables a particular query language to work on any TinkerPop-enabled graph system.
 
 [[sparql-gremlin]]
 == SPARQL-Gremlin
@@ -139,83 +139,90 @@ 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).
+SPARQL query cannot be mapped, 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" .} }""")
+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:
+* A non-Group key variable cannot be projected in a SPARQL query. This is a SPARQL language 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)""")
+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)""")
+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:
-
+* In a SPARQL query with an ORDER-BY clause, the ordering occurs with respect to the first projected variable in the
+query. It is possible to 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)""")
+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:
+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)""")
+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 *`):
+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)""")
+            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
-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.
+the the variable encountered first will be the ordering decider, i.e. since we have `?person` encountered first,
+the result set will be ordered according to the `?person` variable (which are vertex id).
 
+* 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
 
-The following section presents a comprehensive examples of SPARQL queries that are currently covered by the
-SPARQL-Gremlin compiler.
+The following section presents examples of SPARQL queries that are currently covered by the SPARQL-Gremlin compiler.
 
-[[select-all]]
 ==== Select All
 
 Select all vertices in the graph.
@@ -225,7 +232,6 @@ Select all vertices in the graph.
 g.sparql("""SELECT * WHERE { }""")
 ----
 
-[[match-constant-values]]
 ==== Match Constant Values
 
 Select all vertices with the label `person`.
@@ -235,7 +241,6 @@ Select all vertices with the label `person`.
 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.
@@ -249,7 +254,6 @@ WHERE {
   ?person v:age ?age . }""")
 ----
 
-[[pattern-matching]]
 ==== Pattern Matching
 
 Select only those persons who created a project.
@@ -264,7 +268,6 @@ WHERE {
   ?person e:created ?project . }""")
 ----
 
-[[filtering]]
 ==== Filtering
 
 Select only those persons who are older than 30.
@@ -279,7 +282,6 @@ WHERE {
     FILTER (?age > 30) }""")
 ----
 
-[[deduplication]]
 ==== Deduplication
 
 Select the distinct names of the created projects.
@@ -295,7 +297,6 @@ WHERE {
     FILTER (?age > 30)}""")
 ----
 
-[[multiple-filters]]
 ==== Multiple Filters
 
 Select the distinct names of all Java projects.
@@ -312,34 +313,6 @@ WHERE {
     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.
@@ -353,7 +326,6 @@ WHERE {
   {?software v:lang "java" .} }""")
 ----
 
-[[optional]]
 ==== Optional
 
 Return the names of the persons who have created a software in java and optionally python.
@@ -368,7 +340,6 @@ WHERE {
   OPTIONAL {?software v:lang "python" . }}""")
 ----
 
-[[order-by]]
 ==== Order By
 
 Select all vertices with the label `person` and order them by their age.
@@ -383,7 +354,6 @@ WHERE {
 } ORDER BY (?age))
 ----
 
-[[group-by]]
 ==== Group By
 
 Select all vertices with the label `person` and group them by their age.
@@ -397,7 +367,6 @@ WHERE {
 } 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
@@ -413,7 +382,6 @@ 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
@@ -430,7 +398,6 @@ WHERE {
   ?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


[37/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/fb5df622
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fb5df622
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fb5df622

Branch: refs/heads/TINKERPOP-1342
Commit: fb5df6229ae5020c098ad551b394acff62e956c9
Parents: 2da9233
Author: Harsh Thakkar <ha...@gmail.com>
Authored: Wed Aug 1 11:27:59 2018 +0200
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 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/fb5df622/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


[08/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/49b20a15
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/49b20a15
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/49b20a15

Branch: refs/heads/TINKERPOP-1342
Commit: 49b20a151b90dcf4481af7942505f7cd029bd23c
Parents: 91fbf22
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jan 25 14:46:31 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:38:20 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/49b20a15/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/49b20a15/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/49b20a15/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/49b20a15/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/49b20a15/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


[31/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/4f45cde5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4f45cde5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4f45cde5

Branch: refs/heads/TINKERPOP-1342
Commit: 4f45cde56da0128ec12e0c6bb3fea607fb6b24ae
Parents: 07683e3
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jun 15 08:16:03 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/4f45cde5/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" .


[18/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/7343ca89
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/7343ca89
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/7343ca89

Branch: refs/heads/TINKERPOP-1342
Commit: 7343ca89ad441294aca2878043f8db67135513be
Parents: 973d8cf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 29 11:04:23 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/7343ca89/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/7343ca89/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/7343ca89/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.


[03/50] tinkerpop git commit: This closes #842

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


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

Branch: refs/heads/TINKERPOP-1342
Commit: edf1ddcbc684edb61cdd8d6a6760aa52dca3fa6c
Parents: 1a7d50e
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 13 13:48:17 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 13:48:17 2018 -0400

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

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



[20/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/a9b5e570
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a9b5e570
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a9b5e570

Branch: refs/heads/TINKERPOP-1342
Commit: a9b5e57057b1f9b48eddf98750a1c95bc794a010
Parents: f02333a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 16:56:14 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/a9b5e570/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/a9b5e570/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"));
+    }
 }


[39/50] tinkerpop git commit: TINKERPOP-1878 Removed more references to "transpile"

Posted by sp...@apache.org.
TINKERPOP-1878 Removed more references to "transpile"


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

Branch: refs/heads/TINKERPOP-1342
Commit: e22665be46e5becdc6d9cdd9498b04b668da6b5b
Parents: 2fbae88
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 13 13:18:13 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 .../gremlin/sparql/SparqlToGremlinCompiler.java | 20 ++++++++++----------
 .../traversal/strategy/SparqlStrategy.java      |  4 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e22665be/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 4e00045..8a454f6 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
@@ -51,7 +51,7 @@ 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
+ * The engine that compiles SPARQL to Gremlin traversals thus enabling SPARQL to be executed on any TinkerPop-enabled
  * graph system.
  */
 public class SparqlToGremlinCompiler {
@@ -75,23 +75,23 @@ public class SparqlToGremlinCompiler {
      * 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
+     * @param sparqlQuery the query to compile to Gremlin
      */
-    public static GraphTraversal<Vertex, ?> transpile(final Graph graph, final String sparqlQuery) {
-        return transpile(graph.traversal(), sparqlQuery);
+    public static GraphTraversal<Vertex, ?> compile(final Graph graph, final String sparqlQuery) {
+        return compile(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
+     * @param sparqlQuery the query to compile to Gremlin
      */
-    public static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final String sparqlQuery) {
-        return transpile(g, QueryFactory.create(Prefixes.prepend(sparqlQuery), Syntax.syntaxSPARQL));
+    public static GraphTraversal<Vertex, ?> compile(final GraphTraversalSource g, final String sparqlQuery) {
+        return compile(g, QueryFactory.create(Prefixes.prepend(sparqlQuery), Syntax.syntaxSPARQL));
     }
 
-    private GraphTraversal<Vertex, ?> transpile(final Query query) {
+    private GraphTraversal<Vertex, ?> compile(final Query query) {
         final Op op = Algebra.compile(query);
         OpWalker.walk(op, new GremlinOpVisitor());
 
@@ -229,8 +229,8 @@ public class SparqlToGremlinCompiler {
         return orderingIndex;
     }
 
-    private static GraphTraversal<Vertex, ?> transpile(final GraphTraversalSource g, final Query query) {
-        return new SparqlToGremlinCompiler(g).transpile(query);
+    private static GraphTraversal<Vertex, ?> compile(final GraphTraversalSource g, final Query query) {
+        return new SparqlToGremlinCompiler(g).compile(query);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e22665be/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 38956f8..05cfd47 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
@@ -36,7 +36,7 @@ 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
+ * it as a string value. This strategy finds that step and compiles it to a Gremlin traversal which then replaces
  * the {@link ConstantStep}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
@@ -69,7 +69,7 @@ public class SparqlStrategy extends AbstractTraversalStrategy<TraversalStrategy.
             final Object[] injections = stepWithSparql.getInjections();
             if (injections.length == 1 && injections[0] instanceof String) {
                 final String sparql = (String) injections[0];
-                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinCompiler.transpile(
+                final Traversal<Vertex, ?> sparqlTraversal = SparqlToGremlinCompiler.compile(
                         traversal.getGraph().get(), sparql);
                 TraversalHelper.removeAllSteps(traversal);
                 sparqlTraversal.asAdmin().getSteps().forEach(s -> traversal.addStep(s));


[40/50] tinkerpop git commit: TINKERPOP-1878 Minor documentation fix around prefixes

Posted by sp...@apache.org.
TINKERPOP-1878 Minor documentation fix around prefixes


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

Branch: refs/heads/TINKERPOP-1342
Commit: c619e89a323dbc6f0fe0588c0485f6bf1735530e
Parents: f874849
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 13 13:42:27 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c619e89a/docs/src/reference/compilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/compilers.asciidoc b/docs/src/reference/compilers.asciidoc
index 2a8d561..fd41e92 100644
--- a/docs/src/reference/compilers.asciidoc
+++ b/docs/src/reference/compilers.asciidoc
@@ -89,10 +89,9 @@ The SPARQL-Gremlin compiler supports the following prefixes to traverse the grap
 [cols=",",options="header",]
 |====================================
 |Prefix |Purpose
-|`v:<label>` |label-access traversal
+|`v:<id|label|<name>>` |access to vertex id, label or property value
 |`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:


[26/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/0c815ebf
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0c815ebf
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0c815ebf

Branch: refs/heads/TINKERPOP-1342
Commit: 0c815ebf9d9046cd913c13737890f3ed933b53de
Parents: 510bbea
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun May 13 11:02:26 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 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/0c815ebf/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


[19/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/5967ccaa
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5967ccaa
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5967ccaa

Branch: refs/heads/TINKERPOP-1342
Commit: 5967ccaaa1e7f55f95e8272842b44947e70a8b93
Parents: a9b5e57
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jan 29 09:09:07 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:23 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5967ccaa/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());
+    }
 }


[43/50] tinkerpop git commit: TINKERPOP-1878 Minor code fix

Posted by sp...@apache.org.
TINKERPOP-1878 Minor code fix


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

Branch: refs/heads/TINKERPOP-1342
Commit: f874849f381c8059928de259506613fa13f85421
Parents: e22665b
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 13 13:34:06 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:24 2018 -0400

----------------------------------------------------------------------
 .../main/java/org/apache/tinkerpop/gremlin/sparql/Prefixes.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f874849f/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 32768a7..c2544e7 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
@@ -36,7 +36,7 @@ class Prefixes {
     static {
         final StringBuilder builder = new StringBuilder();
         for (final String prefix : PREFIXES) {
-            builder.append("PREFIX ").append(prefix.substring(0, 1)).append(": <").append(getURI(prefix)).
+            builder.append("PREFIX ").append(prefix, 0, 1).append(": <").append(getURI(prefix)).
                     append(">").append(System.lineSeparator());
         }
         PREFIX_DEFINITIONS = builder.toString();


[17/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/b8530424
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b8530424
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b8530424

Branch: refs/heads/TINKERPOP-1342
Commit: b8530424cea63d80893a6d925b019f767aa9c310
Parents: f1e17cb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jan 26 08:16:24 2018 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 13 14:39:22 2018 -0400

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


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b8530424/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 fa7347c..9c0ef8a 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
@@ -406,7 +406,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***
         }};
     }