use of org.apache.tinkerpop.gremlin.driver.ResultSet in project cypher-for-gremlin by opencypher.
the class GroovyCypherGremlinClient 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));
}
Translator<String, GroovyPredicate> translator = Translator.builder().gremlinGroovy().build(flavor);
String gremlin = ast.buildTranslation(translator);
Map<String, Object> extractedParameters = ast.getExtractedParameters();
CompletableFuture<ResultSet> resultSetFuture = client.submitAsync(gremlin, extractedParameters);
ReturnNormalizer returnNormalizer = ReturnNormalizer.create(ast.getReturnTypes());
return resultSetFuture.thenApply(ResultSet::iterator).thenApply(resultIterator -> new CypherResultSet(resultIterator, returnNormalizer::normalize));
}
use of org.apache.tinkerpop.gremlin.driver.ResultSet in project cypher-for-gremlin by opencypher.
the class BytecodeCypherGremlinClient 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));
}
Translator<Bytecode, P> translator = Translator.builder().bytecode().build(flavor);
Bytecode bytecode = ast.buildTranslation(translator);
CompletableFuture<ResultSet> resultSetFuture = client.submitAsync(bytecode);
ReturnNormalizer returnNormalizer = ReturnNormalizer.create(ast.getReturnTypes());
return resultSetFuture.thenApply(ResultSet::iterator).thenApply(resultIterator -> new CypherResultSet(new TraverserIterator(resultIterator), returnNormalizer::normalize));
}
use of org.apache.tinkerpop.gremlin.driver.ResultSet in project cypher-for-gremlin by opencypher.
the class OpProcessorCypherGremlinClient method submitAsync.
@Override
public CompletableFuture<CypherResultSet> submitAsync(String cypher, Map<String, ?> parameters) {
RequestMessage requestMessage = buildRequest(cypher, parameters).create();
CompletableFuture<ResultSet> resultSetFuture = client.submitAsync(requestMessage);
return resultSetFuture.thenApply(ResultSet::iterator).thenApply(CypherResultSet::new);
}
use of org.apache.tinkerpop.gremlin.driver.ResultSet in project DataX by alibaba.
the class AbstractGdbGraph method runInternal.
/**
* @param dsl
* @param parameters
*/
protected void runInternal(final String dsl, final Map<String, Object> parameters) throws Exception {
final RequestOptions.Builder options = RequestOptions.build().timeout(DEFAULT_TIMEOUT);
if (parameters != null && !parameters.isEmpty()) {
parameters.forEach(options::addParameter);
}
final ResultSet results = this.client.submitAsync(dsl, options.create()).get(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
results.all().get(DEFAULT_TIMEOUT + 1000, TimeUnit.MILLISECONDS);
}
use of org.apache.tinkerpop.gremlin.driver.ResultSet 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