use of org.vertexium.cypher.ast.CypherCompilerContext 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.ast.CypherCompilerContext in project vertexium by visallo.
the class GraphGlue method givenHavingExecuted.
@Given("^having executed:$")
public void givenHavingExecuted(String queryString) {
CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
VertexiumCypherQuery.parse(compilerContext, queryString).execute(ctx);
}
use of org.vertexium.cypher.ast.CypherCompilerContext 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);
}
use of org.vertexium.cypher.ast.CypherCompilerContext in project vertexium by visallo.
the class GraphGlue method whenExecutingQuery.
@When("^executing(.*)query:$")
public void whenExecutingQuery(String queryName, String queryString) {
ctx.clearCounts();
lastResults = null;
lastCompileTimeException = null;
lastRuntimeException = null;
try {
CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
query = VertexiumCypherQuery.parse(compilerContext, queryString);
} catch (Exception ex) {
lastCompileTimeException = ex;
}
try {
lastResults = query.execute(ctx);
lastResults.size();
} catch (Exception ex) {
lastRuntimeException = ex;
}
}
use of org.vertexium.cypher.ast.CypherCompilerContext in project vertexium by visallo.
the class GraphGlue method givenTheBinaryTreeGraph.
@Given("^the binary-tree-(\\d+) graph$")
public void givenTheBinaryTreeGraph(int number) throws Throwable {
createGraph();
String resourceName = "/org/vertexium/cypher/tck/binary-tree-" + number + ".cyp";
InputStream treeIn = this.getClass().getResourceAsStream(resourceName);
if (treeIn == null) {
throw new VertexiumException("Could not find '" + resourceName + "'");
}
String cyp = IOUtils.toString(treeIn);
CypherCompilerContext compilerContext = new CypherCompilerContext(ctx.getFunctions());
VertexiumCypherQuery.parse(compilerContext, cyp).execute(ctx);
}
Aggregations