use of org.vertexium.cypher.executor.models.match.PatternPartMatchConstraint 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));
}
Aggregations