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

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

 class SetOpResultSet
extends NoPutResultSetImpl
implements CursorResultSet

Takes the result set produced by an ordered UNION ALL of two tagged result sets and produces the INTERSECT or EXCEPT of the two input result sets. This also projects out the tag, the last column of the input rows.


Field Summary
private  Activation activation
           
private  boolean all
           
private  int[] intermediateOrderByColumns
           
private  int[] intermediateOrderByDirection
           
private  boolean[] intermediateOrderByNullsLow
           
private  ExecRow leftInputRow
           
private  NoPutResultSet leftSource
           
private  int opType
           
private  DataValueDescriptor[] prevCols
           
private  int resultSetNumber
           
private  int rightDuplicateCount
           
private  ExecRow rightInputRow
           
private  NoPutResultSet rightSource
           
private  int rowsReturned
           
private  int rowsSeenLeft
           
private  int rowsSeenRight
           
 
Fields inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
checkNullCols, clonedExecRow, cncLen, targetResultSet
 
Fields inherited from class org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
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
SetOpResultSet(NoPutResultSet leftSource, NoPutResultSet rightSource, Activation activation, int resultSetNumber, long optimizerEstimatedRowCount, double optimizerEstimatedCost, int opType, boolean all, int intermediateOrderByColumnsSavedObject, int intermediateOrderByDirectionSavedObject, int intermediateOrderByNullsLowSavedObject)
           
 
Method Summary
private  void advanceRightPastDuplicates(DataValueDescriptor[] leftColumns)
           
 void close()
          If the result set has been opened, close the currently open source.
private  int compare(DataValueDescriptor[] leftCols, DataValueDescriptor[] rightCols)
           
 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()
          Returns the current row of the result set.
 NoPutResultSet getLeftSourceInput()
          Return the left source input of this SetOpResultSet
 ExecRow getNextRowCore()
          Return the requested values computed from the next row (if any) for which the restriction evaluates to true.
 int getOpType()
          Return the set operation of this SetOpResultSet
 int getResultSetNumber()
          Return the result set number
 NoPutResultSet getRightSourceInput()
          Return the right source input of this SetOpResultSet
 RowLocation getRowLocation()
          Returns the row location of the current base table row of the cursor.
 int getRowsReturned()
          Return the number of rows returned from the result set
 int getRowsSeenLeft()
          Return the number of rows seen on the left source input
 int getRowsSeenRight()
          Return the number of rows seen on the right source input
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
private  boolean isDuplicate(DataValueDescriptor[] curColumns)
           
 void openCore()
          open the first source.
 
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, 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, reopenCore, 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

leftSource

private final NoPutResultSet leftSource

rightSource

private final NoPutResultSet rightSource

activation

private final Activation activation

opType

private final int opType

all

private final boolean all

resultSetNumber

private final int resultSetNumber

prevCols

private DataValueDescriptor[] prevCols

rightDuplicateCount

private int rightDuplicateCount

leftInputRow

private ExecRow leftInputRow

rightInputRow

private ExecRow rightInputRow

intermediateOrderByColumns

private final int[] intermediateOrderByColumns

intermediateOrderByDirection

private final int[] intermediateOrderByDirection

intermediateOrderByNullsLow

private final boolean[] intermediateOrderByNullsLow

rowsSeenLeft

private int rowsSeenLeft

rowsSeenRight

private int rowsSeenRight

rowsReturned

private int rowsReturned
Constructor Detail

SetOpResultSet

SetOpResultSet(NoPutResultSet leftSource,
               NoPutResultSet rightSource,
               Activation activation,
               int resultSetNumber,
               long optimizerEstimatedRowCount,
               double optimizerEstimatedCost,
               int opType,
               boolean all,
               int intermediateOrderByColumnsSavedObject,
               int intermediateOrderByDirectionSavedObject,
               int intermediateOrderByNullsLowSavedObject)
Method Detail

openCore

public void openCore()
              throws StandardException
open the first source.

Specified by:
openCore in interface NoPutResultSet
Throws:
StandardException - thrown on failure

getNextRowCore

public ExecRow getNextRowCore()
                       throws StandardException
Description copied from interface: NoPutResultSet
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 of the intersect or except, null if there is none
Throws:
StandardException - thrown on failure
See Also:
NoPutResultSet.getNextRowCore()

advanceRightPastDuplicates

private void advanceRightPastDuplicates(DataValueDescriptor[] leftColumns)
                                 throws StandardException
Throws:
StandardException

compare

private int compare(DataValueDescriptor[] leftCols,
                    DataValueDescriptor[] rightCols)
             throws StandardException
Throws:
StandardException

isDuplicate

private boolean isDuplicate(DataValueDescriptor[] curColumns)
                     throws StandardException
Throws:
StandardException

getCurrentRow

public ExecRow getCurrentRow()
Description copied from interface: CursorResultSet
Returns the current row of the result set. REMIND: eventually, this will only return the current row for result sets that need to return it; either some field in the activation or a parameter in the constructor will be used to signal that this needs to function. This will let us limit the number of live objects we are holding on to.

Specified by:
getCurrentRow in interface CursorResultSet
Returns:
the last row returned by getNextRow. null if closed.

close

public void close()
           throws StandardException
If the result set has been opened, close the currently open source.

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

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

getRowLocation

public RowLocation getRowLocation()
                           throws StandardException
Description copied from interface: CursorResultSet
Returns the row location of the current base table row of the cursor. If this cursor's row is composed of multiple base tables' rows, i.e. due to a join, then a null is returned.

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

getOpType

public int getOpType()
Return the set operation of this SetOpResultSet

Returns:
the set operation of this ResultSet, the value is either IntersectOrExceptNode.INTERSECT_OP for Intersect operation or IntersectOrExceptNode.EXCEPT_OP for Except operation
See Also:
IntersectOrExceptNode

getResultSetNumber

public int getResultSetNumber()
Return the result set number

Returns:
the result set number

getLeftSourceInput

public NoPutResultSet getLeftSourceInput()
Return the left source input of this SetOpResultSet

Returns:
the left source input of this SetOpResultSet
See Also:
NoPutResultSet

getRightSourceInput

public NoPutResultSet getRightSourceInput()
Return the right source input of this SetOpResultSet

Returns:
the right source input of this SetOpResultSet
See Also:
NoPutResultSet

getRowsSeenLeft

public int getRowsSeenLeft()
Return the number of rows seen on the left source input

Returns:
the number of rows seen on the left source input

getRowsSeenRight

public int getRowsSeenRight()
Return the number of rows seen on the right source input

Returns:
the number of rows seen on the right source input

getRowsReturned

public int getRowsReturned()
Return the number of rows returned from the result set

Returns:
the number of rows returned from the result set

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.