Class PlanOrderingKey
- java.lang.Object
-
- com.apple.foundationdb.record.query.plan.PlanOrderingKey
-
@API(INTERNAL) public class PlanOrderingKey extends Object
The keys that order the results from a plan. Given a record type with primary keyk1, k2
and an index onk1, v1, v2
, the index entries arek1, v1, v2, k2
. Given a scan on this index fork1 = ? AND v1 = ?
, the results are dictionary ordered byv2, k2
. Up toprefixSize
,2
in this case, the ordering is trivial: all records have the same value.primaryKeyStart
is the earlier position for part of the primary key; in this case,0
.primaryKeyTail
is the position after which only primary key fields appear; in this case,3
.
-
-
Constructor Summary
Constructors Constructor Description PlanOrderingKey(List<KeyExpression> keys, int prefixSize, int primaryKeyStart, int primaryKeyTail)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PlanOrderingKey
forPlan(RecordMetaData metaData, RecordQueryPlan queryPlan, KeyExpression primaryKey)
List<KeyExpression>
getKeys()
int
getPrefixSize()
int
getPrimaryKeyStart()
int
getPrimaryKeyTail()
boolean
isPrimaryKeyOrdered()
Returntrue
if only primary key fields follow the prefix.static KeyExpression
mergedComparisonKey(List<RecordQueryPlanner.ScoredPlan> plans, KeyExpression candidateKey, boolean candidateOnly)
Get a key to be evaluated on record results to drive a merge.
-
-
-
Constructor Detail
-
PlanOrderingKey
public PlanOrderingKey(@Nonnull List<KeyExpression> keys, int prefixSize, int primaryKeyStart, int primaryKeyTail)
-
-
Method Detail
-
getKeys
@Nonnull public List<KeyExpression> getKeys()
-
getPrefixSize
public int getPrefixSize()
-
getPrimaryKeyStart
public int getPrimaryKeyStart()
-
getPrimaryKeyTail
public int getPrimaryKeyTail()
-
isPrimaryKeyOrdered
public boolean isPrimaryKeyOrdered()
Returntrue
if only primary key fields follow the prefix. If so, all the (non-trivial) ordering of results is by primary key.- Returns:
true
if this ordering key is ordered by primary key
-
forPlan
@Nullable public static PlanOrderingKey forPlan(@Nonnull RecordMetaData metaData, @Nonnull RecordQueryPlan queryPlan, @Nullable KeyExpression primaryKey)
-
mergedComparisonKey
@Nullable public static KeyExpression mergedComparisonKey(@Nonnull List<RecordQueryPlanner.ScoredPlan> plans, @Nullable KeyExpression candidateKey, boolean candidateOnly)
Get a key to be evaluated on record results to drive a merge. This key must respect the underlying ordering so that only a single record needs to be buffered from each cursor. And it must uniquely identify duplicates by including the primary key.- Parameters:
plans
- the plans for which to find a compatible orderingcandidateKey
- a suggested key to usecandidateOnly
- only accept the given candidate- Returns:
- a comparison key compatible with all the plans
-
-