org.apache.derby.impl.store.access.sort
Class MergeScan

java.lang.Object
  extended by org.apache.derby.impl.store.access.sort.Scan
      extended by org.apache.derby.impl.store.access.sort.SortScan
          extended by org.apache.derby.impl.store.access.sort.MergeScan
All Implemented Interfaces:
ScanManager, GenericScanController, GroupFetchScanController, RowCountable, ScanController, ScanInfo
Direct Known Subclasses:
MergeScanRowSource

public class MergeScan
extends SortScan

A sort scan that is capable of merging as many merge runs as will fit in the passed-in sort buffer.


Field Summary
protected  java.util.Vector mergeRuns
          The merge runs.
protected  StreamContainerHandle[] openScans
          Array of scan controllers for the merge runs.
protected  SortBuffer sortBuffer
          The sort buffer we will use.
private  SortObserver sortObserver
           
 
Fields inherited from class org.apache.derby.impl.store.access.sort.SortScan
current, hold, sort, tran
 
Fields inherited from interface org.apache.derby.iapi.store.access.ScanController
GE, GT, NA
 
Constructor Summary
MergeScan(MergeSort sort, TransactionManager tran, SortBuffer sortBuffer, java.util.Vector mergeRuns, SortObserver sortObserver, boolean hold)
           
 
Method Summary
 void close()
          Close the scan.
 boolean closeForEndTransaction(boolean closeHeldScan)
          Close the scan.
 boolean init(TransactionManager tran)
          Initialize the scan, returning false if there was some error.
(package private)  void mergeARow(int scanindex)
          Insert rows while we keep getting duplicates from the merge run whose scan is in the open scan array entry indexed by scanindex.
 boolean next()
          Move to the next position in the scan.
 
Methods inherited from class org.apache.derby.impl.store.access.sort.SortScan
fetch, fetchNext, fetchWithoutQualify
 
Methods inherited from class org.apache.derby.impl.store.access.sort.Scan
delete, didNotQualify, doesCurrentPositionQualify, fetchLocation, fetchNextGroup, fetchNextGroup, fetchSet, getAllScanInfo, getEstimatedRowCount, getScanInfo, isCurrentPositionDeleted, isHeldAfterCommit, isKeyed, isTableLocked, newRowLocationTemplate, positionAtRowLocation, reopenScan, reopenScanByRowLocation, replace, setEstimatedRowCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sortBuffer

protected SortBuffer sortBuffer
The sort buffer we will use.


mergeRuns

protected java.util.Vector mergeRuns
The merge runs.


openScans

protected StreamContainerHandle[] openScans
Array of scan controllers for the merge runs. Entries in the array become null as the last row is pulled out and the scan is closed.


sortObserver

private SortObserver sortObserver
Constructor Detail

MergeScan

MergeScan(MergeSort sort,
          TransactionManager tran,
          SortBuffer sortBuffer,
          java.util.Vector mergeRuns,
          SortObserver sortObserver,
          boolean hold)
Method Detail

next

public boolean next()
             throws StandardException
Move to the next position in the scan.

Returns:
True if there is a next position in the scan, false if there isn't.
Throws:
StandardException - Standard exception policy.
See Also:
ScanController.next()

close

public void close()
Close the scan.

Specified by:
close in interface GenericScanController
Overrides:
close in class SortScan
See Also:
GenericScanController.close()

closeForEndTransaction

public boolean closeForEndTransaction(boolean closeHeldScan)
Close the scan.

Parameters:
closeHeldScan - If true, means to close scan even if it has been opened to be kept opened across commit. This is used to close these scans on abort.
Returns:
boolean indicating that the close has resulted in a real close of the scan. A held scan will return false if called by closeForEndTransaction(false), otherwise it will return true. A non-held scan will always return true.
See Also:
ScanManager.closeForEndTransaction(boolean)

init

public boolean init(TransactionManager tran)
             throws StandardException
Initialize the scan, returning false if there was some error.

Throws:
StandardException

mergeARow

void mergeARow(int scanindex)
         throws StandardException
Insert rows while we keep getting duplicates from the merge run whose scan is in the open scan array entry indexed by scanindex.

Throws:
StandardException

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.