public class IndexCursorImpl extends CursorImpl implements IndexCursor
| Modifier and Type | Class and Description |
|---|---|
private class |
IndexCursorImpl.EntryIterator
Row iterator (by matching entry) for this cursor, modifiable.
|
private class |
IndexCursorImpl.ForwardIndexDirHandler
Handles moving the table index cursor forward.
|
private class |
IndexCursorImpl.IndexDirHandler
Handles moving the table index cursor in a given direction.
|
private static class |
IndexCursorImpl.IndexPosition
Value object which maintains the current position of an IndexCursor.
|
private class |
IndexCursorImpl.ReverseIndexDirHandler
Handles moving the table index cursor backward.
|
CursorImpl.BaseIterator, CursorImpl.DirHandler, CursorImpl.IdImpl, CursorImpl.PositionImpl, CursorImpl.SavepointImplCursor.Id, Cursor.Position, Cursor.Savepoint| Modifier and Type | Field and Description |
|---|---|
private IndexData.EntryCursor |
_entryCursor
Cursor over the entries of the relevant index
|
private IndexCursorImpl.IndexDirHandler |
_forwardDirHandler
IndexDirHandler for forward traversal
|
private IndexImpl |
_index
logical index which this cursor is using
|
private java.util.Set<java.lang.String> |
_indexEntryPattern
column names for the index entry columns
|
private IndexCursorImpl.IndexDirHandler |
_reverseDirHandler
IndexDirHandler for backward traversal
|
private static org.apache.commons.logging.Log |
LOG |
_columnMatcher, _curPos, _prevPos, MOVE_FORWARD, MOVE_REVERSE| Modifier | Constructor and Description |
|---|---|
private |
IndexCursorImpl(TableImpl table,
IndexImpl index,
IndexData.EntryCursor entryCursor) |
| Modifier and Type | Method and Description |
|---|---|
static IndexCursorImpl |
createCursor(TableImpl table,
IndexImpl index,
java.lang.Object[] startRow,
boolean startInclusive,
java.lang.Object[] endRow,
boolean endInclusive)
Creates an indexed cursor for the given table, narrowed to the given
range.
|
boolean |
currentRowMatchesEntry(java.lang.Object... entryValues)
Returns
true if the current row matches the given index entries. |
private boolean |
currentRowMatchesEntryImpl(java.lang.Object[] rowValues,
ColumnMatcher columnMatcher) |
java.util.Iterator<Row> |
entryIterator(EntryIterableBuilder iterBuilder) |
protected CursorImpl.PositionImpl |
findAnotherPosition(TableImpl.RowState rowState,
CursorImpl.PositionImpl curPos,
boolean moveForward)
Finds the next non-deleted row after the given row (as defined by this
cursor) and returns the id of the row, where "next" may be backwards if
moveForward is
false. |
protected boolean |
findAnotherRowImpl(ColumnImpl columnPattern,
java.lang.Object valuePattern,
boolean moveForward,
ColumnMatcher columnMatcher,
java.lang.Object searchInfo)
Moves to the next row (as defined by the cursor) where the given column
has the given value.
|
protected boolean |
findAnotherRowImpl(java.util.Map<java.lang.String,?> rowPattern,
boolean moveForward,
ColumnMatcher columnMatcher,
java.lang.Object searchInfo)
Moves to the next row (as defined by the cursor) where the given columns
have the given values.
|
void |
findClosestRowByEntry(java.lang.Object... entryValues)
Moves to the first row (as defined by the cursor) where the index entries
are >= the given values.
|
boolean |
findFirstRowByEntry(java.lang.Object... entryValues)
Moves to the first row (as defined by the cursor) where the index entries
match the given values.
|
protected boolean |
findFirstRowByEntryImpl(java.lang.Object[] rowValues,
boolean requireMatch,
ColumnMatcher columnMatcher)
Moves to the first row (as defined by the cursor) where the index entries
match the given values.
|
private boolean |
findPotentialRow(java.lang.Object[] rowValues,
boolean requireMatch) |
Row |
findRowByEntry(java.lang.Object... entryValues)
Finds the first row (as defined by the cursor) where the index entries
match the given values.
|
protected ColumnMatcher |
getDefaultColumnMatcher()
Returns the default ColumnMatcher for this Cursor.
|
protected IndexCursorImpl.IndexDirHandler |
getDirHandler(boolean moveForward)
Returns the DirHandler for the given movement direction.
|
IndexImpl |
getIndex() |
private java.util.Set<java.lang.String> |
getIndexEntryPattern() |
protected CursorImpl.PositionImpl |
getRowPosition(RowIdImpl rowId)
Returns the appropriate position information for the given row (which is
the current row and is valid).
|
protected boolean |
isUpToDate()
Returns
true if this cursor is up-to-date with respect to the
relevant table and related table objects, false otherwise. |
protected boolean |
keepSearching(ColumnMatcher columnMatcher,
java.lang.Object searchInfo)
Called by findAnotherRowImpl to determine if the search should continue
after finding a row which does not match the current pattern.
|
EntryIterableBuilder |
newEntryIterable(java.lang.Object... entryValues)
Convenience method for constructing a new EntryIterableBuilder for this
cursor.
|
protected java.lang.Object |
prepareSearchInfo(ColumnImpl columnPattern,
java.lang.Object valuePattern)
Called before a search commences to allow for search specific data to be
generated (which is cached for re-use by the iterators).
|
protected java.lang.Object |
prepareSearchInfo(java.util.Map<java.lang.String,?> rowPattern)
Called before a search commences to allow for search specific data to be
generated (which is cached for re-use by the iterators).
|
protected void |
reset(boolean moveForward)
Resets this cursor for traversing the given direction.
|
protected void |
restorePositionImpl(CursorImpl.PositionImpl curPos,
CursorImpl.PositionImpl prevPos)
Restores a current and previous position for the cursor.
|
private java.lang.Object[] |
toRowValues(java.lang.Object[] entryValues) |
afterLast, beforeFirst, createCursor, currentRowMatches, currentRowMatches, currentRowMatches, currentRowMatchesImpl, currentRowMatchesImpl, deleteCurrentRow, findAnotherRow, findAnotherRow, findFirstRow, findFirstRow, findFirstRow, findNextRow, findNextRow, findNextRow, findRow, getColumnMatcher, getCurrentRow, getCurrentRow, getCurrentRowValue, getCurrentRowValue, getErrorHandler, getFirstPosition, getFormat, getId, getLastPosition, getNextRow, getNextRow, getPageChannel, getPreviousRow, getPreviousRow, getRowState, getSavepoint, getTable, isAfterLast, isAtBeginning, isBeforeFirst, isCurrentRowDeleted, isCurrentRowValid, iterator, iterator, moveNextRows, movePreviousRows, moveToAnotherRow, moveToNextRow, moveToPreviousRow, newIterable, reset, restorePosition, restorePosition, restoreSavepoint, restoreSavepoint, setColumnMatcher, setCurrentRowValue, setCurrentRowValue, setErrorHandler, toString, updateCurrentRow, updateCurrentRowFromMapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitafterLast, beforeFirst, currentRowMatches, currentRowMatches, deleteCurrentRow, findFirstRow, findFirstRow, findNextRow, findNextRow, findRow, getColumnMatcher, getCurrentRow, getCurrentRow, getCurrentRowValue, getErrorHandler, getId, getNextRow, getNextRow, getPreviousRow, getPreviousRow, getSavepoint, getTable, isAfterLast, isBeforeFirst, isCurrentRowDeleted, iterator, moveNextRows, movePreviousRows, moveToNextRow, moveToPreviousRow, newIterable, reset, restoreSavepoint, setColumnMatcher, setCurrentRowValue, setErrorHandler, updateCurrentRow, updateCurrentRowFromMapprivate static final org.apache.commons.logging.Log LOG
private final IndexCursorImpl.IndexDirHandler _forwardDirHandler
private final IndexCursorImpl.IndexDirHandler _reverseDirHandler
private final IndexImpl _index
private final IndexData.EntryCursor _entryCursor
private java.util.Set<java.lang.String> _indexEntryPattern
private IndexCursorImpl(TableImpl table, IndexImpl index, IndexData.EntryCursor entryCursor) throws java.io.IOException
java.io.IOExceptionpublic static IndexCursorImpl createCursor(TableImpl table, IndexImpl index, java.lang.Object[] startRow, boolean startInclusive, java.lang.Object[] endRow, boolean endInclusive) throws java.io.IOException
Note, index based table traversal may not include all rows, as certain
types of indexes do not include all entries (namely, some indexes ignore
null entries, see Index.shouldIgnoreNulls()).
table - the table over which this cursor will traverseindex - index for the table which will define traversal order as
well as enhance certain lookupsstartRow - the first row of data for the cursor, or null for
the first entrystartInclusive - whether or not startRow is inclusive or exclusiveendRow - the last row of data for the cursor, or null for
the last entryendInclusive - whether or not endRow is inclusive or exclusivejava.io.IOExceptionprivate java.util.Set<java.lang.String> getIndexEntryPattern()
public IndexImpl getIndex()
getIndex in interface IndexCursorpublic Row findRowByEntry(java.lang.Object... entryValues) throws java.io.IOException
IndexCursorfindRowByEntry in interface IndexCursorentryValues - the column values for the index's columns.null if a match could not be found.java.io.IOExceptionpublic boolean findFirstRowByEntry(java.lang.Object... entryValues)
throws java.io.IOException
IndexCursorWarning, this method always starts searching from the beginning of the Table (you cannot use it to find successive matches).
findFirstRowByEntry in interface IndexCursorentryValues - the column values for the index's columns.true if a valid row was found with the given values,
false if no row was foundjava.io.IOExceptionpublic void findClosestRowByEntry(java.lang.Object... entryValues)
throws java.io.IOException
IndexCursorfindClosestRowByEntry in interface IndexCursorentryValues - the column values for the index's columns.java.io.IOExceptionpublic boolean currentRowMatchesEntry(java.lang.Object... entryValues)
throws java.io.IOException
IndexCursortrue if the current row matches the given index entries.currentRowMatchesEntry in interface IndexCursorentryValues - the column values for the index's columns.java.io.IOExceptionpublic EntryIterableBuilder newEntryIterable(java.lang.Object... entryValues)
IndexCursornewEntryIterable in interface IndexCursorentryValues - the column values for the index's columns.public java.util.Iterator<Row> entryIterator(EntryIterableBuilder iterBuilder)
protected IndexCursorImpl.IndexDirHandler getDirHandler(boolean moveForward)
CursorImplgetDirHandler in class CursorImplprotected boolean isUpToDate()
CursorImpltrue if this cursor is up-to-date with respect to the
relevant table and related table objects, false otherwise.isUpToDate in class CursorImplprotected void reset(boolean moveForward)
CursorImplreset in class CursorImplprotected void restorePositionImpl(CursorImpl.PositionImpl curPos, CursorImpl.PositionImpl prevPos) throws java.io.IOException
CursorImplrestorePositionImpl in class CursorImpljava.io.IOExceptionprotected CursorImpl.PositionImpl getRowPosition(RowIdImpl rowId) throws java.io.IOException
CursorImplgetRowPosition in class CursorImpljava.io.IOExceptionprotected boolean findAnotherRowImpl(ColumnImpl columnPattern, java.lang.Object valuePattern, boolean moveForward, ColumnMatcher columnMatcher, java.lang.Object searchInfo) throws java.io.IOException
CursorImplDefault implementation scans the table from beginning to end.
findAnotherRowImpl in class CursorImplcolumnPattern - column from the table for this cursor which is being
matched by the valuePatternvaluePattern - value which is equal to the corresponding value in
the matched rowtrue if a valid row was found with the given value,
false if no row was foundjava.io.IOExceptionprotected boolean findFirstRowByEntryImpl(java.lang.Object[] rowValues,
boolean requireMatch,
ColumnMatcher columnMatcher)
throws java.io.IOException
rowValues - the column values built from the index column valuesrequireMatch - whether or not an exact match is foundtrue if a valid row was found with the given values,
false if no row was foundjava.io.IOExceptionprotected boolean findAnotherRowImpl(java.util.Map<java.lang.String,?> rowPattern,
boolean moveForward,
ColumnMatcher columnMatcher,
java.lang.Object searchInfo)
throws java.io.IOException
CursorImplDefault implementation scans the table from beginning to end.
findAnotherRowImpl in class CursorImplrowPattern - column names and values which must be equal to the
corresponding values in the matched rowtrue if a valid row was found with the given values,
false if no row was foundjava.io.IOExceptionprivate boolean currentRowMatchesEntryImpl(java.lang.Object[] rowValues,
ColumnMatcher columnMatcher)
throws java.io.IOException
java.io.IOExceptionprivate boolean findPotentialRow(java.lang.Object[] rowValues,
boolean requireMatch)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.Object prepareSearchInfo(ColumnImpl columnPattern, java.lang.Object valuePattern)
CursorImplprepareSearchInfo in class CursorImplprotected java.lang.Object prepareSearchInfo(java.util.Map<java.lang.String,?> rowPattern)
CursorImplprepareSearchInfo in class CursorImplprotected boolean keepSearching(ColumnMatcher columnMatcher, java.lang.Object searchInfo) throws java.io.IOException
CursorImplkeepSearching in class CursorImpljava.io.IOExceptionprivate java.lang.Object[] toRowValues(java.lang.Object[] entryValues)
protected CursorImpl.PositionImpl findAnotherPosition(TableImpl.RowState rowState, CursorImpl.PositionImpl curPos, boolean moveForward) throws java.io.IOException
CursorImplfalse. If there are no more rows, the returned
rowId should equal the value returned by CursorImpl.getLastPosition() if
moving forward and CursorImpl.getFirstPosition() if moving backward.findAnotherPosition in class CursorImpljava.io.IOExceptionprotected ColumnMatcher getDefaultColumnMatcher()
CursorImplgetDefaultColumnMatcher in class CursorImpl