Search in sources :

Example 1 with EvaluationContextBuilder

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();
    });
}
Also used : Iterables(com.google.common.collect.Iterables) StoreTimer(com.apple.foundationdb.record.provider.common.StoreTimer) IndexAggregateFunction(com.apple.foundationdb.record.metadata.IndexAggregateFunction) Quantifier(com.apple.foundationdb.record.query.plan.temp.Quantifier) CompletableFuture(java.util.concurrent.CompletableFuture) AsyncUtil(com.apple.foundationdb.async.AsyncUtil) GroupExpressionRef(com.apple.foundationdb.record.query.plan.temp.GroupExpressionRef) Function(java.util.function.Function) PlanHashable(com.apple.foundationdb.record.PlanHashable) ExecuteProperties(com.apple.foundationdb.record.ExecuteProperties) Tuple(com.apple.foundationdb.tuple.Tuple) ImmutableList(com.google.common.collect.ImmutableList) AliasMap(com.apple.foundationdb.record.query.plan.temp.AliasMap) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) FDBRecordStoreBase(com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase) IsolationLevel(com.apple.foundationdb.record.IsolationLevel) ImmutableSet(com.google.common.collect.ImmutableSet) FDBStoreTimer(com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer) RankedSetIndexHelper(com.apple.foundationdb.record.provider.foundationdb.indexes.RankedSetIndexHelper) Set(java.util.Set) EvaluationContextBuilder(com.apple.foundationdb.record.EvaluationContextBuilder) Collectors(java.util.stream.Collectors) QueriedValue(com.apple.foundationdb.record.query.predicates.QueriedValue) TupleRange(com.apple.foundationdb.record.TupleRange) RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) Objects(java.util.Objects) Value(com.apple.foundationdb.record.query.predicates.Value) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) List(java.util.List) CorrelationIdentifier(com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier) EvaluationContext(com.apple.foundationdb.record.EvaluationContext) ObjectPlanHash(com.apple.foundationdb.record.ObjectPlanHash) Message(com.google.protobuf.Message) RecordCursor(com.apple.foundationdb.record.RecordCursor) API(com.apple.foundationdb.annotation.API) PlannerGraph(com.apple.foundationdb.record.query.plan.temp.explain.PlannerGraph) NodeInfo(com.apple.foundationdb.record.query.plan.temp.explain.NodeInfo) Collections(java.util.Collections) AvailableFields(com.apple.foundationdb.record.query.plan.AvailableFields) CompletableFuture(java.util.concurrent.CompletableFuture) EvaluationContextBuilder(com.apple.foundationdb.record.EvaluationContextBuilder) Tuple(com.apple.foundationdb.tuple.Tuple)

Aggregations

API (com.apple.foundationdb.annotation.API)1 AsyncUtil (com.apple.foundationdb.async.AsyncUtil)1 EvaluationContext (com.apple.foundationdb.record.EvaluationContext)1 EvaluationContextBuilder (com.apple.foundationdb.record.EvaluationContextBuilder)1 ExecuteProperties (com.apple.foundationdb.record.ExecuteProperties)1 IsolationLevel (com.apple.foundationdb.record.IsolationLevel)1 ObjectPlanHash (com.apple.foundationdb.record.ObjectPlanHash)1 PlanHashable (com.apple.foundationdb.record.PlanHashable)1 RecordCursor (com.apple.foundationdb.record.RecordCursor)1 TupleRange (com.apple.foundationdb.record.TupleRange)1 IndexAggregateFunction (com.apple.foundationdb.record.metadata.IndexAggregateFunction)1 StoreTimer (com.apple.foundationdb.record.provider.common.StoreTimer)1 FDBRecordStoreBase (com.apple.foundationdb.record.provider.foundationdb.FDBRecordStoreBase)1 FDBStoreTimer (com.apple.foundationdb.record.provider.foundationdb.FDBStoreTimer)1 RankedSetIndexHelper (com.apple.foundationdb.record.provider.foundationdb.indexes.RankedSetIndexHelper)1 Comparisons (com.apple.foundationdb.record.query.expressions.Comparisons)1 AvailableFields (com.apple.foundationdb.record.query.plan.AvailableFields)1 AliasMap (com.apple.foundationdb.record.query.plan.temp.AliasMap)1 CorrelationIdentifier (com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier)1 GroupExpressionRef (com.apple.foundationdb.record.query.plan.temp.GroupExpressionRef)1