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/e09dd295 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e09dd295 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e09dd295 Branch: refs/heads/TINKERPOP-1878 Commit: e09dd29544cf3925a8e1bc406cd3477d45805085 Parents: 06fa430 Author: Stephen Mallette <sp...@genoprime.com> Authored: Thu Jan 25 14:49:18 2018 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Thu Aug 2 06:49:16 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/e09dd295/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/e09dd295/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(); - } -}