use of org.apache.tinkerpop.gremlin.driver.Result in project cypher-for-gremlin by opencypher.
the class CypherRemoteAcceptor method submit.
@Override
public Object submit(List<String> args) throws RemoteException {
String line = String.join(" ", args);
line = DriverRemoteAcceptor.getScript(line, shellEnvironment);
try {
final List<Result> resultSet = send(line);
shellEnvironment.setVariable(RESULT, resultSet);
return resultSet.stream().map(Result::getObject).iterator();
} catch (Exception ex) {
throw new RemoteException(ex);
}
}
use of org.apache.tinkerpop.gremlin.driver.Result in project cypher-for-gremlin by opencypher.
the class CommonResultSets method explain.
static CypherResultSet explain(CypherAstWrapper ast) {
Map<String, Object> explanation = new LinkedHashMap<>();
Translator<String, GroovyPredicate> translator = Translator.builder().gremlinGroovy().inlineParameters().build();
explanation.put("translation", ast.buildTranslation(translator));
explanation.put("options", ast.getOptions().toString());
Iterator<Result> iterator = singletonIterator(() -> new Result(explanation));
return new CypherResultSet(iterator);
}
use of org.apache.tinkerpop.gremlin.driver.Result in project cypher-for-gremlin by opencypher.
the class CypherResultSet method iterator.
/**
* Returns a blocking iterator of the items streaming from the server to the client.
*
* @return query results iterator
*/
@Override
public Iterator<Map<String, Object>> iterator() {
return new Iterator<Map<String, Object>>() {
@Override
public boolean hasNext() {
return resultIterator.hasNext();
}
@Override
public Map<String, Object> next() {
Result result = resultIterator.next();
Object row = result.getObject();
return returnNormalizer.apply(row);
}
};
}
use of org.apache.tinkerpop.gremlin.driver.Result in project cypher-for-gremlin by opencypher.
the class InMemoryCypherGremlinClient method submitAsync.
@Override
public CompletableFuture<CypherResultSet> submitAsync(String cypher, Map<String, ?> parameters) {
CypherAstWrapper ast;
try {
ast = CypherAstWrapper.parse(cypher, parameters);
} catch (Exception e) {
return completedFuture(exceptional(e));
}
if (ast.getOptions().contains(EXPLAIN)) {
return completedFuture(explain(ast));
}
DefaultGraphTraversal g = new DefaultGraphTraversal(gts.clone());
Translator<GraphTraversal, P> translator = Translator.builder().traversal(g).build();
GraphTraversal<?, ?> traversal = ast.buildTranslation(translator);
ReturnNormalizer returnNormalizer = ReturnNormalizer.create(ast.getReturnTypes());
List<Result> results = traversal.toStream().map(returnNormalizer::normalize).map(Result::new).collect(toList());
return completedFuture(new CypherResultSet(results.iterator()));
}
use of org.apache.tinkerpop.gremlin.driver.Result in project janusgraph by JanusGraph.
the class RemoteGraphApp method createSchema.
@Override
public void createSchema() {
LOGGER.info("creating schema");
// get the schema request as a string
final String req = createSchemaRequest();
// submit the request to the server
final ResultSet resultSet = client.submit(req);
// drain the results completely
Stream<Result> futureList = resultSet.stream();
futureList.map(Result::toString).forEach(LOGGER::info);
}
Aggregations