Interface QueryPlan<T>

    • Method Detail

      • execute

        @Nonnull
        default RecordCursor<T> execute​(@Nonnull
                                        FDBRecordStore store)
        Execute this query plan.
        Parameters:
        store - record store from which to fetch items
        Returns:
        a cursor of items that match the query criteria
      • isReverse

        boolean isReverse()
        Indicates whether this plan will return values in "reverse" order from the natural order of results of this plan. The return value is true if the plan returns elements in descending order and false if the elements are returned in ascending order.
        Returns:
        true if this plan returns elements in reverse order
      • hasRecordScan

        boolean hasRecordScan()
        Indicates whether this plan (or one of its components) scans at least a subset of the record range directly rather than going through a secondary index. A plan may only scan over a subset of all records. Someone might not use any secondary indexes explicitly, but they might make use of the primary key index. For example, if they had a compound primary key, and they issued a query for all records that had some value for the first element of their primary key, the planner will produce a plan which scans over a subset of all records.
        Returns:
        true if this plan (or one of its components) scans at least a subset of the records directly
      • hasFullRecordScan

        boolean hasFullRecordScan()
        Indicates whether this plan (or one of its components) must perform a scan over all records in the store directly rather than going through a secondary index. See hasRecordScan for the comparison between two methods.
        Returns:
        true if this plan (or one of its components) must perform a scan over all records in the store directly
      • hasIndexScan

        boolean hasIndexScan​(@Nonnull
                             String indexName)
        Indicates whether this plan scans the given index.
        Parameters:
        indexName - the name of the index to check for
        Returns:
        true if this plan (or one of its children) scans the given index
      • getUsedIndexes

        @Nonnull
        Set<String> getUsedIndexes()
        Returns a set of names of the indexes used by this plan (and its sub-plans).
        Returns:
        an set of indexes used by this plan
      • hasLoadBykeys

        boolean hasLoadBykeys()
        Indicates whether this plan (or one of its components) loads records by their primary key.
        Returns:
        true if this plan (or one of its components) loads records by their primary key
      • maxCardinality

        default int maxCardinality​(@Nonnull
                                   RecordMetaData metaData)
        Indicates how many records this plan could possibly return.
        Parameters:
        metaData - meta-data to use to determine things like index uniqueness
        Returns:
        the maximum number of records or UNKNOWN_MAX_CARDINALITY if not known
      • isStrictlySorted

        default boolean isStrictlySorted()
        Indicates whether the ordering of records from this plan is fully accounted for by its requested sort. That is, each new record will have a different value for that sort key.
        Returns:
        true if this plan is fully sorted according to the query definition
      • strictlySorted

        default QueryPlan<T> strictlySorted()
        Return a copy of this plan that has the isStrictlySorted() property.
        Returns:
        a copy of this plan
      • logPlanStructure

        void logPlanStructure​(StoreTimer timer)
        Adds one to an appropriate StoreTimer counter for each plan and subplan of this plan, allowing tracking of which plans are being chosen (e.g. index scan vs. full scan).
        Parameters:
        timer - the counters to increment
      • getComplexity

        int getComplexity()
        Returns an integer representing the "complexity" of the generated plan. Currently, this should simply be the number of plans in the plan tree with this plan as the root (i.e. the number of descendants of this plan, including itself).
        Returns:
        the complexity of this plan
      • getQueryPlanChildren

        List<? extends QueryPlan<?>> getQueryPlanChildren()
        Returns the (zero or more) child QueryPlans of this plan. These children may or may not return elements of the same type as their parent plan.

        Warning: This part of the API is currently undergoing active development. At some point in the future, this will be renamed getChildren(). This cannot be done at current, however, as it would require an incompatible change to RecordQueryPlan.getChildren(). That method has been marked API.Status.UNSTABLE as of version 2.5.

        Returns:
        the child plans of this plan