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

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

 class ProjectRestrictResultSet
extends NoPutResultSetImpl
implements CursorResultSet

Takes a table and a table filter and returns the table's rows satisfying the filter as a result set.


Field Summary
private  boolean[] cloneMap
          Holds columns present more than once in the result set and which may be represented by a stream, since such columns need to be cloned.
 GeneratedMethod constantRestriction
           
 boolean doesProjection
           
private  ExecRow mappedResultRow
           
private  GeneratedMethod projection
           
 long projectionTime
           
private  int[] projectMapping
           
private  ExecRow projRow
           
 GeneratedMethod restriction
           
 long restrictionTime
           
 boolean reuseResult
           
private  boolean runTimeStatsOn
           
private  boolean shortCircuitOpen
           
(package private)  NoPutResultSet source
           
 
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
ProjectRestrictResultSet(NoPutResultSet s, Activation a, GeneratedMethod r, GeneratedMethod p, int resultSetNumber, GeneratedMethod cr, int mapRefItem, int cloneMapItem, boolean reuseResult, boolean doesProjection, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
           
 
Method Summary
 void close()
          If the result set has been opened, close the open scan.
 ExecRow doBaseRowProjection(ExecRow sourceRow)
          Do the projection against the sourceRow.
private  ExecRow doProjection(ExecRow sourceRow)
          Do the projection against the source row.
 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().
 int[] getBaseProjectMapping()
          Get projection mapping array.
 ExecRow getCurrentRow()
          Gets last row returned.
 ExecRow getNextRowCore()
          Return the requested values computed from the next row (if any) for which the restriction evaluates to true.
 RowLocation getRowLocation()
          Gets information from its source.
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
 boolean isForUpdate()
          Is this ResultSet or it's source result set for update
 void markRowAsDeleted()
          Marks the resultSet's currentRow as deleted after a delete has been issued by either by using positioned delete or JDBC's deleteRow 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...
 void updateRow(ExecRow row, RowChanger rowChanger)
          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.
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, needsRowLocation, needsToClone, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan
 
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, clearCurrentRow, getAbsoluteRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getFirstRow, getLastRow, getNextRow, getPreviousRow, getRelativeRow, getResultDescription, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

restrictionTime

public long restrictionTime

projectionTime

public long projectionTime

source

final NoPutResultSet source

constantRestriction

public GeneratedMethod constantRestriction

restriction

public GeneratedMethod restriction

doesProjection

public boolean doesProjection

projection

private GeneratedMethod projection

projectMapping

private int[] projectMapping

cloneMap

private boolean[] cloneMap
Holds columns present more than once in the result set and which may be represented by a stream, since such columns need to be cloned.


runTimeStatsOn

private boolean runTimeStatsOn

mappedResultRow

private ExecRow mappedResultRow

reuseResult

public boolean reuseResult

shortCircuitOpen

private boolean shortCircuitOpen

projRow

private ExecRow projRow
Constructor Detail

ProjectRestrictResultSet

ProjectRestrictResultSet(NoPutResultSet s,
                         Activation a,
                         GeneratedMethod r,
                         GeneratedMethod p,
                         int resultSetNumber,
                         GeneratedMethod cr,
                         int mapRefItem,
                         int cloneMapItem,
                         boolean reuseResult,
                         boolean doesProjection,
                         double optimizerEstimatedRowCount,
                         double optimizerEstimatedCost)
                   throws StandardException
Throws:
StandardException
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) 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()

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
If the result set has been opened, close the open scan.

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

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

getRowLocation

public RowLocation getRowLocation()
                           throws StandardException
Gets information from its source. We might want to have this take a CursorResultSet in its constructor some day, instead of doing a cast here?

Specified by:
getRowLocation in interface CursorResultSet
Returns:
the row location of the current cursor row.
Throws:
StandardException - thrown on failure.
See Also:
CursorResultSet

getCurrentRow

public ExecRow getCurrentRow()
                      throws StandardException
Gets last row returned.

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

doProjection

private ExecRow doProjection(ExecRow sourceRow)
                      throws StandardException
Do the projection against the source row. Use reflection where necessary, otherwise get the source column into our result row.

Parameters:
sourceRow - The source row.
Returns:
The result of the projection
Throws:
StandardException - thrown on failure.

doBaseRowProjection

public ExecRow doBaseRowProjection(ExecRow sourceRow)
                            throws StandardException
Do the projection against the sourceRow. If the source of the result set is of type ProjectRestrictResultSet, the projection by that result set will also be performed.

Parameters:
sourceRow - row to be projected
Returns:
The result of the projection
Throws:
StandardException - thrown on failure.

getBaseProjectMapping

public int[] getBaseProjectMapping()
Get projection mapping array. The array consist of indexes which maps the column in a row array to another position in the row array. If the value is projected out of the row, the value is negative.

Returns:
projection mapping array.

isForUpdate

public boolean isForUpdate()
Is this ResultSet or it's source result set for update

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

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.

Specified by:
updateRow in interface NoPutResultSet
Overrides:
updateRow in class NoPutResultSetImpl
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:
NoPutResultSet.updateRow(org.apache.derby.iapi.sql.execute.ExecRow, org.apache.derby.iapi.sql.execute.RowChanger)

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.

Specified by:
markRowAsDeleted in interface NoPutResultSet
Overrides:
markRowAsDeleted in class NoPutResultSetImpl
Throws:
StandardException - thrown on failure.
See Also:
NoPutResultSet.markRowAsDeleted()

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

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