Top Fields Constructors Methods
org.apache.derby.impl.store.access.heap

pack-priv Class HeapScan

extends GenericScanController
implements ScanManager
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.store.access.conglomerate.ScanManager, org.apache.derby.iapi.store.access.GroupFetchScanController, org.apache.derby.iapi.store.access.GenericScanController, org.apache.derby.iapi.store.access.RowCountable, org.apache.derby.iapi.store.access.ScanController
Known Direct Subclasses
org.apache.derby.impl.store.access.heap.HeapCompressScan
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.access.conglomerate.ScanManager, .TransactionManager, org.apache.derby.iapi.store.access.BackingStoreHashtable, .Qualifier, .RowUtil, .ScanInfo, org.apache.derby.iapi.store.raw.RecordHandle, org.apache.derby.iapi.types.DataValueDescriptor, .RowLocation, org.apache.derby.impl.store.access.conglomerate.GenericScanController, .RowPosition

Field Summary

Modifier and TypeField and Description
private DataValueDescriptor[][]
fetchNext_one_slot_array

A 1 element array to turn fetchNext and fetch calls into fetchNextGroup calls.

Inherited from org.apache.derby.impl.store.access.conglomerate.GenericScanController:
rowLocationsInvalidatedSCAN_DONESCAN_HOLD_INITSCAN_HOLD_INPROGRESSSCAN_INITSCAN_INPROGRESSscan_positionstat_numpages_visitedstat_numrows_qualifiedstat_numrows_visited

Constructor Summary

AccessConstructor and Description
public
HeapScan()

The only constructor for a heap scan returns a scan in the closed state, the caller must call open.

Method Summary

Modifier and TypeMethod and Description
public void
public boolean

Returns:

True if there is a next position in the scan, false if there isn't.
fetchNext
(DataValueDescriptor[]
The template row into which the value of the next position in the scan is to be stored.
fetch_row
)

Implements org.apache.derby.iapi.store.access.ScanController.fetchNext.

Fetch the row at the next position of the Scan.

public int
fetchNextGroup(DataValueDescriptor[][]
The array of rows to copy rows into. row_array[].length must >= 1. The first entry must be non-null destination rows, other entries may be null and will be allocated by access if needed.
row_array
,
RowLocation[]
If non-null, the array of row locations to copy into. If null, no row locations are retrieved.
rowloc_array
)

Implements org.apache.derby.iapi.store.access.GroupFetchScanController.fetchNextGroup.

Fetch the next N rows from the table.

public int
public ScanInfo

Returns:

The ScanInfo object which contains info about current scan.
getScanInfo
()

Overrides org.apache.derby.impl.store.access.conglomerate.GenericScanController.getScanInfo.

Implements org.apache.derby.iapi.store.access.GenericScanController.getScanInfo.

Return ScanInfo object which describes performance of scan.

protected RowLocation
public boolean
public boolean
positionAtRowLocation(RowLocation
RowLocation for the new position for the scan. The RowLocation submitted should be a RowLocation which has previously been returned by this ScanController.
rl
)

Implements org.apache.derby.iapi.store.access.ScanController.positionAtRowLocation.

Positions the scan at row location and locks the row.

protected void
queueDeletePostCommitWork(RowPosition pos)

Overrides org.apache.derby.impl.store.access.conglomerate.GenericController.queueDeletePostCommitWork.

Protected concrete impl of abstract methods of GenericController class:

private boolean

Returns:

true if the scan was successfully repositioned
reopenScanByRecordHandleAndSetLocks
(RecordHandle
An existing RecordHandle within the conglomerate, at which to position the start of the scan. The scan will begin at this location and continue forward until the end of the conglomerate. Positioning at a non-existent RowLocation (ie. an invalid one or one that had been deleted), will result in an exception being thrown when the first next operation is attempted.
rh
)

Reposition the current scan and sets the necessary locks.

public void
reopenScanByRowLocation(RowLocation
An existing RowLocation within the conglomerate, at which to position the start of the scan. The scan will begin at this location and continue forward until the end of the conglomerate. Positioning at a non-existent RowLocation (ie. an invalid one or one that had been deleted), will result in an exception being thrown when the first next operation is attempted.
startRowLocation
,
Qualifier[][]
An array of qualifiers which, applied to each key, restrict the rows returned by the scan. Rows for which any one of the qualifiers returns false are not returned by the scan. If null, all rows are returned.
qualifier
)

