|
|||||||||
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.
Field Summary | |
---|---|
static int |
ACCUMULATED_LIMIT
|
static int |
DBMAP_LEVEL
|
static int |
EXACT_MATCH
|
static int |
INSERT_SUCCESS
|
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
|
Constructor Summary | |
---|---|
IN()
Create an empty IN, with no node id, to be filled in from the log. |
|
IN(DatabaseImpl db,
byte[] identifierKey,
int capacity,
int level)
Create a new IN. |
Method Summary | |
---|---|
(package private) void |
accountForSubtreeRemoval(INList inList,
UtilizationTracker tracker)
Remove self and children from the in-memory IN list. |
(package private) void |
accumulateStats(TreeWalkerStatsAccumulator acc)
|
(package private) void |
adjustCursors(IN newSibling,
int newSiblingLow,
int newSiblingHigh)
|
(package private) void |
adjustCursorsForInsert(int insertIndex)
|
String |
beginTag()
|
protected boolean |
canBeAncestor(boolean targetContainsDuplicates)
|
(package private) void |
clearKnownDeleted(int idx)
Set knownDeleted to false. |
void |
clearPendingDeleted(int idx)
Set pendingDeleted to false. |
int |
compareTo(Object o)
Sort based on node id. |
boolean |
compress(BINReference binRef,
boolean canFetch)
|
protected static long |
computeArraysOverhead(DbConfigManager configManager)
|
protected long |
computeMemorySize()
Count up the memory usage attributable to this node alone. |
static long |
computeOverhead(DbConfigManager configManager)
|
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. |
protected void |
descendOnParentSearch(SearchResult result,
boolean targetContainsDuplicates,
boolean targetIsRoot,
long targetNodeId,
Node child,
boolean requireExactMatch)
|
(package private) static void |
dumpDeletedState(StringBuffer sb,
byte state)
Utility method for output of knownDeleted and pendingDelete. |
(package private) void |
dumpKeys()
|
void |
dumpLog(StringBuffer sb,
boolean verbose)
Write the object into the string buffer for log dumping. |
protected void |
dumpLogAdditional(StringBuffer 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. |
int |
findEntry(byte[] key,
boolean indicateIfDuplicate,
boolean exact)
Find the entry in this IN for which key arg is >= the key. |
(package private) void |
findParent(Tree.SearchType searchType,
long targetNodeId,
boolean targetContainsDuplicates,
boolean targetIsRoot,
byte[] targetMainTreeKey,
byte[] targetDupTreeKey,
SearchResult result,
boolean requireExactMatch,
boolean updateGeneration,
int targetLevel,
List trackingList,
boolean doFetch)
See if you are the parent of this child. |
(package private) void |
flushProvisionalObsolete(LogManager logManager)
Adds the provisional obsolete tracking information in this node to the live tracker. |
protected int |
generateLevel(DatabaseId dbId,
int newLevel)
|
int |
getAccumulatedDelta()
|
(package private) int |
getChildEvictionType()
Returns the eviction type based on the status of child nodes, irrespective of isEvictionProhibited. |
byte[] |
getChildKey(IN child)
Get the key (dupe or identifier) in child that is used to locate it in 'this' node. |
DatabaseImpl |
getDatabase()
Get the database for this IN. |
DatabaseId |
getDatabaseId()
|
boolean |
getDirty()
|
byte[] |
getDupKey()
Return the key for this duplicate set. |
byte[] |
getDupTreeKey()
Return the key for navigating through the duplicate tree. |
protected long |
getEntryInMemorySize(byte[] key,
Node target)
|
(package private) byte[] |
getEntryLsnByteArray()
|
(package private) long[] |
getEntryLsnLongArray()
|
int |
getEvictionType()
Returns the eviction type for this IN, for use by the evictor. |
long |
getGeneration()
|
byte[] |
getIdentifierKey()
|
long |
getInMemorySize()
Return the number of bytes used by this IN. |
byte[] |
getKey(int idx)
Return the idx'th key. |
Comparator |
getKeyComparator()
Return the relevant user defined comparison function for this type of node. |
long |
getLastFullVersion()
Returns the last logged LSN, or null if never logged. |
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()
All objects that are reponsible for a generating a type of log entry must implement this. |
long |
getLsn(int idx)
Return the idx'th LSN for this entry. |
byte[] |
getMainTreeKey()
Return the key for navigating through the main tree. |
(package private) int |
getMaxEntries()
|
protected long |
getMemoryOverhead(MemoryBudget mb)
|
boolean |
getMigrate(int idx)
Get the idx'th migrate status. |
int |
getNEntries()
|
byte |
getState(int idx)
|
Node |
getTarget(int idx)
Return the idx'th target. |
long |
getTransactionId()
|
int |
hashCode()
|
(package private) boolean |
hasNonLNChildren()
Returns whether any resident children are not LNs (are INs). |
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. |
boolean |
isCompressible()
|
boolean |
isDbRoot()
|
(package private) boolean |
isDirty(int idx)
|
boolean |
isEntryKnownDeleted(int idx)
|
boolean |
isEntryPendingDeleted(int idx)
|
boolean |
isEvictable()
Returns whether this node can itself be evicted. |
(package private) boolean |
isEvictionProhibited()
Returns whether the node is not evictable, irrespective of the status of the children nodes. |
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 |
isLatchOwner()
|
boolean |
isRoot()
|
protected boolean |
isSoughtNode(long nid,
boolean updateGeneration)
|
(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 known deleted. |
(package private) boolean |
isValidForDelete()
Check if this node fits the qualifications for being part of a deletable subtree. |
void |
latch()
Latch this node and set the generation. |
void |
latch(boolean updateGeneration)
Latch this node, 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(boolean updateGeneration)
Latch this node if it is not latched by another thread, optionally setting the generation if the latch succeeds. |
long |
log(LogManager logManager)
Log this IN and clear the dirty flag. |
long |
log(LogManager logManager,
boolean allowDeltas,
boolean allowMigration)
Log this IN and clear the dirty flag. |
long |
log(LogManager logManager,
boolean allowDeltas,
boolean isProvisional,
boolean allowMigration,
IN parent)
Log this node with all available options. |
boolean |
logEntryIsTransactional()
|
protected long |
logInternal(LogManager logManager,
boolean allowDeltas,
boolean isProvisional,
boolean allowMigration,
IN parent)
Decide how to log this node. |
long |
logProvisional(LogManager logManager,
IN parent)
Log this node provisionally and clear the dirty flag. |
(package private) static String |
makeFetchErrorMsg(String msg,
IN in,
long lsn,
byte state)
|
boolean |
needsSplitting()
Return true if this node needs splitting. |
void |
postFetchInit(DatabaseImpl db,
long sourceLsn)
Initialize a node that has been read in from the log. |
void |
postRecoveryInit(DatabaseImpl db,
long sourceLsn)
Initialize a node read in during recovery. |
void |
readFromLog(ByteBuffer itemBuffer,
byte entryTypeVersion)
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 |
releaseLatch()
Release the latch on this node. |
void |
releaseLatchIfOwner()
Release the latch on this node. |
byte[] |
selectKey(byte[] mainTreeKey,
byte[] dupTreeKey)
|
void |
setCleanedSinceLastLog()
Do nothing since INs don't support deltas. |
protected void |
setCompressedSinceLastLog()
Do nothing since INs don't support deltas. |
void |
setDatabase(DatabaseImpl db)
Set the database reference for this node. |
void |
setDirty(boolean dirty)
|
void |
setEntry(int idx,
Node target,
byte[] keyVal,
long lsn,
byte state)
Set the idx'th entry of this node. |
void |
setGeneration()
|
void |
setGeneration(long newGeneration)
|
(package private) void |
setIdentifierKey(byte[] key)
Set the identifier key for this node. |
void |
setInListResident(boolean resident)
|
(package private) void |
setIsRoot(boolean isRoot)
|
(package private) void |
setKnownDeleted(int idx)
Set knownDeleted to true. |
(package private) void |
setLastFullLsn(long lsn)
Sets the last logged LSN. |
void |
setLsn(int idx,
long lsn)
Sets the idx'th target LSN. |
(package private) void |
setLsnElement(int idx,
long value)
|
void |
setMigrate(int idx,
boolean migrate)
Set the idx'th migrate status. |
void |
setPendingDeleted(int idx)
Set pendingDeleted to true. |
(package private) void |
setTarget(int idx,
Node target)
Sets the idx'th target. |
String |
shortClassName()
|
(package private) void |
split(IN parent,
int childIndex,
int maxEntries)
Split this into two nodes. |
protected void |
splitInternal(IN parent,
int childIndex,
int maxEntries,
int splitIndex)
|
(package private) void |
splitSpecial(IN parent,
int parentIndex,
int maxEntriesPerNode,
byte[] key,
boolean leftSide)
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 child,
long obsoleteLsn1,
long obsoleteLsn2)
Adds the given obsolete LSNs 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,
long lsn,
long oldLNSize,
long newLNSize)
Update the idx'th entry of this node. |
void |
updateEntry(int idx,
Node node)
Update the idx'th entry of this node. |
void |
updateEntry(int idx,
Node node,
long lsn)
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(ChildReference oldRef,
ChildReference newRef)
|
protected void |
updateMemorySize(long oldSize,
long newSize)
|
(package private) void |
updateMemorySize(Node oldNode,
Node newNode)
|
(package private) boolean |
validateSubtreeBeforeDelete(int index)
|
void |
verify(byte[] maxKey)
Check that the IN is in a valid state. |
boolean |
verifyMemorySize()
|
void |
writeToLog(ByteBuffer logBuffer)
Serialize this object into the buffer. |
Methods inherited from class com.sleepycat.je.tree.Node |
---|
containsDuplicates, countAsObsoleteWhenLogged, dump, getLastId, getMemorySizeIncludedByParent, getNextNodeId, getNodeId, getType, marshallOutsideWriteLatch, matchLNByNodeId, postLogWork, setLastNodeId, setNodeId, shortDescription |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.sleepycat.je.log.LoggableObject |
---|
countAsObsoleteWhenLogged, marshallOutsideWriteLatch, postLogWork |
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 MAY_NOT_EVICT
public static final int MAY_EVICT_LNS
public static final int MAY_EVICT_NODE
public static final int EXACT_MATCH
public static final int INSERT_SUCCESS
public static int ACCUMULATED_LIMIT
Constructor Detail |
---|
public IN()
public IN(DatabaseImpl db, byte[] identifierKey, int capacity, int level)
Method Detail |
---|
protected void init(DatabaseImpl db, byte[] identifierKey, int initialCapacity, int level)
protected void initMemorySize()
public boolean equals(Object obj)
equals
in class Object
public int hashCode()
hashCode
in class Object
public int compareTo(Object o)
compareTo
in interface Comparable
protected IN createNewInstance(byte[] identifierKey, int maxEntries, int level)
public void postFetchInit(DatabaseImpl db, long sourceLsn) throws DatabaseException
postFetchInit
in class Node
DatabaseException
public void postRecoveryInit(DatabaseImpl db, long sourceLsn)
void setLastFullLsn(long lsn)
public long getLastFullVersion()
public void latch(boolean updateGeneration) throws DatabaseException
DatabaseException
public boolean latchNoWait(boolean updateGeneration) throws DatabaseException
DatabaseException
public void latch() throws DatabaseException
DatabaseException
public boolean latchNoWait() throws DatabaseException
DatabaseException
public void releaseLatch() throws LatchNotHeldException
LatchNotHeldException
public void releaseLatchIfOwner() throws LatchNotHeldException
LatchNotHeldException
public boolean isLatchOwner()
public long getGeneration()
public void setGeneration()
public void setGeneration(long newGeneration)
public int getLevel()
Node
getLevel
in class Node
protected int generateLevel(DatabaseId dbId, int newLevel)
public boolean getDirty()
public void setDirty(boolean dirty)
public boolean isRoot()
public boolean isDbRoot()
void setIsRoot(boolean isRoot)
public byte[] getIdentifierKey()
void setIdentifierKey(byte[] key)
key
- - the new identifier key for this node.public byte[] getChildKey(IN child) throws DatabaseException
DatabaseException
public byte[] selectKey(byte[] mainTreeKey, byte[] dupTreeKey)
public byte[] getDupKey() throws DatabaseException
DatabaseException
public byte[] getDupTreeKey()
public byte[] getMainTreeKey()
public DatabaseImpl getDatabase()
public void setDatabase(DatabaseImpl db)
public DatabaseId getDatabaseId()
public byte[] getKey(int idx)
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)
public void setLsn(int idx, long lsn)
long[] getEntryLsnLongArray()
byte[] getEntryLsnByteArray()
void initEntryLsn(int capacity)
void setLsnElement(int idx, long value)
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)
int getMaxEntries()
public Node fetchTarget(int idx) throws DatabaseException
DatabaseException
static String makeFetchErrorMsg(String msg, IN in, long lsn, byte state)
public void setEntry(int idx, Node target, byte[] keyVal, long lsn, byte state)
public void updateEntry(int idx, Node node)
public void updateEntry(int idx, Node node, long lsn)
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 void updateEntry(int idx, long lsn, long oldLNSize, long newLNSize)
public boolean verifyMemorySize()
public long getInMemorySize()
protected long getEntryInMemorySize(byte[] key, Node target)
protected long computeMemorySize()
public static long computeOverhead(DbConfigManager configManager) throws DatabaseException
DatabaseException
protected static long computeArraysOverhead(DbConfigManager configManager) throws DatabaseException
DatabaseException
protected long getMemoryOverhead(MemoryBudget mb)
protected void updateMemorySize(ChildReference oldRef, ChildReference newRef)
protected void updateMemorySize(long oldSize, long newSize)
void updateMemorySize(Node oldNode, Node newNode)
public int getAccumulatedDelta()
public void setInListResident(boolean resident)
public boolean isKeyInBounds(byte[] keyVal)
public int findEntry(byte[] key, boolean indicateIfDuplicate, boolean exact)
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.
InconsistentNodeException
- if the node is full
(it should have been split earlier).
DatabaseException
public int insertEntry1(ChildReference entry) throws DatabaseException
entry
- The ChildReference to insert into the IN.
InconsistentNodeException
- if the node is full (it should have
been split earlier).
DatabaseException
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
protected void setCompressedSinceLastLog()
public void setCleanedSinceLastLog()
public boolean compress(BINReference binRef, boolean canFetch) throws DatabaseException
DatabaseException
public boolean isCompressible()
boolean validateSubtreeBeforeDelete(int index) throws DatabaseException
DatabaseException
public boolean needsSplitting()
boolean entryZeroKeyComparesLow()
void split(IN parent, int childIndex, int maxEntries) throws DatabaseException
DatabaseException
protected void splitInternal(IN parent, int childIndex, int maxEntries, int splitIndex) throws DatabaseException
DatabaseException
void splitSpecial(IN parent, int parentIndex, int maxEntriesPerNode, byte[] key, boolean leftSide) throws DatabaseException
DatabaseException
void adjustCursors(IN newSibling, int newSiblingLow, int newSiblingHigh)
void adjustCursorsForInsert(int insertIndex)
public Comparator getKeyComparator()
public void verify(byte[] maxKey) throws DatabaseException
verify
in class Node
DatabaseException
void rebuildINList(INList inList) throws DatabaseException
rebuildINList
in class Node
DatabaseException
void accountForSubtreeRemoval(INList inList, UtilizationTracker tracker) throws DatabaseException
accountForSubtreeRemoval
in class Node
DatabaseException
boolean isValidForDelete() throws DatabaseException
isValidForDelete
in class Node
DatabaseException
void findParent(Tree.SearchType searchType, long targetNodeId, boolean targetContainsDuplicates, boolean targetIsRoot, byte[] targetMainTreeKey, byte[] targetDupTreeKey, SearchResult result, boolean requireExactMatch, boolean updateGeneration, int targetLevel, List trackingList, boolean doFetch) throws 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.
DatabaseException
protected void descendOnParentSearch(SearchResult result, boolean targetContainsDuplicates, boolean targetIsRoot, long targetNodeId, Node child, boolean requireExactMatch) throws DatabaseException
DatabaseException
protected boolean isSoughtNode(long nid, boolean updateGeneration) throws DatabaseException
isSoughtNode
in class Node
DatabaseException
protected boolean canBeAncestor(boolean targetContainsDuplicates)
canBeAncestor
in class Node
public boolean isEvictable()
public int getEvictionType()
boolean isEvictionProhibited()
boolean hasNonLNChildren()
int getChildEvictionType()
void accumulateStats(TreeWalkerStatsAccumulator acc)
public long log(LogManager logManager) throws DatabaseException
DatabaseException
public long log(LogManager logManager, boolean allowDeltas, boolean allowMigration) throws DatabaseException
DatabaseException
public long logProvisional(LogManager logManager, IN parent) throws DatabaseException
item
- object to be logged
DatabaseException
public long log(LogManager logManager, boolean allowDeltas, boolean isProvisional, boolean allowMigration, IN parent) throws DatabaseException
DatabaseException
protected long logInternal(LogManager logManager, boolean allowDeltas, boolean isProvisional, boolean allowMigration, IN parent) throws DatabaseException
DatabaseException
void trackProvisionalObsolete(IN child, long obsoleteLsn1, long obsoleteLsn2)
void flushProvisionalObsolete(LogManager logManager) throws DatabaseException
DatabaseException
public LogEntryType getLogType()
LoggableObject
getLogType
in interface LoggableObject
getLogType
in class Node
LoggableObject.getLogType()
public int getLogSize()
getLogSize
in interface LogWritable
getLogSize
in class Node
LogWritable.getLogSize()
public void writeToLog(ByteBuffer logBuffer)
LogWritable
writeToLog
in interface LogWritable
writeToLog
in class Node
logBuffer
- is the destination bufferLogWritable.writeToLog(java.nio.ByteBuffer)
public void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion) throws LogException
LogReadable
readFromLog
in interface LogReadable
readFromLog
in class Node
LogException
LogReadable.readFromLog(java.nio.ByteBuffer, byte)
public void dumpLog(StringBuffer sb, boolean verbose)
LogReadable
dumpLog
in interface LogReadable
dumpLog
in class Node
sb
- destination string bufferverbose
- if true, dump the full, verbose versionLogReadable.dumpLog(java.lang.StringBuffer, boolean)
public boolean logEntryIsTransactional()
logEntryIsTransactional
in interface LogReadable
LogReadable#logEntryIsTransactional.
public long getTransactionId()
getTransactionId
in interface LogReadable
LogReadable.getTransactionId()
protected void dumpLogAdditional(StringBuffer sb)
public String beginTag()
public String endTag()
void dumpKeys() throws DatabaseException
DatabaseException
public String dumpString(int nSpaces, boolean dumpTags)
dumpString
in class Node
static void dumpDeletedState(StringBuffer 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 |