com.sleepycat.je.tree
Class Node

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

public abstract class Node
extends Object
implements LoggableObject, LogReadable, LogWritable

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()
           
 boolean countAsObsoleteWhenLogged()
          Returns true if this item should be counted as obsoleted when logged.
 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()
          All objects that are reponsible for a generating a type of log entry must implement this.
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()
           
 String getType()
           
protected abstract  boolean isSoughtNode(long nid, boolean updateGeneration)
           
(package private) abstract  boolean isValidForDelete()
           
 boolean marshallOutsideWriteLatch()
          Return true if this item can be marshalled outside the log write latch.
(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 postLogWork(long justLoggedLsn)
          Do any processing we need to do after logging, while under the logging latch.
 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.
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
 
Methods inherited from interface com.sleepycat.je.log.LogReadable
getTransactionId, logEntryIsTransactional
 

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)

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()
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
Returns:
the type of log entry
See Also:
LoggableObject.getLogType()

marshallOutsideWriteLatch

public boolean marshallOutsideWriteLatch()
Description copied from interface: LoggableObject
Return true if this item can be marshalled outside the log write latch.

Specified by:
marshallOutsideWriteLatch in interface LoggableObject
See Also:
By default, nodes can be marshalled outside the log write latch.

countAsObsoleteWhenLogged

public boolean countAsObsoleteWhenLogged()
Description copied from interface: LoggableObject
Returns true if this item should be counted as obsoleted when logged. This currently applies to deleted LNs only.

Specified by:
countAsObsoleteWhenLogged in interface LoggableObject
See Also:
LoggableObject.countAsObsoleteWhenLogged()

postLogWork

public void postLogWork(long justLoggedLsn)
                 throws DatabaseException
Description copied from interface: LoggableObject
Do any processing we need to do after logging, while under the logging latch.

Specified by:
postLogWork in interface LoggableObject
Throws:
DatabaseException
See Also:
LoggableObject.postLogWork(long)

getLogSize

public int getLogSize()
Specified by:
getLogSize in interface LogWritable
Returns:
number of bytes used to store this object.
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
Parameters:
logBuffer - is the destination buffer
See Also:
LogWritable.writeToLog(java.nio.ByteBuffer)

readFromLog

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

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

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


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.