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

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.WindowResultSet
All Implemented Interfaces:
NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource

 class WindowResultSet
extends NoPutResultSetImpl

WindowResultSet This ResultSet handles a window function ResultSet. The ResultSet is opened using openCore(). Each row is fetched and any restrictions evaluated for each row in a do-while loop in getNextRowCore(). The ResultSet is closed using closeCore().


Field Summary
private  ExecRow allocatedRow
           
private  FormatableBitSet referencedColumns
           
private  GeneratedMethod restriction
           
 long restrictionTime
          Cumulative time needed to evalute any restriction on this result set.
private  GeneratedMethod row
           
private  long rownumber
           
 NoPutResultSet source
          Source 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.execute.NoPutResultSet
ABSOLUTE, FIRST, LAST, NEXT, PREVIOUS, RELATIVE
 
Fields inherited from interface org.apache.derby.iapi.sql.ResultSet
CURRENT_RESULTSET_ONLY, ENTIRE_RESULTSET_TREE, ISAFTERLAST, ISBEFOREFIRST, ISFIRST, ISLAST
 
Constructor Summary
WindowResultSet(Activation activation, NoPutResultSet source, GeneratedMethod rowAllocator, int resultSetNumber, int erdNumber, GeneratedMethod restriction, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
          Constructor
 
Method Summary
 void close()
          If the result set has been opened, close the open scan, else throw.
private  ExecRow getAllocatedRow()
          Cache the ExecRow for this result set.
 ExecRow getNextRowCore()
          Return the requested values computed from the next row (if any) for which the restriction evaluates to true.
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
 void openCore()
          Open this ResultSet.
 void populateFromSourceRow(ExecRow srcrow, ExecRow destrow)
          Copy columns from srcrow into destrow, or insert ROW_NUMBER.
 void reopenCore()
          Reopen this ResultSet.
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, isForUpdate, 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, finish, 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
 

Field Detail

restriction

private GeneratedMethod restriction

row

private GeneratedMethod row

source

public NoPutResultSet source
Source result set,


restrictionTime

public long restrictionTime
Cumulative time needed to evalute any restriction on this result set.


referencedColumns

private FormatableBitSet referencedColumns

allocatedRow

private ExecRow allocatedRow

rownumber

private long rownumber
Constructor Detail

WindowResultSet

WindowResultSet(Activation activation,
                NoPutResultSet source,
                GeneratedMethod rowAllocator,
                int resultSetNumber,
                int erdNumber,
                GeneratedMethod restriction,
                double optimizerEstimatedRowCount,
                double optimizerEstimatedCost)
Constructor

Parameters:
activation - The activation
source - Source result set
rowAllocator -
resultSetNumber - The resultSetNumber
erdNumber - Int for ResultDescription (so it can be turned back into an object)
restriction - Restriction
optimizerEstimatedRowCount - The optimizer's estimated number of rows.
optimizerEstimatedCost - The optimizer's estimated cost
Method Detail

openCore

public void openCore()
              throws StandardException
Open this ResultSet.

Throws:
StandardException - thrown if cursor finished.

reopenCore

public void reopenCore()
                throws StandardException
Reopen this ResultSet.

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) for which the restriction evaluates to true.

Restriction and projection parameters are evaluated for each row.

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()

close

public void close()
           throws StandardException
If the result set has been opened, close the open scan, else throw.

Specified by:
close in interface ResultSet
Overrides:
close in class NoPutResultSetImpl
Throws:
StandardException - thrown on error

populateFromSourceRow

public void populateFromSourceRow(ExecRow srcrow,
                                  ExecRow destrow)
                           throws StandardException
Copy columns from srcrow into destrow, or insert ROW_NUMBER.

FIXME This is temporary. Window function treatment needs to generalized to work for other window functions.

Throws:
StandardException - thrown on failure to open

getTimeSpent

public long getTimeSpent(int type)
Return the total amount of time spent in this 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).

getAllocatedRow

private ExecRow getAllocatedRow()
                         throws StandardException
Cache the ExecRow for this result set.

Returns:
The cached ExecRow for this ResultSet
Throws:
StandardException - thrown on failure.

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.