Search in sources :

Example 1 with RecordQueryScoreForRankPlan

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

the class RankComparisons method wrap.

@Nonnull
public RecordQueryPlan wrap(@Nonnull RecordQueryPlan plan, @Nullable Set<RankComparison> includedRankComparisons, @Nonnull RecordMetaData metaData) {
    if (comparisons.isEmpty()) {
        return plan;
    }
    List<RecordQueryScoreForRankPlan.ScoreForRank> ranks = new ArrayList<>(comparisons.size());
    for (RankComparison rankComparison : comparisons.values()) {
        if (includedRankComparisons != null && includedRankComparisons.contains(rankComparison)) {
            continue;
        }
        ranks.add(rankComparison.getScoreForRank(metaData));
    }
    if (!ranks.isEmpty()) {
        // Make exact plan deterministic.
        Collections.sort(ranks, Comparator.comparing(RecordQueryScoreForRankPlan.ScoreForRank::getBindingName));
        plan = new RecordQueryScoreForRankPlan(plan, ranks);
    }
    return plan;
}
Also used : ArrayList(java.util.ArrayList) RecordQueryScoreForRankPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryScoreForRankPlan) Nonnull(javax.annotation.Nonnull)

Aggregations

RecordQueryScoreForRankPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryScoreForRankPlan)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1