use of org.vertexium.cypher.VertexiumCypherQuery in project vertexium by visallo.
the class ExecuteCypherQuery method run.
private int run(String[] args) throws Exception {
Parameters params = new Parameters();
JCommander j = new JCommander(params, args);
if (params.help) {
j.usage();
return -1;
}
Map<String, String> config = ConfigurationUtils.loadConfig(params.getConfigFileNames(), params.configPropertyPrefix);
Graph graph = new GraphFactory().createGraph(config);
Authorizations authorizations = params.getAuthorizations(graph);
VertexiumCypherQueryContext ctx = new CliVertexiumCypherQueryContext(graph, authorizations);
CliVertexiumCypherQueryContext.setLabelPropertyName(params.cypherLabelProperty);
CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
long startTime = System.currentTimeMillis();
String queryString = params.query.stream().collect(Collectors.joining(" "));
VertexiumCypherQuery query = VertexiumCypherQuery.parse(compilerContext, queryString);
VertexiumCypherResult results = query.execute(ctx);
results.stream().forEach(row -> {
results.getColumnNames().forEach(column -> {
System.out.println(row.getByName(column));
});
});
long endTime = System.currentTimeMillis();
LOGGER.info("total time: %.2fs", ((double) (endTime - startTime) / 1000.0));
return 0;
}
use of org.vertexium.cypher.VertexiumCypherQuery in project vertexium by visallo.
the class VertexiumScript method executeCypher.
public static Object executeCypher(String code) {
VertexiumCypherQueryContext ctx = new CliVertexiumCypherQueryContext(getGraph(), getAuthorizations());
CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
VertexiumCypherQuery query = VertexiumCypherQuery.parse(compilerContext, code);
return query.execute(ctx);
}
Aggregations