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

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

 class UnionResultSet
extends NoPutResultSetImpl
implements CursorResultSet

Takes two result sets and returns their union (all). (Any duplicate elimination is performed above this ResultSet.)


Field Summary
 int rowsReturned
           
 int rowsSeenLeft
           
 int rowsSeenRight
           
 NoPutResultSet source1
           
private  int source1FinalRowCount
           
 NoPutResultSet source2
           
private  int whichSource
           
 
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
UnionResultSet(NoPutResultSet source1, NoPutResultSet source2, Activation activation, int resultSetNumber, double optimizerEstimatedRowCount, double optimizerEstimatedCost)
           
 
Method Summary
 void close()
          If the result set has been opened, close the currently open source.
 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()
          A union has a single underlying row at a time, although from one of several sources.
 ExecRow getNextRowCore()
          If there are rows still on the first source, return the next one; otherwise, switch to the second source and return a row from there.
 ResultDescription getResultDescription()
          Returns the description of the first source.
 RowLocation getRowLocation()
          A union has a single underlying row at a time, although from one of several sources.
 long getTimeSpent(int type)
          Return the total amount of time spent in this ResultSet
 void openCore()
          open the first source.
 
Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, 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, getRowNumber, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows, setAfterLastRow, setBeforeFirstRow
 

Field Detail

rowsSeenLeft

public int rowsSeenLeft

rowsSeenRight

public int rowsSeenRight

rowsReturned

public int rowsReturned

whichSource

private int whichSource

source1FinalRowCount

private int source1FinalRowCount

source1

public NoPutResultSet source1

source2

public NoPutResultSet source2
Constructor Detail

UnionResultSet

public UnionResultSet(NoPutResultSet source1,
                      NoPutResultSet source2,
                      Activation activation,
                      int resultSetNumber,
                      double optimizerEstimatedRowCount,
                      double optimizerEstimatedCost)
Method Detail

getResultDescription

public ResultDescription getResultDescription()
Returns the description of the first source. Assumes the compiler ensured both sources had the same description.

Specified by:
getResultDescription in interface ResultSet
Overrides:
getResultDescription in class NoPutResultSetImpl
Returns:
A ResultDescription describing the results of the statement.

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
If there are rows still on the first source, return the next one; otherwise, switch to the second source and return a row from there.

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

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
A union has a single underlying row at a time, although from one of several sources.

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
A union has a single underlying row at a time, although from one of several sources.

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

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

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