Class PlanOrderingKey


  • @API(INTERNAL)
    public class PlanOrderingKey
    extends Object
    The keys that order the results from a plan. Given a record type with primary key 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 Detail

      • PlanOrderingKey

        public PlanOrderingKey​(@Nonnull
                               List<KeyExpression> keys,
                               int prefixSize,
                               int primaryKeyStart,
                               int primaryKeyTail)
    • Method Detail

      • getPrefixSize

        public int getPrefixSize()
      • getPrimaryKeyStart

        public int getPrimaryKeyStart()
      • getPrimaryKeyTail

        public int getPrimaryKeyTail()
      • isPrimaryKeyOrdered

        public boolean isPrimaryKeyOrdered()
        Return true 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
      • 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 ordering
        candidateKey - a suggested key to use
        candidateOnly - only accept the given candidate
        Returns:
        a comparison key compatible with all the plans