Top Description Constructors Methods
org.apache.derby.impl.store.access.sort

public abstract Class Scan

extends Object
implements ScanManager, ScanInfo
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.store.access.ScanInfo, 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.sort.SortBufferRowSource, org.apache.derby.impl.store.access.sort.SortScan
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.store.access.BackingStoreHashtable, .Qualifier, .ScanInfo, .ScanController, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.shared.common.i18n.MessageService, org.apache.derby.iapi.types.RowLocation, .DataValueDescriptor, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.access.conglomerate.ScanManager, java.util.Properties

Abstract base class for all sort classes which return rows from the sort. Subclasses must implement fetch, next, and close.

Constructor Summary

AccessConstructor and Description
public
Scan()

Method Summary

Modifier and TypeMethod and Description
public boolean
delete()

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

Delete the row at the current position of the scan.

public void
didNotQualify()

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

A call to allow client to indicate that current row does not qualify.

public boolean
doesCurrentPositionQualify()

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

Returns true if the current position of the scan still qualifies under the set of qualifiers passed to the openScan().

public void
fetchLocation(RowLocation templateLocation)

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

Fetch the location of the current position in 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 void
fetchSet(long
The maximum number of rows to insert into the Hash table. Pass in -1 if there is no maximum.
max_rowcnt
,
int[]
The column numbers of the columns in the scan result row to be the key to the Hashtable. "0" is the first column in the scan result row (which may be different than the first row in the table of the scan).
key_column_numbers
,
BackingStoreHashtable hash_table)

Implements org.apache.derby.iapi.store.access.conglomerate.ScanManager.fetchSet.

Insert all rows that qualify for the current scan into the input Hash table.

public Properties
getAllScanInfo(Properties
Property list to fill in.
prop
)

Implements org.apache.derby.iapi.store.access.ScanInfo.getAllScanInfo.

Return all information gathered about the scan.

public long

Returns:

The total estimated number of rows in the conglomerate.
getEstimatedRowCount
()

Implements org.apache.derby.iapi.store.access.RowCountable.getEstimatedRowCount.

Get the total estimated number of rows in the container.

public ScanInfo

Returns:

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

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

Return ScanInfo object which describes performance of scan.

public boolean
isCurrentPositionDeleted()

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

Returns true if the current position of the scan is at a deleted row.

public boolean
isHeldAfterCommit()

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

Return true is the scan has been closed after a commit, but was opened with holdability and can be reopened using positionAtRowLocation.

public boolean

Returns:

whether this is a keyed conglomerate.
isKeyed
()

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

Return whether this is a keyed conglomerate.

public boolean

Returns:

whether this is table locked.
isTableLocked
()

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

Return whether this scan is table locked.

public RowLocation
newRowLocationTemplate()

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

Return a row location object of the correct type to be used in calls to fetchLocation.

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.

public void
reopenScan(DataValueDescriptor[]
An indexable row which holds a (partial) key value which, in combination with the startSearchOperator, defines the starting position of the scan. If null, the starting position of the scan is the first row of the conglomerate.
startKeyValue
,
int
an operator which defines how the startKeyValue is to be searched for. If startSearchOperator is ScanController.GE, the scan starts on the first row which is greater than or equal to the startKeyValue. If startSearchOperation is ScanController.GT, the scan starts on the first row whose key is greater than startKeyValue. The startSearchOperation parameter is ignored if the startKeyValue parameter is null.
startSearchOperator
,
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
,
DataValueDescriptor[]
An indexable row which holds a (partial) key value which, in combination with the stopSearchOperator, defines the ending position of the scan. If null, the ending position of the scan is the last row of the conglomerate.
stopKeyValue
,
int
an operator which defines how the stopKeyValue is used to determine the scan stopping position. If stopSearchOperation is ScanController.GE, the scan stops just before the first row which is greater than or equal to the stopKeyValue. If stopSearchOperation is ScanController.GT, the scan stops just before the first row whose key is greater than startKeyValue. The stopSearchOperation parameter is ignored if the stopKeyValue parameter is null.
stopSearchOperator
)

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

Reposition the current scan.

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
)

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

Reposition the current scan.

public boolean
replace(DataValueDescriptor[] val, FormatableBitSet validColumns)

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

Replace the entire row at the current position of the scan.

public void
setEstimatedRowCount(long
the estimated number of rows in the container.
count
)

Implements org.apache.derby.iapi.store.access.RowCountable.setEstimatedRowCount.

Set the total estimated number of rows in the container.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Scanback to summary
public Scan()

Method Detail

deleteback to summary
public boolean delete() throws StandardException

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

Delete the row at the current position of the scan.

Returns:boolean

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

true if the delete was successful, false if the current position is no longer valid (ie. if it was already deleted).

Exceptions
StandardException:

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

Standard exception policy.

See Also
ScanController#delete
didNotQualifyback to summary
public void didNotQualify() throws StandardException

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

A call to allow client to indicate that current row does not qualify.

Indicates to the ScanController that the current row does not qualify for the scan. If the isolation level of the scan allows, this may result in the scan releasing the lock on this row.

Note that some scan implimentations may not support releasing locks on non-qualifying rows, or may delay releasing the lock until sometime later in the scan (ie. it may be necessary to keep the lock until either the scan is repositioned on the next row or page).

This call should only be made while the scan is positioned on a current valid row.

This call does not make sense for sort scans.

Exceptions
StandardException:
Standard exception policy.
doesCurrentPositionQualifyback to summary
public boolean doesCurrentPositionQualify() throws StandardException

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

Returns true if the current position of the scan still qualifies under the set of qualifiers passed to the openScan().

Exceptions
StandardException:

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

Standard exception policy.

See Also
ScanController#doesCurrentPositionQualify
fetchLocationback to summary
public void fetchLocation(RowLocation templateLocation) throws StandardException

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

Fetch the location of the current position in the scan.

Exceptions
StandardException:

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

Standard exception policy.

See Also
ScanController#fetchLocation
fetchNextGroupback to summary
public int fetchNextGroup(DataValueDescriptor[][] row_array, RowLocation[] rowloc_array) throws StandardException

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

Fetch the next N rows from the table.

Currently unimplemented for sorts.

Parameters
row_array:DataValueDescriptor[][]

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

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[]

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

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

Returns:int

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

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:

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

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.

fetchSetback to summary
public void fetchSet(long max_rowcnt, int[] key_column_numbers, BackingStoreHashtable hash_table) throws StandardException

Implements org.apache.derby.iapi.store.access.conglomerate.ScanManager.fetchSet.

Insert all rows that qualify for the current scan into the input Hash table.

Currently unimplemented for sorts.

Parameters
max_rowcnt:long

Doc from org.apache.derby.iapi.store.access.conglomerate.ScanManager.fetchSet.

The maximum number of rows to insert into the Hash table. Pass in -1 if there is no maximum.

key_column_numbers:int[]

Doc from org.apache.derby.iapi.store.access.conglomerate.ScanManager.fetchSet.

The column numbers of the columns in the scan result row to be the key to the Hashtable. "0" is the first column in the scan result row (which may be different than the first row in the table of the scan).

Exceptions
StandardException:

Doc from org.apache.derby.iapi.store.access.conglomerate.ScanManager.fetchSet.

Standard exception policy.

getAllScanInfoback to summary
public Properties getAllScanInfo(Properties prop) throws StandardException

Implements org.apache.derby.iapi.store.access.ScanInfo.getAllScanInfo.

Return all information gathered about the scan.

This routine returns a list of properties which contains all information gathered about the scan. If a Property is passed in, then that property list is appeneded to, otherwise a new property object is created and returned.

Currently sort scans doesn't track any information.

Parameters
prop:Properties

Property list to fill in.

Exceptions
StandardException:
Standard exception policy.
getEstimatedRowCountback to summary
public long getEstimatedRowCount() throws StandardException

Implements org.apache.derby.iapi.store.access.RowCountable.getEstimatedRowCount.

Get the total estimated number of rows in the container.

The number is a rough estimate and may be grossly off. In general the server will cache the row count and then occasionally write the count unlogged to a backing store. If the system happens to shutdown before the store gets a chance to update the row count it may wander from reality.

This call is currently only supported on Heap conglomerates, it will throw an exception if called on btree conglomerates.

Returns:long

The total estimated number of rows in the conglomerate.

Exceptions
StandardException:
Standard exception policy.
getScanInfoback to summary
public ScanInfo getScanInfo() throws StandardException

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.

Currently the ScanInfo does not have any performance data.

Returns:ScanInfo

The ScanInfo object which contains info about current scan.

Exceptions
StandardException:
Standard exception policy.
See Also
ScanInfo
isCurrentPositionDeletedback to summary
public boolean isCurrentPositionDeleted() throws StandardException

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

Returns true if the current position of the scan is at a deleted row.

Exceptions
StandardException:

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

Standard exception policy.

See Also
ScanController#isCurrentPositionDeleted
isHeldAfterCommitback to summary
public boolean isHeldAfterCommit() throws StandardException

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

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

Return true is the scan has been closed after a commit, but was opened with holdability and can be reopened using positionAtRowLocation.

Exceptions
StandardException:
Standard exception policy.
See Also
org.apache.derby.iapi.store.access.ScanController#isHeldAfterCommit
isKeyedback to summary
public boolean isKeyed()

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

Return whether this is a keyed conglomerate.

Returns:boolean

whether this is a keyed conglomerate.

isTableLockedback to summary
public boolean isTableLocked()

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

Return whether this scan is table locked.

Returns:boolean

whether this is table locked.

newRowLocationTemplateback to summary
public RowLocation newRowLocationTemplate() throws StandardException

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

Return a row location object of the correct type to be used in calls to fetchLocation.

Returns:RowLocation

Doc from org.apache.derby.iapi.store.access.GenericScanController.newRowLocationTemplate.

a row location object to be used in calls to fetchLocation.

Exceptions
StandardException:

Doc from org.apache.derby.iapi.store.access.GenericScanController.newRowLocationTemplate.

Standard exception policy.

See Also
ScanController#newRowLocationTemplate
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
ScanController#positionAtRowLocation
reopenScanback to summary
public void reopenScan(DataValueDescriptor[] startKeyValue, int startSearchOperator, Qualifier[][] qualifier, DataValueDescriptor[] stopKeyValue, int stopSearchOperator) throws StandardException

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

Reposition the current scan.

Parameters
startKeyValue:DataValueDescriptor[]

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScan.

An indexable row which holds a (partial) key value which, in combination with the startSearchOperator, defines the starting position of the scan. If null, the starting position of the scan is the first row of the conglomerate.

startSearchOperator:int

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScan.

an operator which defines how the startKeyValue is to be searched for. If startSearchOperator is ScanController.GE, the scan starts on the first row which is greater than or equal to the startKeyValue. If startSearchOperation is ScanController.GT, the scan starts on the first row whose key is greater than startKeyValue. The startSearchOperation parameter is ignored if the startKeyValue parameter is null.

qualifier:Qualifier[][]

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScan.

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.

stopKeyValue:DataValueDescriptor[]

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScan.

An indexable row which holds a (partial) key value which, in combination with the stopSearchOperator, defines the ending position of the scan. If null, the ending position of the scan is the last row of the conglomerate.

stopSearchOperator:int

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScan.

an operator which defines how the stopKeyValue is used to determine the scan stopping position. If stopSearchOperation is ScanController.GE, the scan stops just before the first row which is greater than or equal to the stopKeyValue. If stopSearchOperation is ScanController.GT, the scan stops just before the first row whose key is greater than startKeyValue. The stopSearchOperation parameter is ignored if the stopKeyValue parameter is null.

Exceptions
StandardException:

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScan.

Standard exception policy.

See Also
ScanController#reopenScan
reopenScanByRowLocationback to summary
public void reopenScanByRowLocation(RowLocation startRowLocation, Qualifier[][] qualifier) throws StandardException

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.

Parameters
startRowLocation:RowLocation

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScanByRowLocation.

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[][]

Doc from org.apache.derby.iapi.store.access.GenericScanController.reopenScanByRowLocation.

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.
replaceback to summary
public boolean replace(DataValueDescriptor[] val, FormatableBitSet validColumns) throws StandardException

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

Replace the entire row at the current position of the scan.

Returns:boolean

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

true if the replace was successful, false if the current position is no longer valid (ie. if it was deleted).

Exceptions
StandardException:

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

Standard exception policy.

See Also
ScanController#replace
setEstimatedRowCountback to summary
public void setEstimatedRowCount(long count) throws StandardException

Implements org.apache.derby.iapi.store.access.RowCountable.setEstimatedRowCount.

Set the total estimated number of rows in the container.

Often, after a scan, the client of RawStore has a much better estimate of the number of rows in the container than what store has. For instance if we implement some sort of update statistics command, or just after a create index a complete scan will have been done of the table. In this case this interface allows the client to set the estimated row count for the container, and store will use that number for all future references.

This call is currently only supported on Heap conglomerates, it will throw an exception if called on btree conglomerates.

Parameters
count:long

the estimated number of rows in the container.

Exceptions
StandardException:
Standard exception policy.