|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl
org.apache.derby.impl.sql.execute.NoPutResultSetImpl
org.apache.derby.impl.sql.execute.ScrollInsensitiveResultSet
public class ScrollInsensitiveResultSet
Provide insensitive scrolling functionality for the underlying result set. We build a disk backed hash table of rows as the user scrolls forward, with the position as the key. For read-only result sets the hash table will containg the following columns:
+-------------------------------+ | KEY | +-------------------------------+ | Row | +-------------------------------+where key is the position of the row in the result set and row is the data. And for updatable result sets it will contain:
+-------------------------------+ | KEY | [0] +-------------------------------+ | RowLocation | [POS_ROWLOCATION] +-------------------------------+ | Deleted | [POS_ROWDELETED] +-------------------------------+ | Updated | [POS_ROWUPDATED] +-------------------------------+ | Row | [extraColumns ... n] +-------------------------------+where key is the position of the row in the result set, rowLocation is the row location of that row in the Heap, Deleted indicates whether the row has been deleted, Updated indicates whether the row has been updated, and row is the data.
| Field Summary | |
|---|---|
private boolean |
afterLast
|
private boolean |
beforeFirst
|
private int |
currentPosition
|
private int |
extraColumns
|
private BackingStoreHashtable |
ht
|
private boolean |
keepAfterCommit
|
private static int |
LAST_EXTRA_COLUMN
|
private int |
lastPosition
|
private long |
maxRows
|
private boolean |
needsRepositioning
|
int |
numFromHashTable
|
int |
numToHashTable
|
private static int |
POS_ROWDELETED
|
private static int |
POS_ROWLOCATION
|
private static int |
POS_ROWUPDATED
|
private SQLInteger |
positionInHashTable
|
private int |
positionInSource
|
private ExecRow |
resultRow
|
private boolean |
seenFirst
|
private boolean |
seenLast
|
NoPutResultSet |
source
|
private int |
sourceRowWidth
|
private CursorResultSet |
target
|
| 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 | |
|---|---|
ScrollInsensitiveResultSet(NoPutResultSet source,
Activation activation,
int resultSetNumber,
int sourceRowWidth,
double optimizerEstimatedRowCount,
double optimizerEstimatedCost)
Constructor for a ScrollInsensitiveResultSet |
|
| Method Summary | |
|---|---|
private void |
addRowToHashTable(ExecRow sourceRow,
int position,
RowLocation rowLoc,
boolean rowUpdated)
Add a row to the backing hash table, keyed on position. |
boolean |
checkRowPosition(int isType)
Determine if the cursor is before the first row in the result set. |
void |
close()
If the result set has been opened, close the open scan. |
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 |
getAbsoluteRow(int row)
Returns the row at the absolute position from the query, and returns NULL when there is no such position. |
ExecRow |
getCurrentRow()
Gets information from last getNextRow call. |
ExecRow |
getFirstRow()
Returns the first row from the query, and returns NULL when there are no rows. |
ExecRow |
getLastRow()
Returns the last row from the query, and returns NULL when there are no rows. |
ExecRow |
getNextRowCore()
Return the requested values computed from the next row (if any) for which the restriction evaluates to true. |
private ExecRow |
getNextRowFromSource()
|
ExecRow |
getPreviousRow()
Returns the previous row from the query, and returns NULL when there are no more previous rows. |
ExecRow |
getRelativeRow(int row)
Returns the row at the relative position from the current cursor position, and returns NULL when there is no such position. |
private DataValueDescriptor[] |
getRowArrayFromHashTable(int position)
Get the row data at the specified position from the hash table. |
private ExecRow |
getRowFromHashTable(int position)
Get the row at the specified position from the hash table. |
RowLocation |
getRowLocation()
Gets information from its source. |
int |
getRowNumber()
Returns the row number of the current row. |
long |
getTimeSpent(int type)
Return the total amount of time spent in this ResultSet |
boolean |
isDeleted()
Returns TRUE if the row was been deleted within the transaction, otherwise returns FALSE |
boolean |
isForUpdate()
Is this ResultSet or it's source result set for update This method will be overriden in the inherited Classes if it is true |
boolean |
isUpdated()
Returns TRUE if the row was been updated within the transaction, otherwise returns FALSE |
void |
markRowAsDeleted()
Marks the resultSet's currentRow as deleted after a delete has been issued by either by using positioned delete or JDBC's deleteRow method. |
void |
openCore()
open a scan on the source. scan parameters are evaluated at each open, so there is probably some way of altering their values... |
private void |
positionInLastFetchedRow()
Positions the cursor in the last fetched row. |
void |
reopenCore()
reopen a scan on the table. scan parameters are evaluated at each open, so there is probably some way of altering their values... |
ExecRow |
setAfterLastRow()
Sets the current position to after the last row and returns NULL because there is no current row. |
ExecRow |
setBeforeFirstRow()
Sets the current position to before the first row and returns NULL because there is no current row. |
void |
updateRow(ExecRow row,
RowChanger rowChanger)
Updates the resultSet's current row with it's new values after an update has been issued either using positioned update or JDBC's udpateRow method. |
| Methods inherited from class org.apache.derby.impl.sql.execute.NoPutResultSetImpl |
|---|
clearCurrentRow, clearOrderableCache, closeRowSource, getCursorName, getNextRowFromRowSource, getResultDescription, getValidColumns, needsRowLocation, needsToClone, positionScanAtRowLocation, printQualifiers, resultSetNumber, rowLocation, setCurrentRow, setNeedsRowLocation, setTargetResultSet, skipRow, skipScan |
| 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 |
|---|
addWarning, cleanUp, clearCurrentRow, getActivation, getAutoGeneratedKeysResultset, getBeginExecutionTimestamp, getCursorName, getEndExecutionTimestamp, getExecuteTime, getNextRow, getResultDescription, getSubqueryTrackingArray, getWarnings, isClosed, modifiedRowCount, open, returnsRows |
| Field Detail |
|---|
public NoPutResultSet source
private int sourceRowWidth
private BackingStoreHashtable ht
private ExecRow resultRow
private int positionInSource
private int currentPosition
private int lastPosition
private boolean seenFirst
private boolean seenLast
private boolean beforeFirst
private boolean afterLast
public int numFromHashTable
public int numToHashTable
private long maxRows
private boolean keepAfterCommit
private int extraColumns
private SQLInteger positionInHashTable
private CursorResultSet target
private boolean needsRepositioning
private static final int POS_ROWLOCATION
private static final int POS_ROWDELETED
private static final int POS_ROWUPDATED
private static final int LAST_EXTRA_COLUMN
| Constructor Detail |
|---|
public ScrollInsensitiveResultSet(NoPutResultSet source,
Activation activation,
int resultSetNumber,
int sourceRowWidth,
double optimizerEstimatedRowCount,
double optimizerEstimatedCost)
throws StandardException
source - The NoPutResultSet from which to get rows
to scroll throughactivation - The activation for this executionresultSetNumber - The resultSetNumbersourceRowWidth - # of columns in the source row
StandardException - on error| Method Detail |
|---|
public void openCore()
throws StandardException
openCore in interface NoPutResultSetStandardException - thrown on failure
public void reopenCore()
throws StandardException
reopenCore in interface NoPutResultSetreopenCore in class BasicNoPutResultSetImplStandardException - thrown if cursor finished.NoPutResultSet.openCore()
public ExecRow getAbsoluteRow(int row)
throws StandardException
getAbsoluteRow in interface ResultSetgetAbsoluteRow in class BasicNoPutResultSetImplrow - The position.
StandardException - Thrown on failureRow
public ExecRow getRelativeRow(int row)
throws StandardException
getRelativeRow in interface ResultSetgetRelativeRow in class BasicNoPutResultSetImplrow - The position.
StandardException - Thrown on failureRowpublic ExecRow setBeforeFirstRow()
setBeforeFirstRow in interface ResultSetsetBeforeFirstRow in class BasicNoPutResultSetImplRow
public ExecRow getFirstRow()
throws StandardException
getFirstRow in interface ResultSetgetFirstRow in class BasicNoPutResultSetImplStandardException - Thrown on failureRow
public ExecRow getNextRowCore()
throws StandardException
NoPutResultSetrestriction and projection parameters are evaluated for each row.
getNextRowCore in interface NoPutResultSetgetNextRowCore in class BasicNoPutResultSetImplStandardException - thrown on failureNoPutResultSet.getNextRowCore()
public ExecRow getPreviousRow()
throws StandardException
getPreviousRow in interface ResultSetgetPreviousRow in class BasicNoPutResultSetImplStandardException - Thrown on failureRow
public ExecRow getLastRow()
throws StandardException
getLastRow in interface ResultSetgetLastRow in class BasicNoPutResultSetImplStandardException - Thrown on failureRow
public ExecRow setAfterLastRow()
throws StandardException
setAfterLastRow in interface ResultSetsetAfterLastRow in class BasicNoPutResultSetImplStandardException - Thrown on failureRow
public boolean checkRowPosition(int isType)
throws StandardException
checkRowPosition in interface ResultSetcheckRowPosition in class BasicNoPutResultSetImplStandardException - Thrown on error.public int getRowNumber()
getRowNumber in interface ResultSetgetRowNumber in class BasicNoPutResultSetImpl
private ExecRow getNextRowFromSource()
throws StandardException
StandardException
public void close()
throws StandardException
close in interface ResultSetclose in class NoPutResultSetImplStandardException - thrown on error
public void finish()
throws StandardException
ResultSet
finish in interface ResultSetfinish in class BasicNoPutResultSetImplStandardException - on errorpublic long getTimeSpent(int type)
getTimeSpent in interface ResultSettype - CURRENT_RESULTSET_ONLY - time spent only in this ResultSet
ENTIRE_RESULTSET_TREE - time spent in this ResultSet and below.
public RowLocation getRowLocation()
throws StandardException
getRowLocation in interface CursorResultSetStandardException - thrown on failureCursorResultSet
public ExecRow getCurrentRow()
throws StandardException
getCurrentRow in interface CursorResultSetStandardException - thrown on failure.CursorResultSet
private void addRowToHashTable(ExecRow sourceRow,
int position,
RowLocation rowLoc,
boolean rowUpdated)
throws StandardException
sourceRow - The row to add.position - The keyrowLoc - The rowLocation of the row to add.rowUpdated - Indicates whether the row has been updated.
StandardException
private ExecRow getRowFromHashTable(int position)
throws StandardException
position - The specified position.
StandardException - thrown on failure
private DataValueDescriptor[] getRowArrayFromHashTable(int position)
throws StandardException
position - The specified position.
StandardException - thrown on failure
private void positionInLastFetchedRow()
throws StandardException
StandardException
public void updateRow(ExecRow row,
RowChanger rowChanger)
throws StandardException
NoPutResultSet
updateRow in interface NoPutResultSetupdateRow in class NoPutResultSetImplrow - new values for the currentRowrowChanger - holds information about row: what columns of it is to
be used for updating, and what underlying base table column each
such column corresponds to.
StandardException - thrown on failure.Sets the updated column of the hash table to true and updates the row
in the hash table with the new values for the row.
public void markRowAsDeleted()
throws StandardException
NoPutResultSet
markRowAsDeleted in interface NoPutResultSetmarkRowAsDeleted in class NoPutResultSetImplStandardException - thrown on failure.Sets the deleted column of the hash table to true in the current row.
public boolean isDeleted()
throws StandardException
StandardException - on error
public boolean isUpdated()
throws StandardException
StandardException - on errorpublic boolean isForUpdate()
NoPutResultSetImpl
isForUpdate in interface NoPutResultSetisForUpdate in class NoPutResultSetImpl
|
Built on Wed 2013-06-12 15:21:56+0000, from revision ??? | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||