Class NoPutResultSetImpl

java.lang.Object
org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
org.apache.derby.impl.sql.execute.NoPutResultSetImpl
All Implemented Interfaces:
NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource
Direct Known Subclasses:
AnyResultSet, CurrentOfResultSet, GenericAggregateResultSet, HashTableResultSet, IndexRowToBaseRowResultSet, JoinResultSet, MaterializedResultSet, NormalizeResultSet, OnceResultSet, ProjectRestrictResultSet, RowCountResultSet, RowResultSet, ScanResultSet, ScrollInsensitiveResultSet, SetOpResultSet, SortResultSet, UnionResultSet, VTIResultSet, WindowResultSet

abstract class NoPutResultSetImpl extends BasicNoPutResultSetImpl
Abstract ResultSet with built in Activation support for operations that return rows but do not allow the caller to put data on output pipes. This implementation of ResultSet is meant to be overridden by subtypes in the execution engine. Its primary users will be DML operations that do not put data on output pipes, but simply return it due to being result sets themselves.

This abstract class does not define the entire ResultSet interface, but leaves the 'get' half of the interface for subtypes to implement. It is package-visible only, with its methods being public for exposure by its subtypes.

  • Field Details

    • resultSetNumber

      public final int resultSetNumber
    • needsRowLocation

      private boolean needsRowLocation
    • needsRowLocationForDeferredCheckConstraints

      private boolean needsRowLocationForDeferredCheckConstraints
    • clonedExecRow

      protected ExecRow clonedExecRow
    • targetResultSet

      protected TargetResultSet targetResultSet
    • checkNullCols

      protected int[] checkNullCols
    • cncLen

      protected int cncLen
  • Constructor Details

    • NoPutResultSetImpl

      NoPutResultSetImpl(Activation activation, int resultSetNumber, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
      Constructor
      Parameters:
      activation - The activation
      resultSetNumber - The resultSetNumber
      optimizerEstimatedRowCount - The optimizer's estimated number of rows.
      optimizerEstimatedCost - The optimizer's estimated cost
  • Method Details

    • getResultDescription

      public ResultDescription getResultDescription()
      Returns the description of the table's rows
      Specified by:
      getResultDescription in interface ResultSet
      Overrides:
      getResultDescription in class BasicNoPutResultSetImpl
      Returns:
      A ResultDescription describing the results of the statement.
    • getCursorName

      public String getCursorName()
      Return my cursor name for JDBC. Can be null.
      Returns:
      A String with the name of the cursor, if any. Returns NULL if this is not a cursor statement.
    • resultSetNumber

      public int resultSetNumber()
      Description copied from interface: NoPutResultSet
      Get the number of this ResultSet, which is guaranteed to be unique within a statement.
      Specified by:
      resultSetNumber in interface NoPutResultSet
      Overrides:
      resultSetNumber in class BasicNoPutResultSetImpl
      See Also:
    • close

      public void close() throws StandardException
      Close needs to invalidate any dependent statements, if this is a cursor. Must be called by any subclasses that override close().
      Throws:
      StandardException - on error
    • setTargetResultSet

      public void setTargetResultSet(TargetResultSet trs)
      Description copied from interface: NoPutResultSet
      Notify a NPRS that it is the source for the specified TargetResultSet. This is useful when doing bulk insert.
      Parameters:
      trs - The TargetResultSet.
      See Also:
    • setNeedsRowLocation

      public void setNeedsRowLocation(boolean needsRowLocation)
      Description copied from interface: NoPutResultSet
      Set whether or not the NPRS need the row location when acting as a row source. (The target result set determines this.)
      See Also:
    • setHasDeferrableChecks

      public void setHasDeferrableChecks()
      Description copied from interface: NoPutResultSet
      Set that we are acting on behalf of an insert result set that has deferrable check constraints
    • getValidColumns

      public FormatableBitSet getValidColumns()
      Description copied from interface: RowSource
      getValidColumns describes the DataValueDescriptor[] returned by all calls to the getNextRowFromRowSource() call. If getValidColumns returns null, the number of columns is given by the DataValueDescriptor.length where DataValueDescriptor[] is returned by the preceeding getNextRowFromRowSource() call. Column N maps to DataValueDescriptor[N], where column numbers start at zero. If getValidColumns return a non null validColumns FormatableBitSet the number of columns is given by the number of bits set in validColumns. Column N is not in the partial row if validColumns.get(N) returns false. Column N is in the partial row if validColumns.get(N) returns true. If column N is in the partial row then it maps to DataValueDescriptor[M] where M is the count of calls to validColumns.get(i) that return true where i < N. If DataValueDescriptor.length is greater than the number of columns indicated by validColumns the extra entries are ignored.
      See Also:
    • getNextRowFromRowSource

      public DataValueDescriptor[] getNextRowFromRowSource() throws StandardException
      Description copied from interface: RowSource
      Get the next row as an array of column objects. The column objects can be a JBMS Storable or any Serializable/Externalizable/Formattable/Streaming type.
      A return of null indicates that the complete set of rows has been read.

      A null column can be specified by leaving the object null, or indicated by returning a non-null getValidColumns. On streaming columns, it can be indicated by returning a non-null get FieldStates.

      If RowSource.needToClone() is true then the returned row (the DataValueDescriptor[]) is guaranteed not to be modified by drainer of the RowSource (except that the input stream will be read, of course) and drainer will keep no reference to it before making the subsequent nextRow call. So it is safe to return the same DataValueDescriptor[] in subsequent nextRow calls if that is desirable for performance reasons.

      If RowSource.needToClone() is false then the returned row (the DataValueDescriptor[]) may be be modified by drainer of the RowSource, and the drainer may keep a reference to it after making the subsequent nextRow call. In this case the client should severe all references to the row after returning it from getNextRowFromRowSource().

      Throws:
      StandardException - on error
      See Also:
    • needsToClone

      public boolean needsToClone()
      Description copied from interface: RowSource
      Does the caller of getNextRowFromRowSource() need to clone the row in order to keep a reference to the row past the getNextRowFromRowSource() call which returned the row. This call must always return the same for all rows in a RowSource (ie. the caller will call this once per scan from a RowSource and assume the behavior is true for all rows in the RowSource).
      See Also:
    • closeRowSource

      public void closeRowSource()
      Description copied from interface: RowSource
      closeRowSource tells the RowSource that it will no longer need to return any rows and it can release any resource it may have. Subsequent call to any method on the RowSource will result in undefined behavior. A closed rowSource can be closed again.
      See Also:
    • needsRowLocation

      public boolean needsRowLocation()
      Description copied from interface: RowLocationRetRowSource
      needsRowLocation returns true iff this the row source expects the drainer of the row source to call rowLocation after getting a row from getNextRowFromRowSource.
      Returns:
      true iff this row source expects some row location to be returned
      See Also:
    • needsRowLocationForDeferredCheckConstraints

      public boolean needsRowLocationForDeferredCheckConstraints()
    • rowLocation

      public void rowLocation(RowLocation rl) throws StandardException
      Description copied from interface: RowLocationRetRowSource
      rowLocation is a callback for the drainer of the row source to return the rowLocation of the current row, i.e, the row that is being returned by getNextRowFromRowSource. This interface is for the purpose of loading a base table with index. In that case, the indices can be built at the same time the base table is laid down once the row location of the base row is known. This is an example pseudo code on how this call is expected to be used:
                      boolean needsRL = rowSource.needsRowLocation();
                      DataValueDescriptor[] row;
                      while((row = rowSource.getNextRowFromRowSource()) != null)
                      {
                              RowLocation rl = heapConglomerate.insertRow(row);
                              if (needsRL)
                                      rowSource.rowLocation(rl);
                      }
                      

      NeedsRowLocation and rowLocation will ONLY be called by a drainer of the row source which CAN return a row location. Drainer of row source which cannot return rowLocation will guarantee to not call either callbacks. Conversely, if NeedsRowLocation is called and it returns true, then for every row return by getNextRowFromRowSource, a rowLocation callback must also be issued with the row location of the row. Implementor of both the source and the drain of the row source must be aware of this protocol.
      The RowLocation object is own by the caller of rowLocation, in other words, the drainer of the RowSource. This is so that we don't need to new a row location for every row. If the Row Source wants to keep the row location, it needs to clone it (RowLocation is a ClonableObject).
      Throws:
      StandardException - on error
      See Also:
    • offendingRowLocation

      public void offendingRowLocation(RowLocation rl, long containdId) throws StandardException
      Throws:
      StandardException
    • clearOrderableCache

      protected void clearOrderableCache(Qualifier[][] qualifiers) throws StandardException
      Clear the Orderable cache for each qualifier. (This should be done each time a scan/conglomerate with qualifiers is reopened.)
      Parameters:
      qualifiers - The Qualifiers to clear
      Throws:
      StandardException
    • setCurrentRow

      public final void setCurrentRow(ExecRow row)
      Set the current row to the row passed in.
      Parameters:
      row - the new current row
    • clearCurrentRow

      public void clearCurrentRow()
      Clear the current row
    • isForUpdate

      public boolean isForUpdate()
      Is this ResultSet or it's source result set for update This method will be overriden in the inherited Classes if it is true
      Specified by:
      isForUpdate in interface NoPutResultSet
      Overrides:
      isForUpdate in class BasicNoPutResultSetImpl
      Returns:
      Whether or not the result set is for update.
    • skipScan

      protected boolean skipScan(ExecIndexRow startPosition, ExecIndexRow stopPosition) throws StandardException
      Return true if we should skip the scan due to nulls in the start or stop position when the predicate on the column(s) in question do not implement ordered null semantics. beetle 4464, we also compact the areNullsOrdered flags into checkNullCols here.
      Parameters:
      startPosition - An index row for the start position
      stopPosition - An index row for the stop position
      Returns:
      true means not to do the scan
      Throws:
      StandardException
    • skipRow

      protected boolean skipRow(ExecRow row) throws StandardException
      Return true if we should skip the scan due to nulls in the row when the start or stop positioners on the columns containing null do not implement ordered null semantics.
      Parameters:
      row - An index row
      Returns:
      true means skip the row because it has null
      Throws:
      StandardException
    • printQualifiers

      public static String printQualifiers(Qualifier[][] qualifiers)
      Return a 2-d array of Qualifiers as a String
    • updateRow

      public void updateRow(ExecRow row, RowChanger rowChanger) throws StandardException
      Description copied from interface: NoPutResultSet
      Updates the resultSet's current row with it's new values after an update has been issued either using positioned update or JDBC's udpateRow method.
      Parameters:
      row - new values for the currentRow
      rowChanger - holds information about row: what columns of it is to be used for updating, and what underlying base table column each such column corresponds to.
      Throws:
      StandardException - thrown on failure.
      See Also:
    • markRowAsDeleted

      public void markRowAsDeleted() throws StandardException
      Description copied from interface: NoPutResultSet
      Marks the resultSet's currentRow as deleted after a delete has been issued by either by using positioned delete or JDBC's deleteRow method.
      Throws:
      StandardException - thrown on failure.
      See Also:
    • positionScanAtRowLocation

      public void positionScanAtRowLocation(RowLocation rl) throws StandardException
      Description copied from interface: NoPutResultSet
      Positions the cursor in the specified rowLocation. Used for scrollable insensitive result sets in order to position the cursor back to a row that has already be visited.
      Parameters:
      rl - row location of the current cursor row
      Throws:
      StandardException - thrown on failure to get location from storage engine
      See Also:
    • unpackHashValue

      protected DataValueDescriptor[] unpackHashValue(Object hashValue)
      Get all of the columns out of a value stored in a BackingStoreHashtable.