diff --git a/pom.xml b/pom.xml index c232a4e..cf8d3b3 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ org.apache.httpcomponents httpclient - 4.0.1 + 4.1.1 org.json diff --git a/src/main/java/com/tinkerpop/jig/JigConsole.java b/src/main/java/com/tinkerpop/jig/JigConsole.java index c42bb33..6ac6a89 100644 --- a/src/main/java/com/tinkerpop/jig/JigConsole.java +++ b/src/main/java/com/tinkerpop/jig/JigConsole.java @@ -12,6 +12,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -103,11 +104,16 @@ private boolean tryLine(final String line) throws ScriptException, JSONException } private boolean executeScript(final String script) throws ScriptException, JSONException { + //long before = new Date().getTime(); + System.out.println(""); Object result = scriptEngine.eval(script.trim()); showResult(result); System.out.println(""); + //long after = new Date().getTime(); + //System.out.println("[script took " + (after - before) + "ms]"); + // TODO: provide a "quit" command return true; } diff --git a/src/main/java/com/tinkerpop/jig/JigScriptEngine.java b/src/main/java/com/tinkerpop/jig/JigScriptEngine.java index 4d61a41..00e15db 100644 --- a/src/main/java/com/tinkerpop/jig/JigScriptEngine.java +++ b/src/main/java/com/tinkerpop/jig/JigScriptEngine.java @@ -25,6 +25,7 @@ import java.io.Writer; import java.util.Arrays; import java.util.Collection; +import java.util.Date; import java.util.LinkedList; /** @@ -237,7 +238,10 @@ private Object issueRequest(final String script) throws IOException, JSONExcepti String auth = new String(Base64.encodeBase64((userName + ":" + password).getBytes())); request.setHeader("Authorization", "Basic " + auth); + //long before = new Date().getTime(); HttpResponse response = client.execute(request); + long after = new Date().getTime(); + //System.out.println("[request took " + (after - before) + "ms]"); int responseCode = response.getStatusLine().getStatusCode(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); diff --git a/src/main/javascript/jans.js b/src/main/javascript/jans.js new file mode 100644 index 0000000..0dcb52c --- /dev/null +++ b/src/main/javascript/jans.js @@ -0,0 +1,36 @@ +// Name of the triple store +store.name + +// Number of triples in the store +store.size + +// Look at a few triples +g.triples.limit(10) + +// Labels (predicates) only +g.triples.limit(10).label + +// Find more labels +g.triples.limit(100000).label.distinct + +// Pick out a single label (rdf:type in this case) +type = g.triples.limit(100000).label.distinct[6] + +// Find distinct types +g.triples(null, type, null).head.limit(100000).distinct + +// Let's look at the "drugs" type +drugs = g.triples(null, type, null).head.limit(100000).distinct[1] + +// Here are some instances of "drugs" +d = g.v(drugs).inE(type).limit(10).tail + +// Pick a drug at random, find its neighborhood as a ranked list +d0 = g.v(d[0]).nearby(2).aggr + +// Do the same for another node +d9 = g.v(d[9]).nearby(2).aggr + +// Find the intersection (entry-wise product) of the two neighborhoods. +// These are nodes "nearby" to both nodes in the graph +intersect(d0, d9)