From commits-return-31672-archive-asf-public=cust-asf.ponee.io@tinkerpop.apache.org Thu Aug 16 18:57:58 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3AE5F18067E for ; Thu, 16 Aug 2018 18:57:57 +0200 (CEST) Received: (qmail 16123 invoked by uid 500); 16 Aug 2018 16:57:51 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 15723 invoked by uid 99); 16 Aug 2018 16:57:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Aug 2018 16:57:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4129BE11A4; Thu, 16 Aug 2018 16:57:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: spmallette@apache.org To: commits@tinkerpop.apache.org Date: Thu, 16 Aug 2018 16:58:06 -0000 Message-Id: <687769a6860746599e3a230e4a41da16@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [18/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/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 Authored: Mon Jan 29 11:04:23 2018 -0500 Committer: Stephen Mallette 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] +---- + + org.apache.tinkerpop + sparql-gremlin + x.y.z + +---- + +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 +<> to transparently converts that SPARQL query into a standard Gremlin traversal +and then when finally iterated, executes that against the TinkerGraph.