Overrides org.apache.derby.impl.store.access.conglomerate.GenericScanController.reopenScanByRowLocation.

Implements org.apache.derby.iapi.store.access.GenericScanController.reopenScanByRowLocation.

Reposition the current scan.

protected void
setRowLocationArray(RowLocation[] rowloc_array, int index, RowPosition pos)

Implements abstract org.apache.derby.impl.store.access.conglomerate.GenericScanController.setRowLocationArray.

Private/Protected methods of This class:

protected void
setRowLocationArray(RowLocation[] rowloc_array, int index, RecordHandle rh)

Inherited from org.apache.derby.impl.store.access.conglomerate.GenericScanController:
allocateScanPositionclosecloseForEndTransactiondeletedidNotQualifydoesCurrentPositionQualifyfetchfetchRowsfetchSetfetchWithoutQualifygetNumPagesVisitedgetNumRowsQualifiedgetNumRowsVisitedgetQualifiergetScanColumnListgetScanPositiongetScanStategetStartKeyValuegetStartSearchOperatorgetStopKeyValuegetStopSearchOperatorinitisCurrentPositionDeletedisHeldAfterCommitpositionAtDoneScanpositionAtInitScanpositionAtNextPagepositionAtResumeScanpositionAtStartForForwardScanreopenAfterEndTransactionreopenScanreopenScanByRecordHandlereplacesetScanPositionsetScanState

Field Detail

fetchNext_one_slot_arrayback to summary
private DataValueDescriptor[][] fetchNext_one_slot_array

A 1 element array to turn fetchNext and fetch calls into fetchNextGroup calls.

Constructor Detail

HeapScanback to summary
public HeapScan()

The only constructor for a heap scan returns a scan in the closed state, the caller must call open.

Method Detail

fetchLocationback to summary
public void fetchLocation(RowLocation templateLocation) throws StandardException

Overrides org.apache.derby.impl.store.access.conglomerate.GenericScanController.fetchLocation.

Implements org.apache.derby.iapi.store.access.ScanController.fetchLocation.

Doc from org.apache.derby.iapi.store.access.ScanController.fetchLocation.

Fetch the location of the current position in the scan. The destination location is replaced with the location corresponding to the current position in the scan. The destination location must be of the correct actual type to accept a location from the underlying conglomerate location. The results of a fetchLocation() performed on a scan after next() has returned false are undefined. The results of a fetchLocation() performed on a scan positioned on a deleted row are undefined, note that this can happen even if next() has returned true (for instance the client can delete the row, or if using read uncommitted another thread can delete the row after the next() call but before the fetchLocation).

Exceptions
StandardException:
Standard exception policy.
See Also
org.apache.derby.iapi.store.access.ScanController#fetchLocation
fetchNextback to summary
public boolean fetchNext(DataValueDescriptor[] fetch_row) throws StandardException

Implements org.apache.derby.iapi.store.access.ScanController.fetchNext.

Fetch the row at the next position of the Scan. If there is a valid next position in the scan then the value in the template storable row is replaced with the value of the row at the current scan position. The columns of the template row must be of the same type as the actual columns in the underlying conglomerate. The resulting contents of templateRow after a fetchNext() which returns false is undefined. The result of calling fetchNext(row) is exactly logically equivalent to making a next() call followed by a fetch(row) call. This interface allows implementations to optimize the 2 calls if possible.

Parameters
fetch_row:DataValueDescriptor[]

The template row into which the value of the next position in the scan is to be stored.

Returns:boolean

True if there is a next position in the scan, false if there isn't.

Exceptions
StandardException:
Standard exception policy.
fetchNextGroupback to summary
public int fetchNextGroup(DataValueDescriptor[][] row_array, RowLocation[] rowloc_array) throws StandardException

Implements org.apache.derby.iapi.store.access.GroupFetchScanController.fetchNextGroup.

Doc from org.apache.derby.iapi.store.access.GroupFetchScanController.fetchNextGroup.

