use of org.opencypher.gremlin.client.CypherResultSet in project cypher-for-gremlin by opencypher.
the class CypherGremlinServerClient method gremlinStyle.
@Test
public void gremlinStyle() throws Exception {
BaseConfiguration configuration = new BaseConfiguration();
configuration.setProperty("port", gremlinServer.getPort());
configuration.setProperty("hosts", Arrays.asList("localhost"));
// freshReadmeSnippet: gremlinStyle
Cluster cluster = Cluster.open(configuration);
Client gremlinClient = cluster.connect();
CypherGremlinClient cypherGremlinClient = CypherGremlinClient.plugin(gremlinClient);
String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name";
CypherResultSet resultSet = cypherGremlinClient.submit(cypher);
List<Map<String, Object>> results = resultSet.all();
// freshReadmeSnippet: gremlinStyle
assertThat(results).extracting("p.name").containsExactly("marko", "vadas", "josh", "peter");
}
use of org.opencypher.gremlin.client.CypherResultSet in project cypher-for-gremlin by opencypher.
the class CypherRemoteAcceptor method send.
private List<Result> send(String query) throws Exception {
CompletableFuture<CypherResultSet> resultsFuture = client.submitAsync(query);
CypherResultSet resultSet = (timeout > NO_TIMEOUT) ? resultsFuture.get(timeout, TimeUnit.MILLISECONDS) : resultsFuture.get();
return resultSet.stream().map(Result::new).collect(toList());
}
use of org.opencypher.gremlin.client.CypherResultSet in project cypher-for-gremlin by opencypher.
the class CypherGremlinServerClient method async.
@Test
public void async() {
CypherGremlinClient cypherGremlinClient = gremlinServer.cypherGremlinClient();
// freshReadmeSnippet: async
String cypher = "MATCH (p:person) WHERE p.age > 25 RETURN p.name";
CompletableFuture<CypherResultSet> future = cypherGremlinClient.submitAsync(cypher);
future.thenApply(CypherResultSet::all).thenAccept(resultSet -> {
// ...
});
// freshReadmeSnippet: async
}
Aggregations