use of com.apple.foundationdb.record.EvaluationContextBuilder in project fdb-record-layer by FoundationDB.
the class RecordQueryScoreForRankPlan method bindScores.
private <M extends Message> CompletableFuture<EvaluationContext> bindScores(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nonnull IsolationLevel isolationLevel) {
final List<CompletableFuture<Tuple>> scores = ranks.stream().map(r -> bindScore(store, context, r, isolationLevel)).collect(Collectors.toList());
return AsyncUtil.whenAll(scores).thenApply(vignore -> {
EvaluationContextBuilder builder = context.childBuilder();
for (int i = 0; i < scores.size(); i++) {
final ScoreForRank rank = ranks.get(i);
final Tuple score = store.getContext().joinNow(scores.get(i));
final Object binding;
if (score == null) {
binding = null;
} else if (score == RankedSetIndexHelper.COMPARISON_SKIPPED_SCORE) {
binding = Comparisons.COMPARISON_SKIPPED_BINDING;
} else {
binding = rank.bindingFunction.apply(score);
}
builder.setBinding(rank.bindingName, binding);
}
return builder.build();
});
}
Aggregations