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))));
}
Aggregations