org.apache.derby.impl.sql.execute
Class RowCountResultSet

java.lang.Object
  extended by org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
      extended by org.apache.derby.impl.sql.execute.NoPutResultSetImpl
          extended by org.apache.derby.impl.sql.execute.RowCountResultSet
All Implemented Interfaces:
CursorResultSet, NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource

 class RowCountResultSet
extends NoPutResultSetImpl
implements CursorResultSet

This result set implements the filtering of rows needed for the and the . It sits on top of the normal SELECT's top result set, but under any ScrollInsensitiveResultSet needed for cursors. The latter positioning is needed for the correct functioning of and in the presence of scrollable and/or updatable result sets and CURRENT OF cursors. It is only ever generated if at least one of the two clauses is present.


Field Summary
private  long fetchFirst
           
private  GeneratedMethod fetchFirstMethod
           
private  long offset
           
private  GeneratedMethod offsetMethod
           
private  long rowsFetched
          Holds the number of rows returned so far in this round of using the result set.
private  boolean runTimeStatsOn
           
(package private)  NoPutResultSet source
           
private  boolean virginal
          True if we haven't yet fetched any rows from this result set.
 
Fields inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
checkNullCols, clonedExecRow, cncLen, resultSetNumber, targetResultSet
 
Fields inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
activation, beginTime, closeTime, compactRow, constructorTime, currentRow, endExecutionTime, finished, isOpen, isTopResultSet, nextTime, numOpens, openTime, optimizerEstimatedCost, optimizerEstimatedRowCount, resultDescription, rowsFiltered, rowsSeen, startExecutionTime, subqueryTrackingArray
 
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Fields inherited from interface org.apache.derby.iapi.sql.execute.NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE
 
