com.sleepycat.je.tree
Class IN

java.lang.Object
  extended bycom.sleepycat.je.tree.Node
      extended bycom.sleepycat.je.tree.IN
All Implemented Interfaces:
Comparable, LoggableObject, LogReadable, LogWritable
Direct Known Subclasses:
BIN, DIN

public class IN
extends Node
implements Comparable, LoggableObject, LogReadable

An IN represents an Internal Node in the JE tree.


Field Summary
static int DBMAP_LEVEL
           
protected  boolean evictionProhibited
           
static int EXACT_MATCH
           
static int INSERT_SUCCESS
           
static int MAIN_LEVEL
           
static int MAX_LEVEL
           
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, Key identifierKey, int capacity, int level)
          Create a new IN.
 
Method Summary
(package private)  void accountForSubtreeRemoval(INList inList, Set modifiedFileSummaries)
          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 clearTarget(int idx)
          Clear the idx'th target.
 int compareTo(Object o)
          Sort based on node id.
 boolean compress(BINReference binRef)
           
protected  long computeMemorySize()
          Count up the memory usage attributable to this node alone.
static long computeOverhead(DbConfigManager configManager)
           
protected  IN createNewInstance(Key identifierKey, int maxEntries, int level)
          Create a new IN.
 boolean deleteEntry(int index, boolean maybeValidate)
          Deletes the ChildReference at index from this IN.
(package private)  boolean deleteEntry(Key key, boolean maybeValidate)
          Deletes the ChildReference with the key arg from this IN.
protected  void descendOnParentSearch(SearchResult result, boolean targetContainsDuplicates, boolean targetIsRoot, long targetNodeId, Node child, boolean requireExactMatch)
           
(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)
           
(package private)  Node fetchTargetIgnoreKnownDeleted(int idx)
           
 int findEntry(Key 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, Key targetMainTreeKey, Key targetDupTreeKey, SearchResult result, boolean requireExactMatch, List trackingList, boolean doFetch)
          See if you are the parent of this child.
protected  int generateLevel(DatabaseId dbId, int newLevel)
           
 Key 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()
           
 Key getDupKey()
          Return the key for this duplicate set.
 Key getDupTreeKey()
          Return the key for navigating through the duplicate tree.
 long getGeneration()
           
 Key getIdentifierKey()
           
 long getInMemorySize()
          Return the number of bytes used by this IN.
(package private)  long getInMemorySize(int idx)
           
(package private) static long getInMemorySize(Key key, Node target)
           
 Key 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.
 Latch getLatch()
           
 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.
 Key getMainTreeKey()
          Return the key for navigating through the main tree.
(package private)  int getMaxEntries()
           
protected  long getMemoryOverhead(MemoryBudget mb)
           
 int getNEntries()
           
 byte getState(int idx)
           
 Node getTarget(int idx)
          Return the idx'th target.
 long getTransactionId()
           
 int hashCode()
           
protected  void init(DatabaseImpl db, Key identifierKey, int initialCapacity, int level)
          Initialize IN object.
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 isDbRoot()
           
(package private)  boolean isDirty(int idx)
           
 boolean isEntryKnownDeleted(int idx)
           
 boolean isEvictable()
           
 boolean isKeyInBounds(Key key)
          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 isRoot()
           
protected  boolean isSoughtNode(long nid)
           
(package private)  boolean isValidForDelete()
          Check if this node fits the qualifications for being part of a deletable subtree.
 void latch()
          Latch this node.
 long log(LogManager logManager)
          Log this IN and clear the dirty flag.
 long log(LogManager logManager, boolean isProvisional)
          Log this IN and clear the dirty flag.
 long logAllowDeltas(LogManager logManager, boolean isProvisional)
          Log this IN.
 boolean logEntryIsTransactional()
           
protected  long logInternal(LogManager logManager, boolean allowDeltas, boolean isProvisional)
          Decide how to log this node.
 long logProvisional(LogManager logManager)
          Log this node provisionally and clear the dirty flag.
(package private)  String makeFetchErrorMsg(Exception e, long lsn, byte state)
           
(package private)  Key makePrefixKey(Key wholeKey)
          Makes a prefix key suitable for this IN by taking the argument key, comparing it to other existing keys in the node and finding the minimal prefix of the argument that will distinguish it in this IN.
 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)
          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.
 Key selectKey(Key mainTreeKey, Key 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, Key key, long lsn, byte state)
          Set the idx'th entry of this node.
 void setEvictionProhibited(boolean pinned)
           
 void setGeneration()
           
 void setGeneration(long newGeneration)
           
(package private)  void setIdentifierKey(Key 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.
 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, Key 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 traceSplit(Level level, IN parent, IN newSibling, long parentLsn, long myNewLsn, long newSiblingLsn, int splitIndex, int idKeyIndex, int childIndex)
          Send trace messages to the java.util.logger.
 void updateEntry(int idx, long lsn)
          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, Key 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(Key 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, 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
marshallOutsideWriteLatch, postLogWork
 

Field Detail

DBMAP_LEVEL

public static final int DBMAP_LEVEL
See Also:
Constant Field Values

MAIN_LEVEL

public static final int MAIN_LEVEL
See Also:
Constant Field Values

MIN_LEVEL

public static final int MIN_LEVEL
See Also:
Constant Field Values

MAX_LEVEL

public static final int MAX_LEVEL
See Also:
Constant Field Values

evictionProhibited

protected boolean evictionProhibited

EXACT_MATCH

public static final int EXACT_MATCH
See Also:
Constant Field Values

INSERT_SUCCESS

public static final int INSERT_SUCCESS
See Also:
Constant Field Values
Constructor Detail

IN

public IN()
Create an empty IN, with no node id, to be filled in from the log.


IN

public IN(DatabaseImpl db,
          Key identifierKey,
          int capacity,
          int level)
Create a new IN.

Method Detail

init

protected void init(DatabaseImpl db,
                    Key identifierKey,
                    int initialCapacity,
                    int level)
Initialize IN object.


initMemorySize

protected void initMemorySize()
Initialize the per-node memory count by computing its memory usage.


equals

public boolean equals(Object obj)

hashCode

public int hashCode()

compareTo

public int compareTo(Object o)
Sort based on node id.

Specified by:
compareTo in interface Comparable

createNewInstance

protected IN createNewInstance(Key identifierKey,
                               int maxEntries,
                               int level)
Create a new IN. Need this because we can't call newInstance() without getting a 0 for nodeid.


postFetchInit

public void postFetchInit(DatabaseImpl db,
                          long sourceLsn)
                   throws DatabaseException
Initialize a node that has been read in from the log.

Overrides:
postFetchInit in class Node
Throws:
DatabaseException

postRecoveryInit

public void postRecoveryInit(DatabaseImpl db,
                             long sourceLsn)
Initialize a node read in during recovery.


setLastFullLsn

void setLastFullLsn(long lsn)
Sets the last logged LSN.


getLastFullVersion

public long getLastFullVersion()
Returns the last logged LSN, or null if never logged. Is public for unit testing.


latch

public void latch()
           throws DatabaseException
Latch this node.

Throws:
DatabaseException

releaseLatch

public void releaseLatch()
                  throws LatchNotHeldException
Release the latch on this node.

Throws:
LatchNotHeldException

getLatch

public Latch getLatch()
Returns:
the latch object for this node.

getGeneration

public long getGeneration()

setGeneration

public void setGeneration()

setGeneration

public void setGeneration(long newGeneration)

getLevel

public int getLevel()
Description copied from class: Node
Cover for LN's and just return 0 since they'll always be at the bottom of the tree.

Overrides:
getLevel in class Node

generateLevel

protected int generateLevel(DatabaseId dbId,
                            int newLevel)

getDirty

public boolean getDirty()

setDirty

public void setDirty(boolean dirty)

isRoot

public boolean isRoot()

isDbRoot

public boolean isDbRoot()

setIsRoot

void setIsRoot(boolean isRoot)

getIdentifierKey

public Key getIdentifierKey()
Returns:
the identifier key for this node.

setIdentifierKey

void setIdentifierKey(Key key)
Set the identifier key for this node.

Parameters:
key - - the new identifier key for this node.

getChildKey

public Key getChildKey(IN child)
                throws DatabaseException
Get the key (dupe or identifier) in child that is used to locate it in 'this' node.

Throws:
DatabaseException

selectKey

public Key selectKey(Key mainTreeKey,
                     Key dupTreeKey)

getDupKey

public Key getDupKey()
              throws DatabaseException
Return the key for this duplicate set.

Throws:
DatabaseException

getDupTreeKey

public Key getDupTreeKey()
Return the key for navigating through the duplicate tree.


getMainTreeKey

public Key getMainTreeKey()
Return the key for navigating through the main tree.


getDatabase

public DatabaseImpl getDatabase()
Get the database for this IN.


setDatabase

public void setDatabase(DatabaseImpl db)
Set the database reference for this node.


getDatabaseId

public DatabaseId getDatabaseId()

getKey

public Key getKey(int idx)
Return the idx'th key.


getState

public byte getState(int idx)

getTarget

public Node getTarget(int idx)
Return the idx'th target.


setTarget

public void setTarget(int idx,
                      Node target)
Sets the idx'th target. No need to make dirty, that state only applies to key and LSN.


clearTarget

public void clearTarget(int idx)
Clear the idx'th target. No need to make dirty, that state only applies to key and LSN. This method is public because it's safe and used by RecoveryManager. This can't corrupt the tree.


getLsn

public long getLsn(int idx)
Return the idx'th LSN for this entry.

Returns:
the idx'th LSN for this entry.

setLsn

public void setLsn(int idx,
                   long lsn)
Sets the idx'th target LSN.


isEntryKnownDeleted

public boolean isEntryKnownDeleted(int idx)
Returns:
true if the idx'th entry is deleted for sure.

setKnownDeleted

void setKnownDeleted(int idx)
Set knownDeleted to true.


clearKnownDeleted

void clearKnownDeleted(int idx)
Set knownDeleted to false.


isDirty

boolean isDirty(int idx)
Returns:
true if the object is dirty.

getNEntries

public int getNEntries()
Returns:
the number of entries in this node.

getMaxEntries

int getMaxEntries()
Returns:
the maximum number of entries in this node.

fetchTarget

public Node fetchTarget(int idx)
                 throws DatabaseException
Returns:
the target of the idx'th entry.
Throws:
DatabaseException

fetchTargetIgnoreKnownDeleted

Node fetchTargetIgnoreKnownDeleted(int idx)
                             throws DatabaseException
Throws:
DatabaseException

makeFetchErrorMsg

String makeFetchErrorMsg(Exception e,
                         long lsn,
                         byte state)

setEntry

public void setEntry(int idx,
                     Node target,
                     Key key,
                     long lsn,
                     byte state)
Set the idx'th entry of this node.


updateEntry

public void updateEntry(int idx,
                        Node node)
Update the idx'th entry of this node. Note: does not dirty the node.


updateEntry

public void updateEntry(int idx,
                        Node node,
                        long lsn)
Update the idx'th entry of this node.


updateEntry

public void updateEntry(int idx,
                        Node node,
                        long lsn,
                        Key key)
Update the idx'th entry of this node.


updateEntry

public void updateEntry(int idx,
                        long lsn)
Update the idx'th entry of this node.


updateEntry

public void updateEntry(int idx,
                        long lsn,
                        long oldLNSize,
                        long newLNSize)
Update the idx'th entry of this node. This flavor is used when the target LN is being modified, by an operation like a delete or update. We don't have to check whether the LSN has been nulled or not, because we know an LSN existed before. Also, the modification of the target is done in the caller, so instead of passing in the old and new nodes, we pass in the old and new node sizes.


verifyMemorySize

public boolean verifyMemorySize()

getInMemorySize

public long getInMemorySize()
Return the number of bytes used by this IN. Latching is up to the caller.


getInMemorySize

long getInMemorySize(int idx)

getInMemorySize

static long getInMemorySize(Key key,
                            Node target)

computeMemorySize

protected long computeMemorySize()
Count up the memory usage attributable to this node alone. LNs children are counted by their BIN/DIN parents, but INs are not counted by their parents because they are resident on the IN list.


computeOverhead

public static long computeOverhead(DbConfigManager configManager)
                            throws DatabaseException
Throws:
DatabaseException

getMemoryOverhead

protected long getMemoryOverhead(MemoryBudget mb)

updateMemorySize

protected void updateMemorySize(ChildReference oldRef,
                                ChildReference newRef)

updateMemorySize

protected void updateMemorySize(long oldSize,
                                long newSize)

updateMemorySize

void updateMemorySize(Node oldNode,
                      Node newNode)

setInListResident

public void setInListResident(boolean resident)

isKeyInBounds

public boolean isKeyInBounds(Key key)
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. This method is used to determine whether a key to be inserted belongs in this IN, without doing a tree search. If false is returned it is still possible that the key belongs in this IN, but a tree search must be performed to find out.


findEntry

public int findEntry(Key key,
                     boolean indicateIfDuplicate,
                     boolean exact)
Find the entry in this IN for which key arg is >= the key. Currently uses a binary search, but eventually, this may use binary or linear search depending on key size, number of entries, etc. Note that the 0'th entry's key is treated specially in an IN. It always compares lower than any other key. This is public so that DbCursorTest can access it.

Parameters:
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.
Returns:
offset for the entry that has a key >= the arg. 0 if key is less than the 1st entry. -1 if exact is true and no exact match is found. If indicateIfDuplicate is true and an exact match was found then EXACT_MATCH is or'd onto the return value.

insertEntry

public boolean insertEntry(ChildReference entry)
                    throws DatabaseException
Inserts the argument ChildReference into this IN. Assumes this node is already latched by the caller.

Parameters:
entry - The ChildReference to insert into the IN.
Returns:
true if the entry was successfully inserted, false if it was a duplicate.
Throws:
InconsistentNodeException - if the node is full (it should have been split earlier).
DatabaseException

insertEntry1

public int insertEntry1(ChildReference entry)
                 throws DatabaseException
Same as insertEntry except that it returns the index where the dup was found instead of false. The return value is |'d with either INSERT_SUCCESS or EXACT_MATCH depending on whether the entry was inserted or it was a duplicate, resp. This returns a failure if there's a duplicate match. The caller must do the processing to check if the entry is actually deleted and can be overwritten. This is foisted upon the caller rather than handled in this object because there may be some latch releasing/retaking in order to check a child ln. Inserts the argument ChildReference into this IN. Assumes this node is already latched by the caller.

Parameters:
entry - The ChildReference to insert into the IN.
Returns:
either (1) the index of location in the IN where the entry was inserted |'d with INSERT_SUCCESS, or (2) the index of the duplicate in the IN |'d with EXACT_MATCH if the entry was found to be a duplicate.
Throws:
InconsistentNodeException - if the node is full (it should have been split earlier).
DatabaseException

deleteEntry

boolean deleteEntry(Key key,
                    boolean maybeValidate)
              throws DatabaseException
Deletes the ChildReference with the key arg from this IN. Assumes this node is already latched by the caller. This seems to only be used by INTest.

Parameters:
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.
Returns:
true if the entry was successfully deleted, false if it was not found.
Throws:
DatabaseException

deleteEntry

public boolean deleteEntry(int index,
                           boolean maybeValidate)
                    throws DatabaseException
Deletes the ChildReference at index from this IN. Assumes this node is already latched by the caller.

Parameters:
index - The index of the entry to delete from the IN.
maybeValidate - true if asserts are enabled.
Returns:
true if the entry was successfully deleted, false if it was not found.
Throws:
DatabaseException

setCompressedSinceLastLog

protected void setCompressedSinceLastLog()
Do nothing since INs don't support deltas.


setCleanedSinceLastLog

public void setCleanedSinceLastLog()
Do nothing since INs don't support deltas.


compress

public boolean compress(BINReference binRef)
                 throws DatabaseException
Throws:
DatabaseException

validateSubtreeBeforeDelete

boolean validateSubtreeBeforeDelete(int index)
                              throws DatabaseException
Throws:
DatabaseException

makePrefixKey

Key makePrefixKey(Key wholeKey)
Makes a prefix key suitable for this IN by taking the argument key, comparing it to other existing keys in the node and finding the minimal prefix of the argument that will distinguish it in this IN.

Returns:
The prefix key

needsSplitting

public boolean needsSplitting()
Return true if this node needs splitting. For the moment, needing to be split is defined by there being no free entries available.


entryZeroKeyComparesLow

boolean entryZeroKeyComparesLow()
Indicates whether whether entry 0's key is "special" in that it always compares less than any other key. BIN's don't have the special key, but IN's do.


split

void split(IN parent,
           int childIndex,
           int maxEntries)
     throws DatabaseException
Split this into two nodes. Parent IN is passed in parent and should be latched by the caller. childIndex is the index in parent of where "this" can be found.

Returns:
lsn of the newly logged parent
Throws:
DatabaseException

splitInternal

protected void splitInternal(IN parent,
                             int childIndex,
                             int maxEntries,
                             int splitIndex)
                      throws DatabaseException
Throws:
DatabaseException

splitSpecial

void splitSpecial(IN parent,
                  int parentIndex,
                  int maxEntriesPerNode,
                  Key key,
                  boolean leftSide)
            throws DatabaseException
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. This is achieved by just forcing the split to occur either one element in from the left or the right (i.e. splitIndex is 1 or nEntries - 1).

Throws:
DatabaseException

adjustCursors

void adjustCursors(IN newSibling,
                   int newSiblingLow,
                   int newSiblingHigh)

adjustCursorsForInsert

void adjustCursorsForInsert(int insertIndex)

getKeyComparator

public Comparator getKeyComparator()
Return the relevant user defined comparison function for this type of node. For IN's and BIN's, this is the BTree Comparison function.


verify

public void verify(Key maxKey)
            throws DatabaseException
Check that the IN is in a valid state. For now, validity means that the keys are in sorted order and that there are more than 0 entries. maxKey, if non-null specifies that all keys in this node must be less than maxKey.

Overrides:
verify in class Node
Throws:
DatabaseException

rebuildINList

void rebuildINList(INList inList)
             throws DatabaseException
Add self and children to this in-memory IN list. Called by recovery, can run with no latching.

Specified by:
rebuildINList in class Node
Throws:
DatabaseException

accountForSubtreeRemoval

void accountForSubtreeRemoval(INList inList,
                              Set modifiedFileSummaries)
                        throws DatabaseException
Remove self and children from the in-memory IN list. The INList latch is already held before this is called. Also count removed nodes as obsolete.

Specified by:
accountForSubtreeRemoval in class Node
Throws:
DatabaseException

isValidForDelete

boolean isValidForDelete()
                   throws DatabaseException
Check if this node fits the qualifications for being part of a deletable subtree. It can only have one IN child and no LN children.

Specified by:
isValidForDelete in class Node
Returns:
true if you're part of a deletable subtree.
Throws:
DatabaseException

findParent

void findParent(Tree.SearchType searchType,
                long targetNodeId,
                boolean targetContainsDuplicates,
                boolean targetIsRoot,
                Key targetMainTreeKey,
                Key targetDupTreeKey,
                SearchResult result,
                boolean requireExactMatch,
                List trackingList,
                boolean doFetch)
          throws DatabaseException
See if you are the parent of this child. If not, find a child of your's that may be the parent, and return it. If there are no possiblities, return null. Note that the keys of the target are passed in so we don't have to latch the target to look at them. Also, this node is latched upon entry.

Parameters:
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.
Throws:
DatabaseException

descendOnParentSearch

protected void descendOnParentSearch(SearchResult result,
                                     boolean targetContainsDuplicates,
                                     boolean targetIsRoot,
                                     long targetNodeId,
                                     Node child,
                                     boolean requireExactMatch)
                              throws DatabaseException
Throws:
DatabaseException

isSoughtNode

protected boolean isSoughtNode(long nid)
                        throws DatabaseException
Specified by:
isSoughtNode in class Node
Returns:
true if you're an IN in the search path
Throws:
DatabaseException

canBeAncestor

protected boolean canBeAncestor(boolean targetContainsDuplicates)
Specified by:
canBeAncestor in class Node
Returns:
true if you can be the ancestor of the target IN. Currently the determining factor is whether the target IN contains duplicates.

isEvictable

public boolean isEvictable()

setEvictionProhibited

public void setEvictionProhibited(boolean pinned)

accumulateStats

void accumulateStats(TreeWalkerStatsAccumulator acc)

log

public long log(LogManager logManager)
         throws DatabaseException
Log this IN and clear the dirty flag.

Throws:
DatabaseException

log

public long log(LogManager logManager,
                boolean isProvisional)
         throws DatabaseException
Log this IN and clear the dirty flag.

Throws:
DatabaseException

logProvisional

public long logProvisional(LogManager logManager)
                    throws DatabaseException
Log this node provisionally and clear the dirty flag.

Returns:
LSN of the new log entry
Throws:
DatabaseException

logAllowDeltas

public long logAllowDeltas(LogManager logManager,
                           boolean isProvisional)
                    throws DatabaseException
Log this IN. Called by checkpointer, allow deltas where appropriate. If a delta has been logged, return null.

Throws:
DatabaseException

logInternal

protected long logInternal(LogManager logManager,
                           boolean allowDeltas,
                           boolean isProvisional)
                    throws DatabaseException
Decide how to log this node. INs are always logged in full.

Throws:
DatabaseException

getLogType

public LogEntryType getLogType()
Description copied from interface: LoggableObject
All objects that are reponsible for a generating a type of log entry must implement this.

Specified by:
getLogType in interface LoggableObject
Specified by:
getLogType in class Node
See Also:
LoggableObject.getLogType()

getLogSize

public int getLogSize()
Specified by:
getLogSize in interface LogWritable
Overrides:
getLogSize in class Node
See Also:
LogWritable.getLogSize()

writeToLog

public void writeToLog(ByteBuffer logBuffer)
Description copied from interface: LogWritable
Serialize this object into the buffer.

Specified by:
writeToLog in interface LogWritable
Overrides:
writeToLog in class Node
See Also:
LogWritable.writeToLog(java.nio.ByteBuffer)

readFromLog

public void readFromLog(ByteBuffer itemBuffer)
                 throws LogException
Description copied from interface: LogReadable
Initialize this object from the data in itemBuf.

Specified by:
readFromLog in interface LogReadable
Overrides:
readFromLog in class Node
Throws:
LogException
See Also:
LogReadable.readFromLog(java.nio.ByteBuffer)

dumpLog

public void dumpLog(StringBuffer sb,
                    boolean verbose)
Description copied from interface: LogReadable
Write the object into the string buffer for log dumping. Each object should be dumped without indentation or new lines and should be valid XML.

Specified by:
dumpLog in interface LogReadable
Overrides:
dumpLog in class Node
See Also:
LogReadable.dumpLog(java.lang.StringBuffer, boolean)

logEntryIsTransactional

public boolean logEntryIsTransactional()
Specified by:
logEntryIsTransactional in interface LogReadable
Returns:
true if the LogEntry is a transactional log entry type.
See Also:
LogReadable#logEntryIsTransactional.

getTransactionId

public long getTransactionId()
Specified by:
getTransactionId in interface LogReadable
Returns:
return the transaction id if this log entry is transactional, 0 otherwise.
See Also:
LogReadable.getTransactionId()

dumpLogAdditional

protected void dumpLogAdditional(StringBuffer sb)
Allows subclasses to add additional fields before the end tag. If they just overload dumpLog, the xml isn't nested.


beginTag

public String beginTag()

endTag

public String endTag()

dumpKeys

void dumpKeys()
        throws DatabaseException
Throws:
DatabaseException

dumpString

public String dumpString(int nSpaces,
                         boolean dumpTags)
For unit test support:

Overrides:
dumpString in class Node
Returns:
a string that dumps information about this IN, without

toString

public String toString()
Description copied from class: Node
Default toString method at the root of the tree.

Overrides:
toString in class Node

shortClassName

public String shortClassName()

traceSplit

void traceSplit(Level level,
                IN parent,
                IN newSibling,
                long parentLsn,
                long myNewLsn,
                long newSiblingLsn,
                int splitIndex,
                int idKeyIndex,
                int childIndex)
Send trace messages to the java.util.logger. Don't rely on the logger alone to conditionalize whether we send this message, we don't even want to construct the message if the level is not enabled.



Copyright 2004 Sleepycat, Inc. All Rights Reserved.