Search in sources :

Example 1 with MatchPartition

use of com.apple.foundationdb.record.query.plan.temp.MatchPartition in project fdb-record-layer by FoundationDB.

the class MatchPartitionMatchers method ofExpressionOptionalAndMatches.

public static <O extends Optional<RelationalExpression>, C extends Collection<? extends PartialMatch>> BindingMatcher<MatchPartition> ofExpressionOptionalAndMatches(@Nonnull final BindingMatcher<O> downstreamExpressionOptional, @Nonnull final BindingMatcher<C> downstreamMatches) {
    return typedWithDownstream(MatchPartition.class, Extractor.identity(), AllOfMatcher.matchingAllOf(MatchPartition.class, ImmutableList.of(typedWithDownstream(MatchPartition.class, Extractor.of(matchPartition -> {
        final Set<PartialMatch> partialMatches = matchPartition.getPartialMatches();
        final Iterator<PartialMatch> iterator = partialMatches.iterator();
        RelationalExpression lastExpression = null;
        while (iterator.hasNext()) {
            final PartialMatch partialMatch = iterator.next();
            if (lastExpression == null) {
                lastExpression = partialMatch.getQueryExpression();
            } else if (lastExpression != partialMatch.getQueryExpression()) {
                return Optional.empty();
            }
        }
        return Optional.ofNullable(lastExpression);
    }, name -> "expressionOptional(" + name + ")"), downstreamExpressionOptional), typedWithDownstream(MatchPartition.class, Extractor.of(MatchPartition::getPartialMatches, name -> "partialMatches(" + name + ")"), downstreamMatches))));
}
Also used : RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) PartialMatch(com.apple.foundationdb.record.query.plan.temp.PartialMatch) MatchPartition(com.apple.foundationdb.record.query.plan.temp.MatchPartition)

Aggregations

MatchPartition (com.apple.foundationdb.record.query.plan.temp.MatchPartition)1 PartialMatch (com.apple.foundationdb.record.query.plan.temp.PartialMatch)1 RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)1