Search in sources :

Example 1 with Pipeline

use of com.tinkerpop.pipes.util.Pipeline in project gremlin by tinkerpop.

the class GremlinGroovyScriptEngineTest method testUTF8Query.

public void testUTF8Query() throws Exception {
    TinkerGraph graph = new TinkerGraph();
    Index<Vertex> index = graph.createIndex("nodes", Vertex.class);
    Vertex nonUtf8 = graph.addVertex("1");
    nonUtf8.setProperty("name", "marko");
    nonUtf8.setProperty("age", 29);
    index.put("name", "marko", nonUtf8);
    Vertex utf8Name = graph.addVertex("2");
    utf8Name.setProperty("name", "轉注");
    utf8Name.setProperty("age", 32);
    index.put("name", "轉注", utf8Name);
    graph.addVertex(utf8Name);
    graph.addEdge("12", nonUtf8, utf8Name, "created").setProperty("weight", 0.2f);
    ScriptEngine engine = new GremlinGroovyScriptEngine();
    engine.put("g", graph);
    Pipeline eval = (Pipeline) engine.eval("g.idx(\"nodes\")[['name' : 'marko']]");
    assertEquals(nonUtf8, eval.next());
    eval = (Pipeline) engine.eval("g.idx(\"nodes\")[['name' : '轉注']]");
    assertEquals(utf8Name, eval.next());
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) ScriptEngine(javax.script.ScriptEngine) Pipeline(com.tinkerpop.pipes.util.Pipeline)

Aggregations

Vertex (com.tinkerpop.blueprints.Vertex)1 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 Pipeline (com.tinkerpop.pipes.util.Pipeline)1 ScriptEngine (javax.script.ScriptEngine)1