@API(value=INTERNAL) public class PlanOrderingKey extends Object
k1, k2
and an index on k1, v1, v2
,
the index entries are k1, v1, v2, k2
.
Given a scan on this index for k1 = ? AND v1 = ?
, the results are dictionary ordered by v2, k2
.
Up to prefixSize
, 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 and Description |
---|
PlanOrderingKey(List<KeyExpression> keys,
int prefixSize,
int primaryKeyStart,
int primaryKeyTail) |
Modifier and Type | Method and Description |
---|---|
static PlanOrderingKey |
forPlan(RecordMetaData metaData,
RecordQueryPlan queryPlan,
KeyExpression primaryKey) |
List<KeyExpression> |
getKeys() |
int |
getPrefixSize() |
int |
getPrimaryKeyStart() |
int |
getPrimaryKeyTail() |
boolean |
isPrimaryKeyOrdered()
Return
true 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.
|
public PlanOrderingKey(@Nonnull List<KeyExpression> keys, int prefixSize, int primaryKeyStart, int primaryKeyTail)
@Nonnull public List<KeyExpression> getKeys()
public int getPrefixSize()
public int getPrimaryKeyStart()
public int getPrimaryKeyTail()
public boolean isPrimaryKeyOrdered()
true
if only primary key fields follow the prefix.
If so, all the (non-trivial) ordering of results is by primary key.true
if this ordering key is ordered by primary key@Nullable public static PlanOrderingKey forPlan(@Nonnull RecordMetaData metaData, @Nonnull RecordQueryPlan queryPlan, @Nullable KeyExpression primaryKey)
@Nullable public static KeyExpression mergedComparisonKey(@Nonnull List<RecordQueryPlanner.ScoredPlan> plans, @Nullable KeyExpression candidateKey, boolean candidateOnly)
plans
- the plans for which to find a compatible orderingcandidateKey
- a suggested key to usecandidateOnly
- only accept the given candidate