use of org.vertexium.cypher.VertexiumCypherScope in project vertexium by visallo.
the class QueryExecutor method executeUnion.
private VertexiumCypherScope executeUnion(VertexiumCypherQueryContext ctx, CypherUnion union) {
VertexiumCypherScope leftResults = executeQuery(ctx, union.getLeft());
VertexiumCypherScope rightResults = executeQuery(ctx, union.getRight());
return leftResults.concat(rightResults, !union.isAll(), null);
}
use of org.vertexium.cypher.VertexiumCypherScope in project vertexium by visallo.
the class QueryExecutor method execute.
private VertexiumCypherScope execute(VertexiumCypherQueryContext ctx, CypherQuery cypherQuery) {
VertexiumCypherScope scope = VertexiumCypherScope.newSingleItemScope(VertexiumCypherScope.newEmptyItem());
ImmutableList<CypherClause> clauses = cypherQuery.getClauses();
AtomicInteger clauseIndex = new AtomicInteger(0);
for (; clauseIndex.intValue() < clauses.size(); clauseIndex.incrementAndGet()) {
scope = execute(ctx, clauses, clauseIndex, scope);
}
if (clauses.get(clauses.size() - 1) instanceof CypherReturnClause) {
return scope;
}
scope.run();
return VertexiumCypherScope.newEmpty();
}
use of org.vertexium.cypher.VertexiumCypherScope in project vertexium by visallo.
the class QueryExecutor method execute.
private VertexiumCypherScope execute(VertexiumCypherQueryContext ctx, ImmutableList<CypherClause> clauses, AtomicInteger clauseIndex, VertexiumCypherScope previousScope) {
VertexiumCypherScope results;
CypherClause clause = clauses.get(clauseIndex.get());
if (clause instanceof CypherCreateClause) {
results = ctx.getCreateClauseExecutor().execute(ctx, (CypherCreateClause) clause, previousScope);
} else if (clause instanceof CypherReturnClause) {
results = ctx.getReturnClauseExecutor().execute(ctx, (CypherReturnClause) clause, previousScope);
} else if (clause instanceof CypherMatchClause) {
List<CypherMatchClause> matchClauses = getSimilarClauses(clauses, clauseIndex.get(), CypherMatchClause.class);
results = ctx.getMatchClauseExecutor().execute(ctx, matchClauses, previousScope);
clauseIndex.addAndGet(matchClauses.size() - 1);
} else if (clause instanceof CypherUnwindClause) {
List<CypherUnwindClause> unwindClauses = getSimilarClauses(clauses, clauseIndex.get(), CypherUnwindClause.class);
results = ctx.getUnwindClauseExecutor().execute(ctx, unwindClauses, previousScope);
clauseIndex.addAndGet(unwindClauses.size() - 1);
} else if (clause instanceof CypherWithClause) {
results = ctx.getWithClauseExecutor().execute(ctx, (CypherWithClause) clause, previousScope);
} else if (clause instanceof CypherMergeClause) {
results = ctx.getMergeClauseExecutor().execute(ctx, (CypherMergeClause) clause, previousScope);
} else if (clause instanceof CypherDeleteClause) {
results = ctx.getDeleteClauseExecutor().execute(ctx, (CypherDeleteClause) clause, previousScope);
} else if (clause instanceof CypherSetClause) {
results = ctx.getSetClauseExecutor().execute(ctx, (CypherSetClause) clause, previousScope);
} else if (clause instanceof CypherRemoveClause) {
results = ctx.getRemoveClauseExecutor().execute(ctx, (CypherRemoveClause) clause, previousScope);
} else {
throw new VertexiumException("clause not implemented \"" + clause.getClass().getName() + "\": " + clause);
}
return results;
}
Aggregations