| Modifier and Type | Class and Description |
|---|---|
static class |
CursorImpl.LockStanding
Holds the result of a lockLN operation.
|
static interface |
CursorImpl.WithCursor
Callback object for traverseDbWithCursor.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
EXACT_KEY |
static int |
FOUND |
static int |
FOUND_LAST |
| Constructor and Description |
|---|
CursorImpl(DatabaseImpl database,
Locker locker)
Creates a cursor with retainNonTxnLocks=true, isSecondaryCursor=false.
|
CursorImpl(DatabaseImpl dbImpl,
Locker locker,
boolean retainNonTxnLocks,
boolean isSecondaryCursor)
Creates a cursor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
advanceCursor(DatabaseEntry key,
DatabaseEntry data)
Advance a cursor.
|
void |
afterNonStickyOp()
For a non-sticky cursor, this method is called after a successful
operation.
|
void |
assertBIN(BIN bin) |
void |
beforeNonStickyOp()
For a non-sticky cursor, this method is called when the cursor is
initialized and an advancing operation (next/prev/skip) is about to be
performed.
|
void |
checkCursorState(boolean mustBeInitialized,
boolean mustNotBeInitialized)
Check that the cursor is open and optionally if it is initialized or
uninitialized.
|
void |
checkEnv() |
boolean |
checkForInsertion(GetMode getMode,
CursorImpl dupCursor)
Used to detect phantoms during "get next" operations with serializable
isolation.
|
void |
clearClosingLocker()
Called when a cursor move operation is complete.
|
CursorImpl |
cloneCursor(boolean samePosition)
Performs a shallow copy and returns the new cursor.
|
void |
close() |
void |
close(CursorImpl newCursor)
Close a cursor.
|
void |
criticalEviction() |
OperationResult |
deleteCurrentRecord(ReplicationContext repContext)
Delete the item pointed to by the cursor.
|
void |
dump()
dump the cursor for debugging purposes.
|
void |
dump(boolean verbose)
Dump the cursor for debugging purposes.
|
String |
dumpToString(boolean verbose) |
void |
evictLN()
Evict the LN node at the cursor position.
|
List<TrackingInfo> |
getAncestorPath()
Returns the stack of ancestor TrackingInfo for the BIN at the cursor, or
null if a split occurs and the information returned would be
inconsistent.
|
BIN |
getBIN() |
CacheMode |
getCacheMode() |
OperationResult |
getCurrent(DatabaseEntry foundKey,
DatabaseEntry foundData)
Copy current record into the key and data DatabaseEntry.
|
byte[] |
getCurrentKey() |
byte[] |
getCurrentKey(boolean isLatched)
Returns the key at the current position, regardless of whether the
record is defunct.
|
LN |
getCurrentLN(boolean isLatched,
boolean unlatch) |
long |
getCurrentLsn() |
static long |
getCurrentLsn(CursorImpl cursor) |
long |
getCurrentNodeId()
Called for creating trace messages without any latching.
|
RecordVersion |
getCurrentVersion(boolean allowFetch)
Returns the VLSN and LSN for the record at the current position.
|
DatabaseImpl |
getDb() |
long |
getExpirationTime() |
int |
getIndex() |
Locker |
getLocker() |
StatGroup |
getLockStats() |
OperationResult |
getNext(DatabaseEntry foundKey,
DatabaseEntry foundData,
LockType lockType,
boolean dirtyReadAll,
boolean forward,
boolean isLatched,
RangeConstraint rangeConstraint)
Move the cursor forward and return the next "valid" record.
|
int |
getNSecondaryWrites()
Returns the number of secondary records written by the last put/delete
operation at the current cursor position.
|
int |
getStorageSize()
Returns the estimated disk storage size for the record at the current
position.
|
boolean |
hasDuplicates() |
int |
hashCode() |
void |
incrementLNCount() |
OperationResult |
insertOrUpdateRecord(DatabaseEntry key,
DatabaseEntry data,
LN ln,
ExpirationInfo expInfo,
PutMode putMode,
DatabaseEntry returnOldData,
DatabaseEntry returnNewData,
ReplicationContext repContext)
Insert or update a given record.
|
boolean |
insertRecord(byte[] key,
LN ln,
boolean blindInsertion,
ReplicationContext repContext)
Insert the given record (key + LN) in the tree or return false if the
key is already present.
|
boolean |
isClosed() |
boolean |
isInternalDbCursor() |
boolean |
isNotInitialized() |
boolean |
isOnBIN(BIN bin) |
boolean |
isOnSamePosition(CursorImpl other) |
boolean |
isProbablyExpired() |
void |
latchBIN() |
static void |
lockAfterLsnChange(DatabaseImpl dbImpl,
long oldLsn,
long newLsn,
Locker excludeLocker)
After logging a deferred-write LN during eviction/checkpoint or a
migrated LN during cleaning, for every existing lock on the old LSN held
by another locker, we must lock the new LSN on behalf of that locker.
|
OperationResult |
lockAndGetCurrent(DatabaseEntry foundKey,
DatabaseEntry foundData,
LockType lockType)
Lock and copy current record into the key and data DatabaseEntry.
|
OperationResult |
lockAndGetCurrent(DatabaseEntry foundKey,
DatabaseEntry foundData,
LockType lockType,
boolean dirtyReadAll,
boolean isLatched,
boolean unlatch)
Let S be the slot where this cursor is currently positioned on.
|
LN |
lockAndGetCurrentLN(LockType lockType)
Retrieve the current LN.
|
void |
lockEof(LockType lockType)
Locks the logical EOF node for the dbImpl.
|
CursorImpl.LockStanding |
lockLN(LockType lockType)
Does not allow uncontended locks.
|
void |
lockNextKeyForInsert(DatabaseEntry key)
Search for the next key following the given key, and acquire a range
insert lock on it.
|
boolean |
positionFirstOrLast(boolean first)
Position the cursor at the first or last record of the dbImpl.
|
void |
releaseBIN() |
void |
reset()
Reset a cursor to an uninitialized state, but unlike close(), allow it
to be used further.
|
void |
revertLock(CursorImpl.LockStanding standing) |
boolean |
searchExact(DatabaseEntry searchKey,
LockType lockType) |
CursorImpl.LockStanding |
searchExact(DatabaseEntry searchKey,
LockType lockType,
boolean dirtyReadAll,
boolean dataRequested)
Position this cursor on the slot (if any) whose key matches the given
search key.
|
int |
searchRange(DatabaseEntry searchKey,
Comparator<byte[]> comparator)
Position this cursor on the slot whose key is the max key less or equal
to the given search key.
|
void |
setAllowEviction(boolean allowed)
Disables or enables eviction during cursor operations.
|
void |
setBIN(BIN newBin) |
void |
setCacheMode(CacheMode mode)
Sets the effective cache mode to use for the next operation.
|
void |
setClosingLocker(CursorImpl closingCursor)
Called when a cursor has been duplicated prior to being moved.
|
void |
setIndex(int idx) |
void |
setNSecondaryWrites(int nWrites) |
void |
setOnFirstSlot() |
void |
setOnLastSlot() |
void |
setPriInfo(CursorImpl sourceCursor)
When the primary record is read during a secondary operation, this
method is called to copy the primary version and storage size here.
|
void |
setTestHook(TestHook hook) |
void |
setTreeStatsAccumulator(TreeWalkerStatsAccumulator tSA) |
long |
skip(boolean forward,
long maxCount,
RangeConstraint rangeConstraint)
Skips over entries until a boundary condition is satisfied, either
because maxCount is reached or RangeConstraint.inBounds returns false.
|
static void |
traverseDbWithCursor(DatabaseImpl db,
LockType lockType,
boolean allowEviction,
CursorImpl.WithCursor withCursor)
Enumerates all records in a dbImpl non-transactionally and calls
the withCursor method for each record.
|
OperationResult |
updateCurrentRecord(DatabaseEntry key,
DatabaseEntry data,
ExpirationInfo expInfo,
DatabaseEntry returnOldData,
DatabaseEntry returnNewData,
ReplicationContext repContext)
Modify the current record with the given data, and optionally replace
the key.
|
public static final int FOUND
public static final int EXACT_KEY
public static final int FOUND_LAST
public CursorImpl(DatabaseImpl database, Locker locker)
public CursorImpl(DatabaseImpl dbImpl, Locker locker, boolean retainNonTxnLocks, boolean isSecondaryCursor)
retainNonTxnLocks - is true if non-transactional locks should be
retained (not released automatically) when the cursor is reset or
closed.isSecondaryCursor - whether to treat this cursor as a secondary
cursor, e.g., secondary records don't have record versions.public CursorImpl cloneCursor(boolean samePosition)
samePosition - If true, this cursor's position is used for the new
cursor, and addCursor is called on the new cursor to register it with
the current BIN. If false, the new cursor will be uninitialized.public Locker getLocker()
public DatabaseImpl getDb()
public void setClosingLocker(CursorImpl closingCursor)
closingCursor - the old cursor that will be closed if the new
cursor is moved successfully.public void clearClosingLocker()
public CacheMode getCacheMode()
public void setCacheMode(CacheMode mode)
public void setTreeStatsAccumulator(TreeWalkerStatsAccumulator tSA)
public void incrementLNCount()
public int getIndex()
public BIN getBIN()
public void setIndex(int idx)
public void setOnFirstSlot()
public void setOnLastSlot()
public boolean isOnBIN(BIN bin)
public void assertBIN(BIN bin)
public boolean isOnSamePosition(CursorImpl other)
public void setBIN(BIN newBin)
public void latchBIN()
public void releaseBIN()
public long getCurrentNodeId()
public static long getCurrentLsn(CursorImpl cursor)
public long getCurrentLsn()
public byte[] getCurrentKey()
public byte[] getCurrentKey(boolean isLatched)
public boolean isProbablyExpired()
public long getExpirationTime()
public boolean isClosed()
public boolean isNotInitialized()
public boolean isInternalDbCursor()
public boolean hasDuplicates()
public void beforeNonStickyOp()
public void afterNonStickyOp()
public void reset()
public void close()
public void close(CursorImpl newCursor)
newCursor - is another cursor that is kept open by the parent
Cursor object, or null if no other cursor is kept open.public void setAllowEviction(boolean allowed)
public void criticalEviction()
public void evictLN()
public OperationResult deleteCurrentRecord(ReplicationContext repContext)
public OperationResult updateCurrentRecord(DatabaseEntry key, DatabaseEntry data, ExpirationInfo expInfo, DatabaseEntry returnOldData, DatabaseEntry returnNewData, ReplicationContext repContext)
key - The new key value for the BIN slot S to be updated. Cannot
be partial. For a no-dups DB, it is null. For dups DBs it is a 2-part
key combining the current primary key of slot S with the original,
user-provided data. "key" (if not null) must compare equal to S.key
(otherwise DuplicateDataException is thrown), but the 2 keys may not
be identical if custom comparators are used. So, S.key will actually
be replaced by "key".data - The new data to (perhaps partially) replace the data of the
LN associated with the BIN slot. For dups DBs it is EMPTY_DUPS_DATA.
Note: for dups DBs the original, user-provided "data" must not be
partial.returnOldData - To receive the old LN data (before the update).
It is needed only by DBs with indexes/triggers; will be null otherwise.returnNewData - To receive the full data of the updated LN.
It is needed only by DBs with indexes/triggers and only if "data" is
partial; will be null otherwise. Note: "returnNewData" may be different
than "data" only if "data" is partial.public boolean insertRecord(byte[] key,
LN ln,
boolean blindInsertion,
ReplicationContext repContext)
public OperationResult insertOrUpdateRecord(DatabaseEntry key, DatabaseEntry data, LN ln, ExpirationInfo expInfo, PutMode putMode, DatabaseEntry returnOldData, DatabaseEntry returnNewData, ReplicationContext repContext)
key - The new key value for the BIN slot S to be inserted/updated.
Cannot be partial. For dups DBs it is a 2-part key combining the
original, user-provided key and data. In case of update, "key" must
compare equal to S.key (otherwise DuplicateDataException is thrown),
but the 2 keys may not be identical if custom comparators are used.
So, S.key will actually be replaced by "key".data - In case of update, the new data to (perhaps partially)
replace the data of the LN associated with the BIN slot. For dups DBs
it is EMPTY_DUPS_DATA. Note: for dups DBs the original, user-provided
"data" must not be partial.ln - is normally a new LN node that is created for insertion, and
will be discarded if an update occurs. However, HA will pass an
existing node.putMode - OVERWRITE or NO_OVERWRITEreturnOldData - To receive, in case of update, the old LN data
(before the update). It is needed only by DBs with indexes/triggers;
will be null otherwise.returnNewData - To receive the full data of the new or updated LN.
It is needed only by DBs with indexes/triggers and only if "data" is
partial; will be null otherwise. Note: "returnNewData" may be different
than "data" only if "data" is partial.public boolean positionFirstOrLast(boolean first)
public int searchRange(DatabaseEntry searchKey, Comparator<byte[]> comparator)
public boolean searchExact(DatabaseEntry searchKey, LockType lockType)
public CursorImpl.LockStanding searchExact(DatabaseEntry searchKey, LockType lockType, boolean dirtyReadAll, boolean dataRequested)
public OperationResult lockAndGetCurrent(DatabaseEntry foundKey, DatabaseEntry foundData, LockType lockType)
public OperationResult lockAndGetCurrent(DatabaseEntry foundKey, DatabaseEntry foundData, LockType lockType, boolean dirtyReadAll, boolean isLatched, boolean unlatch)
lockLNAndCheckDefunct(com.sleepycat.je.txn.LockType, boolean, boolean).
On entry, the isLatched param says whether this.bin is latched or not.
On return, this.bin is unlatched if the unlatch param is true or an
exception is thrown.public OperationResult getCurrent(DatabaseEntry foundKey, DatabaseEntry foundData)
public LN getCurrentLN(boolean isLatched, boolean unlatch)
public LN lockAndGetCurrentLN(LockType lockType)
public RecordVersion getCurrentVersion(boolean allowFetch)
allowFetch - is true to fetch the LN to get the VLSN, or false to
return -1 for the VLSN if both the LN and VLSN are not cached.IllegalStateException - if the cursor is closed or uninitialized,
or this is a secondary cursor and the version is not cached.public int getStorageSize()
This method does not fetch the LN. Must be called when the cursor is positioned on a record.
When called on a secondary cursor that was used to return the primary data, the size of the primary record is returned by this method. Otherwise the size of the record at this cursor position is returned.
IllegalStateException - if the cursor is closed or uninitialized.StorageSizepublic void setPriInfo(CursorImpl sourceCursor)
sourceCursor - contains the primary info, but may be a primary or
secondary cursor.public int getNSecondaryWrites()
public void setNSecondaryWrites(int nWrites)
public boolean advanceCursor(DatabaseEntry key, DatabaseEntry data)
key - on return contains the key if available, or null.data - on return contains the data if available, or null.public OperationResult getNext(DatabaseEntry foundKey, DatabaseEntry foundData, LockType lockType, boolean dirtyReadAll, boolean forward, boolean isLatched, RangeConstraint rangeConstraint)
foundKey - DatabaseEntry to use for returning keyfoundData - DatabaseEntry to use for returning dataforward - if true, move forward, else move backwardsisLatched - if true, the bin that we're on is already
latched.rangeConstraint - if non-null, is called to determine whether a key
is out of range.public boolean checkForInsertion(GetMode getMode, CursorImpl dupCursor)
public long skip(boolean forward,
long maxCount,
RangeConstraint rangeConstraint)
forward - is true to skip forward, false to skip backward.maxCount - is the maximum number of non-defunct entries to skip,
and may be LTE zero if no maximum is enforced.rangeConstraint - is a predicate that returns false at a position
where advancement should stop, or null if no predicate is enforced.public List<TrackingInfo> getAncestorPath()
public void lockNextKeyForInsert(DatabaseEntry key)
public CursorImpl.LockStanding lockLN(LockType lockType) throws LockConflictException
LockConflictExceptionpublic static void lockAfterLsnChange(DatabaseImpl dbImpl, long oldLsn, long newLsn, Locker excludeLocker)
public void checkCursorState(boolean mustBeInitialized,
boolean mustNotBeInitialized)
IllegalStateException - via all Cursor methods that call
Cursor.checkState (all get and put methods, plus more).public void revertLock(CursorImpl.LockStanding standing)
public void lockEof(LockType lockType)
public void checkEnv()
EnvironmentFailureException - if the underlying environment is
invalid.public static void traverseDbWithCursor(DatabaseImpl db, LockType lockType, boolean allowEviction, CursorImpl.WithCursor withCursor)
db - DatabaseImpl to traverse.lockType - non-null LockType for reading records.allowEviction - should normally be true to evict when performing
multiple operations, but may be false if eviction is disallowed in a
particular context.withCursor - callback object.public void dump(boolean verbose)
public void dump()
public String dumpToString(boolean verbose)
public StatGroup getLockStats()
public void setTestHook(TestHook hook)
Copyright © 2024. All rights reserved.