Fetch the next N rows from the table.

The client allocates an array of N rows and passes it into the fetchNextSet() call. The client must at least allocate a row and set row_array[0] to this row. The client can optionally either leave the rest of array entries null, or allocate rows to the slots. If access finds an entry to be null, and wants to read a row into it, it will allocate a row to the slot. Once fetchNextGroup() returns "ownership" of the row passes back to the client, access will not keep references to the allocated row. Expected usage is that the client will specify an array of some number (say 10), and then only allocate a single row. This way if only 1 row qualifies only one row will have been allocated.

This routine does the equivalent of N fetchNext() calls, filling in each of the rows in the array. Locking is performed exactly as if the N fetchNext() calls had been made.

It is up to Access how many rows to return. fetchNextGroup() will return how many rows were filled in. If fetchNextGroup() returns 0 then the scan is complete, (ie. the scan is in the same state as if fetchNext() had returned false). If the scan is not complete then fetchNext() will return (1 <= row_count <= N).

The current position of the scan is undefined if fetchNextSet() is used (ie. mixing fetch()/fetchNext() and fetchNextSet() calls in a single scan does not work). This is because a fetchNextSet() request for 5 rows from a heap where the first 2 rows qualify, but no other rows qualify will result in the scan being positioned at the end of the table, while if 5 rows did qualify the scan will be positioned on the 5th row.

If the row loc array is non-null then for each row fetched into the row array, a corresponding fetchLocation() call will be made to fill in the rowloc_array. This array, like the row array can be initialized with only one non-null RowLocation and access will allocate the rest on demand.

Qualifiers, start and stop positioning of the openscan are applied just as in a normal scan.

The columns of the row will be the standard columns returned as part of a scan, as described by the validColumns - see openScan for description.

Expected usage: // allocate an array of 5 empty rows DataValueDescriptor[][] row_array = allocate_row_array(5); int row_cnt = 0; scan = openScan(); while ((row_cnt = scan.fetchNextSet(row_array, null) != 0) { // I got "row_cnt" rows from the scan. These rows will be // found in row_array[0] through row_array[row_cnt - 1] }

Parameters
row_array:DataValueDescriptor[][]

The array of rows to copy rows into. row_array[].length must >= 1. The first entry must be non-null destination rows, other entries may be null and will be allocated by access if needed.

rowloc_array:RowLocation[]

If non-null, the array of row locations to copy into. If null, no row locations are retrieved.

Returns:int

The number of qualifying rows found and copied into the provided array of rows. If 0 then the scan is complete, otherwise the return value will be: 1 <= row_count <= row_array.length

Exceptions
StandardException:
Standard exception policy.
fetchNextGroupback to summary
public int fetchNextGroup(DataValueDescriptor[][] row_array, RowLocation[] old_rowloc_array, RowLocation[] new_rowloc_array) throws StandardException

Implements org.apache.derby.iapi.store.access.GroupFetchScanController.fetchNextGroup.

getScanInfoback to summary
public ScanInfo getScanInfo() throws StandardException

Overrides org.apache.derby.impl.store.access.conglomerate.GenericScanController.getScanInfo.

Implements org.apache.derby.iapi.store.access.GenericScanController.getScanInfo.

Return ScanInfo object which describes performance of scan.

Return ScanInfo object which contains information about the current scan.

Returns:ScanInfo

The ScanInfo object which contains info about current scan.

Exceptions
StandardException:
Standard exception policy.
See Also
ScanInfo
makeRowLocationback to summary
protected RowLocation makeRowLocation(RowPosition pos) throws StandardException

Implements abstract org.apache.derby.impl.store.access.conglomerate.GenericScanController.makeRowLocation.

Doc from org.apache.derby.impl.store.access.conglomerate.GenericScanController.makeRowLocation.

Make a RowLocation from a RowPosition

nextback to summary
public boolean next() throws StandardException

Implements org.apache.derby.iapi.store.access.ScanController.next, org.apache.derby.iapi.store.access.GroupFetchScanController.next.

Doc from org.apache.derby.iapi.store.access.ScanController.next.

