Search in sources :

Example 6 with VertexiumCypherScope

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);
}
Also used : VertexiumCypherScope(org.vertexium.cypher.VertexiumCypherScope)

Example 7 with VertexiumCypherScope

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();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) VertexiumCypherScope(org.vertexium.cypher.VertexiumCypherScope)

Example 8 with VertexiumCypherScope

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;
}
Also used : VertexiumException(org.vertexium.VertexiumException) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VertexiumCypherScope(org.vertexium.cypher.VertexiumCypherScope)

Aggregations

VertexiumCypherScope (org.vertexium.cypher.VertexiumCypherScope)8 VertexiumException (org.vertexium.VertexiumException)3 ArrayList (java.util.ArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)1 java.util (java.util)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 VertexiumCypherQueryContext (org.vertexium.cypher.VertexiumCypherQueryContext)1 org.vertexium.cypher.ast.model (org.vertexium.cypher.ast.model)1 CypherUnwindClause (org.vertexium.cypher.ast.model.CypherUnwindClause)1 VertexiumCypherNotImplemented (org.vertexium.cypher.exceptions.VertexiumCypherNotImplemented)1 PatternPartMatchConstraint (org.vertexium.cypher.executor.models.match.PatternPartMatchConstraint)1 MatchConstraintBuilder (org.vertexium.cypher.executor.utils.MatchConstraintBuilder)1 CypherFunction (org.vertexium.cypher.functions.CypherFunction)1 AggregationFunction (org.vertexium.cypher.functions.aggregate.AggregationFunction)1 ObjectUtils (org.vertexium.cypher.utils.ObjectUtils)1 StreamUtils (org.vertexium.util.StreamUtils)1 StreamUtils.stream (org.vertexium.util.StreamUtils.stream)1