Constructor Summary
RowCountResultSet(NoPutResultSet s, Activation a, int resultSetNumber, GeneratedMethod offsetMethod, GeneratedMethod fetchFirstMethod, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
          RowCountResultSet constructor
 
Method Summary
 void clearCurrentRow()
          Clear the current row
 void close()
          Close needs to invalidate any dependent statements, if this is a cursor.
 void finish()
          Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open().
 ExecRow getCurrentRow()
          Gets information from source
 ExecRow getNextRowCore()
          Return the requested values computed from the next row (if any)
 RowLocation getRowLocation()
          Gets information from its source.
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
 ProjectRestrictResultSet getUnderlyingProjectRestrictRS()
          Return underlying result set (the source og this result set) if it is a ProjectRestrictResultSet, else null.
 boolean isForUpdate()
          Override of NoPutResultSetImpl method.
 void openCore()
          Open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...
 void reopenCore()
          Reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, markRowAsDeleted, needsRowLocation, needsToClone, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan, updateRow
 
Methods inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
addWarning, attachStatementContext, checkCancellationFlag, checkRowPosition, cleanUp, dumpTimeStats, finishAndRTS, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCompactRow, getCurrentTimeMillis, getElapsedMillis, getEndExecutionTimestamp, getEstimatedRowCount, getExecuteTime, getExecutionFactory, getFirstRow, getLanguageConnectionContext, getLastRow, getNextRow, getPointOfAttachment, getPreviousRow, getRelativeRow, getRowNumber, getScanIsolationLevel, getSubqueryTrackingArray, getTransactionController, getWarnings, isClosed, markAsTopResultSet, modifiedRowCount, open, recordConstructorTime, requiresRelocking, returnsRows, setAfterLastRow, setBeforeFirstRow, setCompactRow, setCompatRow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.sql.ResultSet
checkRowPosition, cleanUp, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

source

final NoPutResultSet source

runTimeStatsOn

private final boolean runTimeStatsOn

offset

private long offset

fetchFirst

private long fetchFirst

offsetMethod

private final GeneratedMethod offsetMethod

fetchFirstMethod

private final GeneratedMethod fetchFirstMethod

virginal

private boolean virginal
True if we haven't yet fetched any rows from this result set. Will be reset on close so the result set is ready to reuse.


rowsFetched

private long rowsFetched
Holds the number of rows returned so far in this round of using the result set. Will be reset on close so the result set is ready to reuse.

Constructor Detail

RowCountResultSet

RowCountResultSet(NoPutResultSet s,
                  Activation a,
                  int resultSetNumber,
                  GeneratedMethod offsetMethod,
                  GeneratedMethod fetchFirstMethod,
                  double optimizerEstimatedRowCount,
                  double optimizerEstimatedCost)
            throws StandardException
RowCountResultSet constructor

Parameters:
s - The source result set being filtered
a - The activation for this result set, which provides the context for the row allocation operation
resultSetNumber - The resultSetNumber for the ResultSet
offsetMethod - Generated method
fetchFirstMethod - Generated method
optimizerEstimatedRowCount - Estimated total # of rows by optimizer
optimizerEstimatedCost - Estimated total cost by optimizer
Throws:
StandardException - Standard error policy
Method Detail

openCore

public void openCore()
              throws StandardException
Open a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...

Specified by:
openCore in interface NoPutResultSet
Throws:
StandardException - thrown if cursor finished.

reopenCore

public void reopenCore()
                throws StandardException
Reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values...

Specified by:
reopenCore in interface NoPutResultSet
Overrides:
reopenCore in class BasicNoPutResultSetImpl
Throws:
StandardException - thrown if cursor finished.
See Also:
NoPutResultSet.openCore()

getNextRowCore

public ExecRow getNextRowCore()
                       throws StandardException
Return the requested values computed from the next row (if any)

Specified by:
getNextRowCore in interface NoPutResultSet
Specified by:
getNextRowCore in class BasicNoPutResultSetImpl
Returns:
the next row in the result
Throws:
StandardException - thrown on failure.
StandardException - ResultSetNotOpen thrown if not yet open.
See Also:
NoPutResultSet.getNextRowCore()

getTimeSpent

public long getTimeSpent(int type)
Return the total amount of time spent in this ResultSet

Specified by:
getTimeSpent in interface ResultSet
Parameters:
type - CURRENT_RESULTSET_ONLY - time spent only in this ResultSet ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.
Returns:
long The total amount of time spent (in milliseconds).

close

public void close()
           throws StandardException
Description copied from class: NoPutResultSetImpl
Close needs to invalidate any dependent statements, if this is a cursor. Must be called by any subclasses that override close().

Specified by:
close in interface ResultSet
Overrides:
close in class NoPutResultSetImpl
Throws:
StandardException - on error
See Also:
ResultSet.close()

finish

public void finish()
            throws StandardException
Description copied from interface: ResultSet
Tells the system that there will be no more access to any database information via this result set; in particular, no more calls to open(). Will close the result set if it is not already closed.

Specified by:
finish in interface ResultSet
Overrides:
finish in class BasicNoPutResultSetImpl
Throws:
StandardException - on error
See Also:
ResultSet.finish()

clearCurrentRow

public final void clearCurrentRow()
Description copied from class: NoPutResultSetImpl
Clear the current row

Specified by:
clearCurrentRow in interface ResultSet
Overrides:
clearCurrentRow in class NoPutResultSetImpl
See Also:
ResultSet.clearCurrentRow()

getRowLocation

public RowLocation getRowLocation()
                           throws StandardException
Gets information from its source.

Specified by:
getRowLocation in interface CursorResultSet
Returns:
the row location of the current cursor row.
Throws:
StandardException - thrown on failure to get location from storage engine
See Also:
CursorResultSet.getRowLocation()

getCurrentRow

public ExecRow getCurrentRow()
                      throws StandardException
Gets information from source

Specified by:
getCurrentRow in interface CursorResultSet
Returns:
the last row returned.
Throws:
StandardException - thrown on failure.
See Also:
CursorResultSet.getCurrentRow()

isForUpdate

public boolean isForUpdate()
Override of NoPutResultSetImpl method. Ask the source.

Specified by:
isForUpdate in interface NoPutResultSet
Overrides:
isForUpdate in class NoPutResultSetImpl
Returns:
Whether or not the result set is for update.

getUnderlyingProjectRestrictRS

public ProjectRestrictResultSet getUnderlyingProjectRestrictRS()
Return underlying result set (the source og this result set) if it is a ProjectRestrictResultSet, else null.


Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.