org.apache.derby.impl.store.access.btree
Class BTreeMaxScan
- java.lang.Object
-
- org.apache.derby.impl.store.access.btree.OpenBTree
-
- org.apache.derby.impl.store.access.btree.BTreeScan
-
- org.apache.derby.impl.store.access.btree.BTreeMaxScan
-
- All Implemented Interfaces:
- ScanManager, GenericScanController, GroupFetchScanController, RowCountable, ScanController
- Direct Known Subclasses:
- B2IMaxScan
public class BTreeMaxScan extends BTreeScan
A BTreeScan implementation that provides the 95% solution to the max on btree problem. If the row is the last row in the btree it works very efficiently. This implementation will be removed once backward scan is fully functional. The current implementation only exports to the user the ability to call fetchMax() and get back one row, none of the generic scan ablities are exported. To return the maximum row this implementation does the following: 1) calls positionAtStartPosition() which returns with the a latch on the rightmost leaf page and a lock on the rightmost leaf row on that page. It will loop until it can get the lock without waiting while holding the latch. At this point the slot position is just right of the locked row. 2) in fetchMax() it loops backward on the last leaf page, locking rows as it does so, until it finds the first non-deleted, non-NULL row. 3) If it is not successful in this last page search it attempts to latch the left sibling page, without waiting to avoid deadlocks with forward scans, and continue the search on that page. 4) If the sibling page couldn't be latched without waiting, save the current position, release all latches, and restart the scan from the saved position.
-
-
Field Summary
-
Fields inherited from interface org.apache.derby.iapi.store.access.ScanController
GE, GT, NA
-
-
Constructor Summary
Constructors Constructor and Description BTreeMaxScan()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanfetchMax(DataValueDescriptor[] fetch_row)Fetch the maximum row in the table.-
Methods inherited from class org.apache.derby.impl.store.access.btree.BTreeScan
close, closeForEndTransaction, delete, didNotQualify, doesCurrentPositionQualify, fetch, fetchLocation, fetchNext, fetchNextGroup, fetchNextGroup, fetchSet, fetchWithoutQualify, getCurrentRecordHandleForDebugging, getScanInfo, init, isCurrentPositionDeleted, isHeldAfterCommit, isKeyed, newRowLocationTemplate, next, positionAtRowLocation, reopenScan, reopenScanByRowLocation, replace, toString
-
Methods inherited from class org.apache.derby.impl.store.access.btree.OpenBTree
checkConsistency, debugConglomerate, getColumnSortOrderInfo, getConglomerate, getContainer, getContainerHandle, getEstimatedRowCount, getHeight, getHold, getLockingPolicy, getLockLevel, getOpenMode, getRawTran, getRuntimeMem, getSpaceInfo, getXactMgr, init, isClosed, isTableLocked, reopen, setEstimatedRowCount, setLockingPolicy, test_errors
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.derby.iapi.store.access.GenericScanController
isTableLocked
-
Methods inherited from interface org.apache.derby.iapi.store.access.RowCountable
getEstimatedRowCount, setEstimatedRowCount
-
-
-
-
Method Detail
-
fetchMax
public boolean fetchMax(DataValueDescriptor[] fetch_row) throws StandardException
Fetch the maximum row in the table. Call positionAtStartPosition() to quickly position on rightmost row of rightmost leaf of tree. Search last page for last non deleted row, and if one is found return it as max. If no row found on last page, or could not find row without losing latch then call fetchMaxRowFromBeginning() to search from left to right for maximum value in index.- Throws:
StandardException- Standard exception policy.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG