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

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

TINKERPOP-1878 Added basic docs for sparql-gremlin


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

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

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


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

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

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8e6acf43/docs/src/reference/transpilers.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/transpilers.asciidoc b/docs/src/reference/transpilers.asciidoc
new file mode 100644
index 0000000..305e3dc
--- /dev/null
+++ b/docs/src/reference/transpilers.asciidoc
@@ -0,0 +1,66 @@
+////
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+////
+[[transpilers]]
+= Gremlin Transpilers
+
+There are many languages built to query data. SQL is typically used to query relational data. There is SPARQL for RDF
+data. Cypher is used to do pattern matching in graph data. The list could go on. Transpilers convert languages like
+these to Gremlin so that it becomes possible to use them in any context that Gremlin is used. In other words, a
+Gremlin Transpiler enables a particular query language to work on any TinkerPop-enabled graph system.
+
+== SPARQL-Gremlin
+
+[source,xml]
+----
+<dependency>
+   <groupId>org.apache.tinkerpop</groupId>
+   <artifactId>sparql-gremlin</artifactId>
+   <version>x.y.z</version>
+</dependency>
+----
+
+The SPARQL-Gremlin transpiler converts link:https://en.wikipedia.org/wiki/SPARQL[SPARQL] queries into Gremlin so that
+they can be executed across any TinkerPop-enabled graph system. To use this transpiler in the Gremlin Console, first
+install and activate the "tinkerpop.sparql" plugin:
+
+[source,text]
+----
+gremlin> :install org.apache.tinkerpop sparql-gremlin x.y.z
+==>Loaded: [org.apache.tinkerpop, sparql-gremlin, x.y.z]
+gremlin> :plugin use tinkerpop.sparql
+==>tinkerpop.sparql activated
+----
+
+Installing this plugin will download appropriate dependencies and import certain classes to the console so that they
+may be used as follows:
+
+[gremlin-groovy,modern]
+----
+graph = TinkerFactory.createModern()
+g = graph.traversal(SparqlTraversalSource)                                                             <1>
+g.sparql("""SELECT ?name ?age
+            WHERE { ?person v:name ?name . ?person v:age ?age }
+            ORDER BY ASC(?age)""")                                                                     <2>
+----
+
+<1> Define `g` as a `TraversalSource` that uses the `SparqlTraversalSource` - by default, the `traversal()` method
+usually returns a `GraphTraversalSource` which includes the standard Gremlin starts steps like `V()` or `E()`. In this
+case, the `SparqlTraversalSource` enables starts steps that are specific to SPARQL only - in this case the `sparql()`
+start step.
+<2> Execute a SPARQL query against the TinkerGraph instance. The `SparqlTraversalSource` uses a
+<<traversalstrategy,TraversalStrategy>> to transparently converts that SPARQL query into a standard Gremlin traversal
+and then when finally iterated, executes that against the TinkerGraph.