Move to the next position in the scan. If this is the first call to next(), the position is set to the first row. Returns false if there is not a next row to move to. It is possible, but not guaranteed, that this method could return true again, after returning false, if some other operation in the same transaction appended a row to the underlying conglomerate.

Returns:boolean

True if there is a next position in the scan, false if there isn't.

Exceptions
StandardException:
Standard exception policy.
See Also
org.apache.derby.iapi.store.access.ScanController#next
positionAtRowLocationback to summary
public boolean positionAtRowLocation(RowLocation rl) throws StandardException

Implements org.apache.derby.iapi.store.access.ScanController.positionAtRowLocation.

Doc from org.apache.derby.iapi.store.access.ScanController.positionAtRowLocation.

Positions the scan at row location and locks the row. If the scan is not opened, it will be reopened if this is a holdable scan and there has not been any operations which causes RowLocations to be invalidated.

Parameters
rl:RowLocation

RowLocation for the new position for the scan. The RowLocation submitted should be a RowLocation which has previously been returned by this ScanController.

Returns:boolean

true if the scan has been positioned at the RowLocation. false if the scan could not be positioned.

Exceptions
StandardException:
Standard exception policy.
See Also
org.apache.derby.iapi.store.access.ScanController#positionAtRowLocation
queueDeletePostCommitWorkback to summary
protected void queueDeletePostCommitWork(RowPosition pos) throws StandardException

Overrides org.apache.derby.impl.store.access.conglomerate.GenericController.queueDeletePostCommitWork.

Protected concrete impl of abstract methods of GenericController class:

reopenScanByRecordHandleAndSetLocksback to summary
private boolean reopenScanByRecordHandleAndSetLocks(RecordHandle rh) throws StandardException

Reposition the current scan and sets the necessary locks.

Parameters
rh:RecordHandle

An existing RecordHandle within the conglomerate, at which to position the start of the scan. The scan will begin at this location and continue forward until the end of the conglomerate. Positioning at a non-existent RowLocation (ie. an invalid one or one that had been deleted), will result in an exception being thrown when the first next operation is attempted.

Returns:boolean

true if the scan was successfully repositioned

Exceptions
StandardException:
Standard exception policy.
reopenScanByRowLocationback to summary
public void reopenScanByRowLocation(RowLocation startRowLocation, Qualifier[][] qualifier) throws StandardException

Overrides org.apache.derby.impl.store.access.conglomerate.GenericScanController.reopenScanByRowLocation.

Implements org.apache.derby.iapi.store.access.GenericScanController.reopenScanByRowLocation.

Reposition the current scan. This call is semantically the same as if the current scan had been closed and a openScan() had been called instead. The scan is reopened against the same conglomerate, and the scan is reopened with the same "scan column list", "hold" and "forUpdate" parameters passed in the original openScan.

The statistics gathered by the scan are not reset to 0 by a reopenScan(), rather they continue to accumulate.

Note that this operation is currently only supported on Heap conglomerates. Also note that order of rows within are heap are not guaranteed, so for instance positioning at a RowLocation in the "middle" of a heap, then inserting more data, then continuing the scan is not guaranteed to see the new rows - they may be put in the "beginning" of the heap.

Parameters
startRowLocation:RowLocation

An existing RowLocation within the conglomerate, at which to position the start of the scan. The scan will begin at this location and continue forward until the end of the conglomerate. Positioning at a non-existent RowLocation (ie. an invalid one or one that had been deleted), will result in an exception being thrown when the first next operation is attempted.

qualifier:Qualifier[][]

An array of qualifiers which, applied to each key, restrict the rows returned by the scan. Rows for which any one of the qualifiers returns false are not returned by the scan. If null, all rows are returned.

Exceptions
StandardException:
Standard exception policy.
setRowLocationArrayback to summary
protected void setRowLocationArray(RowLocation[] rowloc_array, int index, RowPosition pos) throws StandardException

Implements abstract org.apache.derby.impl.store.access.conglomerate.GenericScanController.setRowLocationArray.

Private/Protected methods of This class:

setRowLocationArrayback to summary
protected void setRowLocationArray(RowLocation[] rowloc_array, int index, RecordHandle rh) throws StandardException