Class IndexToBaseRowNode

  • All Implemented Interfaces:
    Optimizable, Visitable

    class IndexToBaseRowNode
    extends FromTable
    This node type translates an index row to a base row. It takes a FromBaseTable as its source ResultSetNode, and generates an IndexRowToBaseRowResultSet that takes a TableScanResultSet on an index conglomerate as its source.
    • Method Detail

      • getFinalCostEstimate

        CostEstimate getFinalCostEstimate()
        Description copied from class: FromTable
        Get the final CostEstimate for this FromTable.
        Overrides:
        getFinalCostEstimate in class FromTable
        Returns:
        The final CostEstimate for this FromTable, which is the costEstimate of trulyTheBestAccessPath if there is one. If there's no trulyTheBestAccessPath for this node, then we just return the value stored in costEstimate as a default.
      • isOrderedOn

        boolean isOrderedOn​(ColumnReference[] crs,
                            boolean permuteOrdering,
                            java.util.List<FromBaseTable> fbtHolder)
                     throws StandardException
        Return whether or not the underlying ResultSet tree is ordered on the specified columns. RESOLVE - This method currently only considers the outermost table of the query block.
        Overrides:
        isOrderedOn in class ResultSetNode
        Parameters:
        crs - The specified ColumnReference[]
        permuteOrdering - Whether or not the order of the CRs in the array can be permuted
        fbtHolder - List that is to be filled with the FromBaseTable
        Returns:
        Whether the underlying ResultSet tree is ordered on the specified column.
        Throws:
        StandardException - Thrown on error
      • generate

        void generate​(ActivationClassBuilder acb,
                      MethodBuilder mb)
               throws StandardException
        Generation of an IndexToBaseRowNode creates an IndexRowToBaseRowResultSet, which uses the RowLocation in the last column of an index row to get the row from the base conglomerate (heap).
        Overrides:
        generate in class QueryTreeNode
        Parameters:
        acb - The ActivationClassBuilder for the class being built
        mb - the method for the method to be built
        Throws:
        StandardException - Thrown on error
      • isOneRowResultSet

        boolean isOneRowResultSet()
                           throws StandardException
        Return whether or not the underlying ResultSet tree will return a single row, at most. This is important for join nodes where we can save the extra next on the right side if we know that it will return at most 1 row.
        Overrides:
        isOneRowResultSet in class ResultSetNode
        Returns:
        Whether or not the underlying ResultSet tree will return a single row.
        Throws:
        StandardException - Thrown on error
      • isNotExists

        boolean isNotExists()
        Return whether or not the underlying FBT is for NOT EXISTS.
        Overrides:
        isNotExists in class ResultSetNode
        Returns:
        Whether or not the underlying FBT is for NOT EXISTS.
      • decrementLevel

        void decrementLevel​(int decrement)
        Decrement (query block) level (0-based) for this FromTable. This is useful when flattening a subquery.
        Overrides:
        decrementLevel in class FromTable
        Parameters:
        decrement - The amount to decrement by.
      • updateTargetLockMode

        int updateTargetLockMode()
        Get the lock mode for the target of an update statement (a delete or update). The update mode will always be row for CurrentOfNodes. It will be table if there is no where clause.
        Overrides:
        updateTargetLockMode in class ResultSetNode
        Returns:
        The lock mode
        See Also:
        TransactionController
      • adjustForSortElimination

        void adjustForSortElimination()
        Description copied from class: ResultSetNode
        Notify the underlying result set tree that the optimizer has chosen to "eliminate" a sort. Sort elimination can happen as part of preprocessing (see esp. SelectNode.preprocess(...)) or it can happen if the optimizer chooses an access path that inherently returns the rows in the correct order (also known as a "sort avoidance" plan). In either case we drop the sort and rely on the underlying result set tree to return its rows in the correct order. For most types of ResultSetNodes we automatically get the rows in the correct order if the sort was eliminated. One exception to this rule, though, is the case of an IndexRowToBaseRowNode, for which we have to disable bulk fetching on the underlying base table. Otherwise the index scan could return rows out of order if the base table is updated while the scan is "in progress" (i.e. while the result set is open). In order to account for this (and potentially other, similar issues in the future) this method exists to notify the result set node that it is expected to return rows in the correct order. The result set can then take necessary action to satsify this requirement--such as disabling bulk fetch in the case of IndexRowToBaseRowNode. All of that said, any ResultSetNodes for which we could potentially eliminate sorts should override this method accordingly. So we don't ever expect to get here.
        Overrides:
        adjustForSortElimination in class ResultSetNode
        See Also:
        ResultSetNode.adjustForSortElimination()
      • getIndexColMapping

        private int[] getIndexColMapping()
        Fill in the column mapping for those columns coming from the index.
        Returns:
        The int[] with the mapping.