|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sleepycat.je.tree.Node
com.sleepycat.je.tree.IN
public class IN
An IN represents an Internal Node in the JE tree. Explanation of KD (KnownDeleted) and PD (PendingDelete) entry flags =================================================================== PD: set for all LN entries that are deleted, even before the LN is committed. Is used as an authoritative (transactionally correct) indication that an LN is deleted. PD will be cleared if the txn for the deleted LN is aborted. KD: set under special conditions for entries containing LNs which are known to be obsolete. Not used for entries in an active/uncommitted transaction. First notice that IN.fetchTarget will allow a FileNotFoundException when the PD or KD flag is set on the entry. And it will allow a NULL_LSN when the KD flag is set. KD was implemented first, and was originally used when the cleaner attempts to migrate an LN and discovers it is deleted (see Cleaner.migrateLN). We need KD because the INCompressor may not have run, and may not have compressed the BIN. There's the danger that we'll try to fetch that entry, and that the file was deleted by the cleaner. KD was used more recently when an unexpected exception occurs while logging an LN, after inserting the entry. Rather than delete the entry to clean up, we mark the entry KD so it won't cause a fetch error later. In this case the entry LSN is NULL_LSN. See Tree.insertNewSlot. PD is closely related to the first use of KD above (for cleaned deleted LNs) and came about because of a cleaner optimization we make. The cleaner considers all deleted LN log entries to be obsolete, without doing a tree lookup, and without any record of an obsolete offset. This makes the cost of cleaning of deleted LNs very low. For example, if the log looks like this: 100 LNA 200 delete of LNA then LSN 200 will be considered obsolete when this file is processed by the cleaner. After all, only two things can happen: (1) the txn commits, and we don't need LSN 200, because we can wipe this LN out of the tree, or (2) the txn aborts, and we don't need LSN 200, because we are going to revert to LSN 100/LNA. We set PD for the entry of a deleted LN at the time of the operation, and we clear PD if the transaction aborts. There is no real danger that this log entry will be processed by the cleaner before it's committed, because cleaning can only happen after the first active LSN. Just as in the first use of KD above, setting PD is necessary to avoid a fetch error, when the file is deleted by the cleaner but the entry containing the deleted LN has not been deleted by the INCompressor. PD is also set in replication rollback, when LNs are marked as invisible. When LSN locking was implemented (see CursorImpl.lockLN), the PD flag took on additional meaning. PD is used to determine whether an LN is deleted without fetching it, and therefore is relied on to be transactionally correct. In addition to the setting and use of the KD/PD flags described above, the situation is complicated by the fact that we must restore the state of these flags during abort, recovery, and set them properly during slot reuse. We have been meaning to consider whether PD and KD can be consolidated into one flag: simply the Deleted flag. The Deleted flag would be set in the same way as PD is currently set, as well as the second use of KD described above (when the LSN is NULL_LSN after an insertion error). The use of KD and PD for invisible entries and recovery rollback should also be considered. If we consolidate the two flags and set the Deleted flag during a delete operation (like PD), we'll have to remove optimizations (in CursorImpl for example) that consider a slot deleted when KD is set. Since KD is rarely set currently, this shouldn't have a noticeable performance impact.
Field Summary | |
---|---|
static int |
ACCUMULATED_LIMIT
|
static int |
BIN_LEVEL
|
(package private) DatabaseImpl |
databaseImpl
|
static int |
DBMAP_LEVEL
|
static int |
EXACT_MATCH
|
static int |
INSERT_SUCCESS
|
protected SharedLatch |
latch
|
static int |
LEVEL_MASK
|
static int |
MAIN_LEVEL
|
static int |
MAX_LEVEL
|
static int |
MAY_EVICT_LNS
|
static int |
MAY_EVICT_NODE
|
static int |
MAY_NOT_EVICT
|
static int |
MIN_LEVEL
|
Fields inherited from class com.sleepycat.je.tree.Node |
---|
NULL_NODE_ID |
Constructor Summary | |
---|---|
IN()
Create an empty IN, with no node ID, to be filled in from the log. |
|
IN(DatabaseImpl dbImpl,
byte[] identifierKey,
int capacity,
int level)
Create a new IN. |
|
IN(SizeofMarker marker)
For Sizeof, set all array fields to null, since they are not part of the fixed overhead. |
Method Summary | |
---|---|
(package private) void |
accountForDeferredWriteSubtreeRemoval(INList inList,
IN subtreeParent)
For a deferred-write DB, account for a deleted subtree. |
(package private) void |
accountForSubtreeRemoval(INList inList,
LocalUtilizationTracker localTracker)
For a regular (not deferred-write) DB, account for a deleted subtree. |
(package private) void |
accumulateStats(TreeWalkerStatsAccumulator acc)
|
(package private) void |
adjustCursors(IN newSibling,
int newSiblingLow,
int newSiblingHigh)
|
(package private) void |
adjustCursorsForInsert(int insertIndex)
|
void |
afterLog(LogManager logManager,
INLogItem item,
INLogContext context)
Post-log processing. |
(package private) void |
afterLogCommon(LogManager logManager,
INLogItem item,
INLogContext context,
long oldLsn,
long auxOldLsn)
Post-log processing shared by IN and BIN classes. |
void |
beforeLog(LogManager logManager,
INLogItem item,
INLogContext context)
Pre-log processing. |
(package private) void |
beforeLogCommon(INLogItem item,
INLogContext context,
long oldLsn,
long auxOldLsn)
Pre-log processing shared by IN and BIN classes. |
String |
beginTag()
|
(package private) void |
changeMemorySize(long delta)
|
(package private) void |
clearEntry(int idx)
|
(package private) void |
clearKnownDeleted(int idx)
Set knownDeleted to false. |
void |
clearLsnCompaction()
Mutates the compact LSN representation to the expanded representation. |
void |
clearPendingDeleted(int idx)
Set pendingDeleted to false. |
void |
compactMemory()
|
int |
compareTo(IN argIN)
Sort based on equality key. |
(package private) boolean |
compareToKeyPrefix(byte[] newKey)
|
long |
computeMemorySize()
Count up the memory usage attributable to this node alone. |
(package private) void |
copyEntries(int from,
int to,
int n)
|
(package private) void |
copyEntry(int idx,
IN from,
int fromIdx)
Set the idx'th entry of this node using the specified entry of another node. |
protected IN |
createNewInstance(byte[] identifierKey,
int maxEntries,
int level)
Create a new IN. |
(package private) boolean |
deleteEntry(byte[] key,
boolean maybeValidate)
Deletes the ChildReference with the key arg from this IN. |
boolean |
deleteEntry(int index,
boolean maybeValidate)
Deletes the ChildReference at index from this IN. |
(package private) static void |
dumpDeletedState(StringBuilder sb,
byte state)
Utility method for output of knownDeleted and pendingDelete. |
(package private) void |
dumpKeys()
|
void |
dumpLog(StringBuilder sb,
boolean verbose)
Write the object into the string buffer for log dumping. |
protected void |
dumpLogAdditional(StringBuilder sb)
Allows subclasses to add additional fields before the end tag. |
String |
dumpString(int nSpaces,
boolean dumpTags)
For unit test support: |
String |
endTag()
|
(package private) boolean |
entryZeroKeyComparesLow()
Indicates whether whether entry 0's key is "special" in that it always compares less than any other key. |
boolean |
equals(Object obj)
|
Node |
fetchTarget(int idx)
Returns the target of the idx'th entry or null if a pendingDeleted or knownDeleted entry has been cleaned. |
Node |
fetchTargetWithExclusiveLatch(int idx)
Variant of fetchTarget that is called while holding an exclusive latch and therefore does not throw RelatchRequiredException. |
int |
findEntry(byte[] key,
boolean indicateIfDuplicate,
boolean exact)
|
int |
findEntry(byte[] key,
boolean indicateIfDuplicate,
boolean exact,
Comparator<byte[]> searchComparator)
Find the entry in this IN for which key is LTE the key arg. |
(package private) void |
findParent(Tree.SearchType searchType,
long targetNodeId,
boolean targetIsRoot,
byte[] targetTreeKey,
SearchResult result,
boolean requireExactMatch,
CacheMode cacheMode,
int targetLevel,
boolean doFetch)
Determine if 'this' is the parent of a child IN (targetNodeId). |
long |
getBudgetedMemorySize()
Returns the amount of memory currently budgeted for this IN. |
(package private) int |
getChildEvictionType()
Returns the eviction type based on the status of child nodes, irrespective of isEvictionProhibited. |
protected int |
getCompactMaxKeyLength()
|
DatabaseImpl |
getDatabase()
Get the database for this IN. |
DatabaseId |
getDatabaseId()
|
boolean |
getDirty()
|
(package private) byte[] |
getEntryLsnByteArray()
|
(package private) long[] |
getEntryLsnLongArray()
|
int |
getEvictionType()
Returns the eviction type for this IN, for use by the evictor. |
protected long |
getFixedMemoryOverhead()
|
long |
getGeneration()
|
LogEntryType |
getGenericLogType()
Returns the generic LogEntryType for this node. |
byte[] |
getIdentifierKey()
|
boolean |
getInListResident()
Returns whether this IN is on the INList. |
long |
getInMemorySize()
For unit tests. |
byte[] |
getKey(int idx)
Return the idx'th key. |
Comparator<byte[]> |
getKeyComparator()
Convenience method to return the database key comparator. |
(package private) byte[] |
getKeyPrefix()
|
INKeyRep |
getKeyVals()
|
long |
getLastDeltaVersion()
Returns the last delta version LSN, or NULL_LSN if a delta was not last logged. |
long |
getLastFullVersion()
Returns the last full version LSN, or NULL_LSN if never logged. |
long |
getLastLoggedVersion()
Returns the last logged LSN, or NULL_LSN if never logged. |
int |
getLatchQueueLength()
|
String |
getLatchString()
|
int |
getLevel()
Cover for LN's and just return 0 since they'll always be at the bottom of the tree. |
int |
getLogSize()
|
LogEntryType |
getLogType()
Get the log type of this node. |
long |
getLsn(int idx)
Return the idx'th LSN for this entry. |
int |
getMaxEntries()
|
boolean |
getMigrate(int idx)
Get the idx'th migrate status. |
int |
getNEntries()
|
long |
getNodeId()
|
boolean |
getRecalcToggle()
|
byte |
getState(int idx)
|
Node |
getTarget(int idx)
Return the idx'th target. |
INArrayRep<INTargetRep,INTargetRep.Type,Node> |
getTargets()
|
long |
getTreeAdminMemorySize()
Returns the treeAdmin memory in objects referenced by this IN. |
int |
hashCode()
We would like as even a hash distribution as possible so that the Evictor's LRU is as accurate as possible. |
(package private) boolean |
hasPinnedChildren()
Returns whether any resident children are not LNs (are INs). |
(package private) boolean |
hasResidentChildren()
Returns whether any child is non-null. |
void |
incEvictStats(Evictor.EvictionSource source)
We categorize eviction stats by the type of IN, so IN subclasses update different stats. |
void |
incFetchStats(EnvironmentImpl envImpl,
boolean isMiss)
We categorize fetch stats by the type of node, so node subclasses update different stats. |
protected void |
init(DatabaseImpl db,
byte[] identifierKey,
int initialCapacity,
int level)
Initialize IN object. |
(package private) void |
initEntryLsn(int capacity)
|
protected void |
initMemorySize()
Initialize the per-node memory count by computing its memory usage. |
boolean |
insertEntry(ChildReference entry)
Inserts the argument ChildReference into this IN. |
int |
insertEntry1(ChildReference entry)
Same as insertEntry except that it returns the index where the dup was found instead of false. |
(package private) boolean |
isAlwaysLatchedExclusively()
|
boolean |
isDbRoot()
|
(package private) boolean |
isDirty(int idx)
|
boolean |
isEntryKnownDeleted(int idx)
|
boolean |
isEntryPendingDeleted(int idx)
|
boolean |
isEvictable()
Returns whether this node can be evicted. |
protected boolean |
isEvictionProhibited()
Returns whether the node is not evictable, irrespective of the status of the children nodes. |
boolean |
isIN()
|
boolean |
isKeyInBounds(byte[] keyVal)
Returns whether the given key is greater than or equal to the first key in the IN and less than or equal to the last key in the IN. |
boolean |
isLatchOwnerForRead()
|
boolean |
isLatchOwnerForWrite()
|
boolean |
isRoot()
|
(package private) static boolean |
isStateKnownDeleted(byte state)
Returns true if the given state is known deleted. |
(package private) static boolean |
isStatePendingDeleted(byte state)
Returns true if the given state is pending deleted. |
(package private) boolean |
isValidForDelete()
Check if this node fits the qualifications for being part of a deletable subtree. |
void |
latch()
Latch this node exclusive and set the generation. |
void |
latch(CacheMode cacheMode)
Latch this node exclusive, optionally setting the generation. |
boolean |
latchNoWait()
Latch this node if it is not latched by another thread, and set the generation if the latch succeeds. |
boolean |
latchNoWait(CacheMode cacheMode)
Latch this node if it is not latched by another thread, optionally setting the generation if the latch succeeds. |
void |
latchShared()
Latch this node shared and set the generation. |
void |
latchShared(CacheMode cacheMode)
Latch this node shared, optionally setting the generation. |
long |
log(LogManager logManager)
Log this IN and clear the dirty flag. |
long |
log(LogManager logManager,
boolean allowDeltas,
boolean allowCompress,
boolean isProvisional,
boolean backgroundIO,
IN parent)
Log this node with all available options. |
long |
log(LogManager logManager,
boolean allowDeltas,
boolean allowCompress,
Provisional provisional,
boolean backgroundIO,
IN parent)
|
void |
logDirtyChildren()
When splits and checkpoints intermingle in a deferred write databases, a checkpoint target may appear which has a valid target but a null LSN. |
boolean |
logicalEquals(Loggable other)
|
(package private) static String |
makeFetchErrorMsg(String msg,
IN in,
long lsn,
byte state)
|
boolean |
needsSplitting()
Return true if this node needs splitting. |
long |
optionalLog(LogManager logManager)
Log this IN and clear the dirty flag. |
long |
optionalLogProvisional(LogManager logManager,
IN parent)
Log this node provisionally and clear the dirty flag. |
void |
postFetchInit(DatabaseImpl db,
long lastLoggedLsn)
Initialize a node that has been read in from the log. |
void |
postRecoveryInit(DatabaseImpl db,
long lastLoggedLsn)
Initialize a node read in during recovery. |
void |
prepareForSlotReuse(int idx)
Called prior to changing a slot to contain a different logical node. |
protected long |
printMemorySize()
|
void |
readFromLog(ByteBuffer itemBuffer,
int entryVersion)
Initialize this object from the data in itemBuf. |
(package private) void |
rebuildINList(INList inList)
Add self and children to this in-memory IN list. |
void |
recalcKeyPrefix()
Forces computation of the key prefix, without requiring a split. |
void |
releaseLatch()
Release the latch on this node. |
void |
releaseLatchIfOwner()
Release the latch on this node. |
long |
resetAndGetMemorySize()
Called as part of a memory budget reset (during a checkpoint) to clear the accumulated delta and return the total memory size. |
void |
setDatabase(DatabaseImpl db)
Set the database reference for this node. |
void |
setDirty(boolean dirty)
|
void |
setGeneration(CacheMode cacheMode)
|
void |
setGeneration(long newGeneration)
|
void |
setIdentifierKey(byte[] key)
Set the identifier key for this node. |
void |
setInListResident(boolean resident)
Called when adding/removing this IN to/from the INList. |
(package private) void |
setIsRoot(boolean isRoot)
|
(package private) void |
setKeyPrefix(byte[] keyPrefix)
|
(package private) void |
setKnownDeleted(int idx)
Set knownDeleted to true. |
(package private) void |
setLastFullLsn(long lsn)
Sets the last full version LSN. |
(package private) void |
setLastLoggedLsn(long lsn)
Sets the last logged LSN, which for a BIN may be a delta. |
(package private) void |
setLsnElement(int idx,
long value)
|
void |
setMigrate(int idx,
boolean migrate)
Set the idx'th migrate status. |
(package private) void |
setNodeId(long nid)
|
void |
setPendingDeleted(int idx)
Set pendingDeleted to true. |
void |
setProhibitNextDelta()
Do nothing since INs don't support deltas. |
void |
setRecalcToggle(boolean toggle)
|
(package private) void |
setTarget(int idx,
Node target)
Sets the idx'th target. |
String |
shortClassName()
|
(package private) boolean |
shouldUpdateLsn(long oldLsn,
long newLsn)
For a deferred write database, ensure that information is not lost when a new LSN is assigned. |
(package private) void |
split(IN parent,
int childIndex,
int maxEntries,
CacheMode cacheMode)
Split this into two nodes. |
protected void |
splitInternal(IN parent,
int childIndex,
int maxEntries,
int splitIndex,
CacheMode cacheMode)
|
(package private) void |
splitSpecial(IN parent,
int parentIndex,
int maxEntriesPerNode,
byte[] key,
boolean leftSide,
CacheMode cacheMode)
Called when we know we are about to split on behalf of a key that is the minimum (leftSide) or maximum (!leftSide) of this node. |
String |
toString()
Default toString method at the root of the tree. |
(package private) void |
trackProvisionalObsolete(IN childIN,
long obsoleteLsn,
boolean isObsoleteLN,
int obsoleteSize)
Adds the given obsolete LSN and any tracked obsolete LSNs for the given child IN to this IN's tracking list. |
void |
updateEntry(int idx,
long lsn)
Update the idx'th entry of this node. |
void |
updateEntry(int idx,
long lsn,
byte state)
Update the idx'th entry of this node. |
void |
updateEntry(int idx,
Node node,
long lsn,
byte[] key)
Update the idx'th entry of this node. |
protected void |
updateMemorySize(long oldSize,
long newSize)
|
(package private) void |
updateMemorySize(Node oldNode,
Node newNode)
|
void |
updateNode(int idx,
long oldNodeSize,
long lsn,
byte[] lnSlotKey,
Node nodeForLnSlotKey)
Update the idx'th entry of this node. |
void |
updateNode(int idx,
Node node,
byte[] lnSlotKey)
Update the idx'th entry, replacing the node and, if appropriate, the LN slot key. |
void |
updateNode(int idx,
Node node,
long lsn,
byte[] lnSlotKey)
Update the idx'th entry, replacing the node and, if appropriate, the LN slot key. |
(package private) boolean |
validateSubtreeBeforeDelete(int index)
|
void |
verify(byte[] maxKey)
Check that the IN is in a valid state. |
(package private) boolean |
verifyKeyPrefix()
|
boolean |
verifyMemorySize()
|
void |
writeToLog(ByteBuffer logBuffer)
Serialize this object into the buffer. |
Methods inherited from class com.sleepycat.je.tree.Node |
---|
containsDuplicates, dump, getMemorySizeIncludedByParent, getTransactionId, getType, isBIN, isCompressible, isLN |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.sleepycat.je.log.Loggable |
---|
getTransactionId |
Field Detail |
---|
public static final int DBMAP_LEVEL
public static final int MAIN_LEVEL
public static final int LEVEL_MASK
public static final int MIN_LEVEL
public static final int MAX_LEVEL
public static final int BIN_LEVEL
public static final int MAY_NOT_EVICT
public static final int MAY_EVICT_LNS
public static final int MAY_EVICT_NODE
protected SharedLatch latch
DatabaseImpl databaseImpl
public static final int EXACT_MATCH
public static final int INSERT_SUCCESS
public static int ACCUMULATED_LIMIT
Constructor Detail |
---|
public IN()
public IN(DatabaseImpl dbImpl, byte[] identifierKey, int capacity, int level)
public IN(SizeofMarker marker)
Method Detail |
---|
protected void init(DatabaseImpl db, byte[] identifierKey, int initialCapacity, int level)
protected void initMemorySize()
public long getNodeId()
void setNodeId(long nid)
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(IN argIN)
compareTo
in interface Comparable<IN>
protected IN createNewInstance(byte[] identifierKey, int maxEntries, int level)
boolean isAlwaysLatchedExclusively()
public void postFetchInit(DatabaseImpl db, long lastLoggedLsn)
postFetchInit
in class Node
public void postRecoveryInit(DatabaseImpl db, long lastLoggedLsn)
void setLastLoggedLsn(long lsn)
public long getLastLoggedVersion()
void setLastFullLsn(long lsn)
public long getLastFullVersion()
public long getLastDeltaVersion()
public void latch(CacheMode cacheMode) throws DatabaseException
DatabaseException
public void latchShared(CacheMode cacheMode) throws DatabaseException
latchShared
in class Node
DatabaseException
- from subclasses.public boolean latchNoWait(CacheMode cacheMode) throws DatabaseException
DatabaseException
public void latch() throws DatabaseException
DatabaseException
public void latchShared() throws DatabaseException
latchShared
in class Node
DatabaseException
- from subclasses.public boolean latchNoWait() throws DatabaseException
DatabaseException
public String getLatchString()
public void releaseLatch()
releaseLatch
in class Node
public void releaseLatchIfOwner()
public boolean isLatchOwnerForRead()
public boolean isLatchOwnerForWrite()
public int getLatchQueueLength()
public long getGeneration()
public void setGeneration(CacheMode cacheMode)
public void setGeneration(long newGeneration)
public int getLevel()
Node
getLevel
in class Node
void setKeyPrefix(byte[] keyPrefix)
byte[] getKeyPrefix()
public boolean getDirty()
public void setDirty(boolean dirty)
public boolean getRecalcToggle()
public void setRecalcToggle(boolean toggle)
public boolean isRoot()
public boolean isDbRoot()
void setIsRoot(boolean isRoot)
public byte[] getIdentifierKey()
public void setIdentifierKey(byte[] key)
key
- - the new identifier key for this node.public DatabaseImpl getDatabase()
public void setDatabase(DatabaseImpl db)
public DatabaseId getDatabaseId()
void copyEntries(int from, int to, int n)
void clearEntry(int idx)
public byte[] getKey(int idx)
public void recalcKeyPrefix()
boolean compareToKeyPrefix(byte[] newKey)
boolean verifyKeyPrefix()
public boolean getMigrate(int idx)
public void setMigrate(int idx, boolean migrate)
public byte getState(int idx)
public Node getTarget(int idx)
void setTarget(int idx, Node target)
WARNING: This method does not update the memory budget. The caller must update the budget.
public long getLsn(int idx)
long[] getEntryLsnLongArray()
byte[] getEntryLsnByteArray()
void initEntryLsn(int capacity)
void setLsnElement(int idx, long value)
public void clearLsnCompaction()
public boolean isEntryPendingDeleted(int idx)
public void setPendingDeleted(int idx)
public void clearPendingDeleted(int idx)
public boolean isEntryKnownDeleted(int idx)
void setKnownDeleted(int idx)
void clearKnownDeleted(int idx)
boolean isDirty(int idx)
public int getNEntries()
static boolean isStateKnownDeleted(byte state)
static boolean isStatePendingDeleted(byte state)
public int getMaxEntries()
public final Node fetchTargetWithExclusiveLatch(int idx) throws DatabaseException
DatabaseException
public Node fetchTarget(int idx) throws RelatchRequiredException, DatabaseException
RelatchRequiredException
DatabaseException
static String makeFetchErrorMsg(String msg, IN in, long lsn, byte state)
void copyEntry(int idx, IN from, int fromIdx)
boolean shouldUpdateLsn(long oldLsn, long newLsn)
public void prepareForSlotReuse(int idx)
public void updateNode(int idx, long oldNodeSize, long lsn, byte[] lnSlotKey, Node nodeForLnSlotKey)
public void updateNode(int idx, Node node, byte[] lnSlotKey)
public void updateNode(int idx, Node node, long lsn, byte[] lnSlotKey)
public void updateEntry(int idx, Node node, long lsn, byte[] key)
public void updateEntry(int idx, long lsn)
public void updateEntry(int idx, long lsn, byte state)
public boolean verifyMemorySize()
public long getBudgetedMemorySize()
public long resetAndGetMemorySize()
public long getTreeAdminMemorySize()
public long getInMemorySize()
public INArrayRep<INTargetRep,INTargetRep.Type,Node> getTargets()
public INKeyRep getKeyVals()
public long computeMemorySize()
protected long printMemorySize()
protected long getFixedMemoryOverhead()
protected void updateMemorySize(long oldSize, long newSize)
public void compactMemory()
protected int getCompactMaxKeyLength()
void updateMemorySize(Node oldNode, Node newNode)
void changeMemorySize(long delta)
public void setInListResident(boolean resident)
public boolean getInListResident()
public boolean isKeyInBounds(byte[] keyVal)
public int findEntry(byte[] key, boolean indicateIfDuplicate, boolean exact)
public int findEntry(byte[] key, boolean indicateIfDuplicate, boolean exact, Comparator<byte[]> searchComparator)
key
- - the key to search for.indicateIfDuplicate
- - true if EXACT_MATCH should
be or'd onto the return value if key is already present in this node.exact
- - true if an exact match must be found.
public boolean insertEntry(ChildReference entry) throws DatabaseException
entry
- The ChildReference to insert into the IN.
EnvironmentFailureException
- if the node is full
(it should have been split earlier).
DatabaseException
public int insertEntry1(ChildReference entry)
entry
- The ChildReference to insert into the IN.
EnvironmentFailureException
- if the node is full (it should have
been split earlier).boolean deleteEntry(byte[] key, boolean maybeValidate) throws DatabaseException
key
- The key of the reference to delete from the IN.maybeValidate
- true if assert validation should occur prior to
delete. Set this to false during recovery.
DatabaseException
public boolean deleteEntry(int index, boolean maybeValidate) throws DatabaseException
index
- The index of the entry to delete from the IN.maybeValidate
- true if asserts are enabled.
DatabaseException
public void setProhibitNextDelta()
public boolean isIN()
isIN
in class Node
boolean validateSubtreeBeforeDelete(int index) throws DatabaseException
DatabaseException
public boolean needsSplitting()
boolean entryZeroKeyComparesLow()
void split(IN parent, int childIndex, int maxEntries, CacheMode cacheMode) throws DatabaseException
DatabaseException
protected void splitInternal(IN parent, int childIndex, int maxEntries, int splitIndex, CacheMode cacheMode) throws DatabaseException
DatabaseException
void splitSpecial(IN parent, int parentIndex, int maxEntriesPerNode, byte[] key, boolean leftSide, CacheMode cacheMode) throws DatabaseException
DatabaseException
void adjustCursors(IN newSibling, int newSiblingLow, int newSiblingHigh)
void adjustCursorsForInsert(int insertIndex)
public final Comparator<byte[]> getKeyComparator()
public void verify(byte[] maxKey) throws EnvironmentFailureException
verify
in class Node
EnvironmentFailureException
- when implemented.void rebuildINList(INList inList) throws DatabaseException
rebuildINList
in class Node
DatabaseException
void accountForSubtreeRemoval(INList inList, LocalUtilizationTracker localTracker) throws DatabaseException
Remove self and children from the in-memory IN list. Also count removed nodes as obsolete in the local tracker. The local tracker will be flushed by the compressor.
TODO: Note that we neglect to transfer any accumulated provisional obsolete info from the deleted INs to the tracker. See accountForDeferredWriteSubtreeRemoval for the case where this comes up. Ideally, in a future release we will record all obsolete info for regular as well as deferred-write DBs, including any accumulated provisional info, from the deleted INs to the subtree parent, as we do in accountForDeferredWriteSubtreeRemoval, and then rely on the logging of the subtree parent (for a regular DB) to flush that info. This was not done as part of SR [#21348] because logging the subtree parent does not flush the utilization info all the way to the log, while the compressor does flush the local tracker info all the way to the log. With further thought we may decide this change in behavior is acceptable, but it was too risky for a patch release. See the SR [#21348] for more details.
accountForSubtreeRemoval
in class Node
DatabaseException
void accountForDeferredWriteSubtreeRemoval(INList inList, IN subtreeParent) throws DatabaseException
Remove self and children from the in-memory IN list. Also count removed nodes as provisionally obsolete, recording this information in the parent of the subtree. When the root IN is logged non-provisionally by a checkpoint or Database.sync, the provisional obsolete info will be flushed to the log.
When removed nodes are counted obsolete, also transfer their accumulated provisional obsolete to the subtree parent. This accounts for the case where a subtree is removed in the middle of a checkpoint.
For example, say a two level subtree is removed, INa-BINb, and the grandparent, INc, is the subtree parent. Say a checkpoint logged BINb provisionally, but did not log INa (or INc). The provisional obsolete info for BINb will be present in INa. In this method, we transfer that info to INc, so it will be flushed when INc is logged non-provisionally.
accountForDeferredWriteSubtreeRemoval
in class Node
DatabaseException
boolean isValidForDelete() throws DatabaseException
isValidForDelete
in class Node
DatabaseException
void findParent(Tree.SearchType searchType, long targetNodeId, boolean targetIsRoot, byte[] targetTreeKey, SearchResult result, boolean requireExactMatch, CacheMode cacheMode, int targetLevel, boolean doFetch) throws RelatchRequiredException, DatabaseException
doFetch
- If true, fetch the child in the pursuit of this search.
If false, give up if the child is not resident. In that case, we have
a potential ancestor, but are not sure if this is the parent.
On return, if result.parent is non-null, then the IN that it refers to
will be latched. If an exception is thrown, then "this" is latched.
RelatchRequiredException
DatabaseException
public boolean isEvictable()
public int getEvictionType()
protected boolean isEvictionProhibited()
boolean hasPinnedChildren()
int getChildEvictionType()
final boolean hasResidentChildren()
void accumulateStats(TreeWalkerStatsAccumulator acc)
public void logDirtyChildren() throws DatabaseException
DatabaseException
public long log(LogManager logManager) throws DatabaseException
DatabaseException
public long log(LogManager logManager, boolean allowDeltas, boolean allowCompress, boolean isProvisional, boolean backgroundIO, IN parent) throws DatabaseException
DatabaseException
public long log(LogManager logManager, boolean allowDeltas, boolean allowCompress, Provisional provisional, boolean backgroundIO, IN parent) throws DatabaseException
DatabaseException
public long optionalLog(LogManager logManager) throws DatabaseException
DatabaseException
public long optionalLogProvisional(LogManager logManager, IN parent) throws DatabaseException
item
- object to be logged
DatabaseException
public void beforeLog(LogManager logManager, INLogItem item, INLogContext context)
void beforeLogCommon(INLogItem item, INLogContext context, long oldLsn, long auxOldLsn)
public void afterLog(LogManager logManager, INLogItem item, INLogContext context)
void afterLogCommon(LogManager logManager, INLogItem item, INLogContext context, long oldLsn, long auxOldLsn)
void trackProvisionalObsolete(IN childIN, long obsoleteLsn, boolean isObsoleteLN, int obsoleteSize)
public void incEvictStats(Evictor.EvictionSource source)
public void incFetchStats(EnvironmentImpl envImpl, boolean isMiss)
Node
incFetchStats
in class Node
Node.incFetchStats(com.sleepycat.je.dbi.EnvironmentImpl, boolean)
public LogEntryType getGenericLogType()
Node
getGenericLogType
in class Node
Node.getGenericLogType()
public LogEntryType getLogType()
public int getLogSize()
getLogSize
in interface Loggable
getLogSize
in class Node
Loggable.getLogSize()
public void writeToLog(ByteBuffer logBuffer)
Loggable
writeToLog
in interface Loggable
writeToLog
in class Node
logBuffer
- is the destination bufferLoggable.writeToLog(java.nio.ByteBuffer)
public void readFromLog(ByteBuffer itemBuffer, int entryVersion)
Loggable
readFromLog
in interface Loggable
readFromLog
in class Node
Loggable.readFromLog(java.nio.ByteBuffer, int)
public void dumpLog(StringBuilder sb, boolean verbose)
Loggable
dumpLog
in interface Loggable
dumpLog
in class Node
sb
- destination string bufferverbose
- if true, dump the full, verbose versionLoggable.dumpLog(java.lang.StringBuilder, boolean)
public boolean logicalEquals(Loggable other)
logicalEquals
in interface Loggable
Always return false, this item should never be compared.
protected void dumpLogAdditional(StringBuilder sb)
public String beginTag()
public String endTag()
void dumpKeys()
public String dumpString(int nSpaces, boolean dumpTags)
dumpString
in class Node
static void dumpDeletedState(StringBuilder sb, byte state)
public String toString()
Node
toString
in class Node
public String shortClassName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |