com.sleepycat.je.tree
Class Node

java.lang.Object
  extended by com.sleepycat.je.tree.Node
All Implemented Interfaces:
Loggable
Direct Known Subclasses:
IN, LN

public abstract class Node
extends Object
implements Loggable

A Node contains all the common base information for any JE B-Tree node.


Constructor Summary
protected Node(boolean init)
          Create a new node, assigning it the next available node id.
 
Method Summary
(package private) abstract  void accountForSubtreeRemoval(INList inList, UtilizationTracker tracker)
          Remove yourself from the in memory list if you're a type of node that is put there.
protected abstract  boolean canBeAncestor(boolean targetContainsDuplicates)
           
 boolean containsDuplicates()
           
 void dump(int nSpaces)
           
 void dumpLog(StringBuffer sb, boolean verbose)
          Write the object into the string buffer for log dumping.
(package private)  String dumpString(int nSpaces, boolean dumpTags)
           
static long getLastId()
          Get the latest id, for checkpointing.
(package private)  int getLevel()
          Cover for LN's and just return 0 since they'll always be at the bottom of the tree.
 int getLogSize()
           
abstract  LogEntryType getLogType()
           
protected  long getMemorySizeIncludedByParent()
          Return the approximate size of this node in memory, if this size should be included in it's parents memory accounting.
static long getNextNodeId()
          Increment and return the next usable id.
 long getNodeId()
           
 long getTransactionId()
           
 String getType()
           
protected abstract  boolean isSoughtNode(long nid, boolean updateGeneration)
           
(package private) abstract  boolean isValidForDelete()
           
 void latchShared()
           
(package private)  boolean matchLNByNodeId(TreeLocation location, long nodeId)
           
 void postFetchInit(DatabaseImpl db, long sourceLsn)
          Initialize a node that has been faulted in from the log
 void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion)
          Initialize this object from the data in itemBuf.
(package private) abstract  void rebuildINList(INList inList)
          Add yourself to the in memory list if you're a type of node that should belong.
 void releaseLatch()
           
static void setLastNodeId(long id)
           
(package private)  void setNodeId(long nid)
           
 String shortDescription()
           
 String toString()
          Default toString method at the root of the tree.
 void verify(byte[] maxKey)
           
 void writeToLog(ByteBuffer logBuffer)
          Serialize this object into the buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

protected Node(boolean init)
Create a new node, assigning it the next available node id.

Method Detail

setLastNodeId

public static void setLastNodeId(long id)

getNextNodeId

public static long getNextNodeId()
Increment and return the next usable id. Must be synchronized.


getLastId

public static long getLastId()
Get the latest id, for checkpointing.


postFetchInit

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

Throws:
DatabaseException

getNodeId

public long getNodeId()

setNodeId

void setNodeId(long nid)

latchShared

public void latchShared()
                 throws DatabaseException
Throws:
DatabaseException

releaseLatch

public void releaseLatch()
                  throws LatchNotHeldException
Throws:
LatchNotHeldException

verify

public void verify(byte[] maxKey)
            throws DatabaseException
Throws:
DatabaseException

containsDuplicates

public boolean containsDuplicates()
Returns:
true if this node is a duplicate-bearing node type, false if otherwise.

getLevel

int getLevel()
Cover for LN's and just return 0 since they'll always be at the bottom of the tree.


matchLNByNodeId

boolean matchLNByNodeId(TreeLocation location,
                        long nodeId)
                  throws DatabaseException
Throws:
DatabaseException

rebuildINList

abstract void rebuildINList(INList inList)
                     throws DatabaseException
Add yourself to the in memory list if you're a type of node that should belong.

Throws:
DatabaseException

accountForSubtreeRemoval

abstract void accountForSubtreeRemoval(INList inList,
                                       UtilizationTracker tracker)
                                throws DatabaseException
Remove yourself from the in memory list if you're a type of node that is put there.

Throws:
DatabaseException

isValidForDelete

abstract boolean isValidForDelete()
                           throws DatabaseException
Returns:
true if you're part of a deletable subtree.
Throws:
DatabaseException

isSoughtNode

protected abstract boolean isSoughtNode(long nid,
                                        boolean updateGeneration)
                                 throws DatabaseException
Returns:
true if you're an IN in the search path
Throws:
DatabaseException

canBeAncestor

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

getMemorySizeIncludedByParent

protected long getMemorySizeIncludedByParent()
Return the approximate size of this node in memory, if this size should be included in it's parents memory accounting. For example, all INs return 0, because they are accounted for individually. LNs must return a count, they're not counted on the INList.


toString

public String toString()
Default toString method at the root of the tree.

Overrides:
toString in class Object

dump

public void dump(int nSpaces)

dumpString

String dumpString(int nSpaces,
                  boolean dumpTags)

shortDescription

public String shortDescription()

getType

public String getType()

getLogType

public abstract LogEntryType getLogType()

getLogSize

public int getLogSize()
Specified by:
getLogSize in interface Loggable
Returns:
number of bytes used to store this object.
See Also:
Loggable.getLogSize()

writeToLog

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

Specified by:
writeToLog in interface Loggable
Parameters:
logBuffer - is the destination buffer
See Also:
Loggable.writeToLog(java.nio.ByteBuffer)

readFromLog

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

Specified by:
readFromLog in interface Loggable
Throws:
LogException
See Also:
Loggable.readFromLog(java.nio.ByteBuffer, byte)

dumpLog

public void dumpLog(StringBuffer sb,
                    boolean verbose)
Description copied from interface: Loggable
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 Loggable
Parameters:
sb - destination string buffer
verbose - if true, dump the full, verbose version
See Also:
Loggable.dumpLog(java.lang.StringBuffer, boolean)

getTransactionId

public long getTransactionId()
Specified by:
getTransactionId in interface Loggable
Returns:
the transaction id embedded within this loggable object. Objects that have no transaction id should return 0.
See Also:
Loggable.getTransactionId()


Copyright 2004,2008 Oracle. All rights reserved.