Search in sources :

Example 1 with MatchConstraintBuilder

use of org.vertexium.cypher.executor.utils.MatchConstraintBuilder in project vertexium by visallo.

the class MatchClauseExecutor method execute.

public VertexiumCypherScope execute(VertexiumCypherQueryContext ctx, List<CypherMatchClause> matchClauses, VertexiumCypherScope scope) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("execute: %s", matchClauses.stream().map(CypherMatchClause::toString).collect(Collectors.joining("; ")));
    }
    MatchConstraints matchConstraints = new MatchConstraintBuilder().getMatchConstraints(matchClauses);
    Stream<VertexiumCypherScope.Item> results = scope.stream().flatMap(item -> executeMatchConstraints(ctx, matchConstraints, item));
    return VertexiumCypherScope.newItemsScope(results, scope);
}
Also used : MatchConstraintBuilder(org.vertexium.cypher.executor.utils.MatchConstraintBuilder)

Example 2 with MatchConstraintBuilder

use of org.vertexium.cypher.executor.utils.MatchConstraintBuilder in project vertexium by visallo.

the class MergeClauseExecutor method execute.

public VertexiumCypherScope execute(VertexiumCypherQueryContext ctx, CypherMergeClause clause, VertexiumCypherScope scope) {
    LOGGER.debug("execute: %s", clause);
    // need to materialize the scope
    scope.run();
    PatternPartMatchConstraint patternPartConstraint = new MatchConstraintBuilder().patternPartToConstraints(clause.getPatternPart(), false);
    Stream<VertexiumCypherScope> results = scope.stream().map(item -> {
        Stream<VertexiumCypherScope.Item> patternPartResults = ctx.getMatchClauseExecutor().executePatternPartConstraint(ctx, patternPartConstraint, item);
        return StreamUtils.ifEmpty(patternPartResults, () -> {
            Stream<VertexiumCypherScope.Item> createResults = executeCreate(ctx, clause, patternPartConstraint, item);
            return VertexiumCypherScope.newItemsScope(createResults, scope);
        }, (stream) -> executeMatch(ctx, clause, stream, scope));
    });
    return results.collect(VertexiumCypherScope.concatStreams(scope));
}
Also used : PatternPartMatchConstraint(org.vertexium.cypher.executor.models.match.PatternPartMatchConstraint) MatchConstraintBuilder(org.vertexium.cypher.executor.utils.MatchConstraintBuilder) VertexiumCypherScope(org.vertexium.cypher.VertexiumCypherScope)

Aggregations

MatchConstraintBuilder (org.vertexium.cypher.executor.utils.MatchConstraintBuilder)2 VertexiumCypherScope (org.vertexium.cypher.VertexiumCypherScope)1 PatternPartMatchConstraint (org.vertexium.cypher.executor.models.match.PatternPartMatchConstraint)1