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 java.lang.Object
implements Loggable

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


Constructor Summary
protected Node()
          Only for subclasses.
protected Node(EnvironmentImpl envImpl, boolean replicated)
          Create a new node, assigning it the next available node id.
 
Method Summary
protected abstract  boolean canBeAncestor(boolean targetContainsDuplicates)
           
 boolean containsDuplicates()
           
 void dump(int nSpaces)
           
 void dumpLog(java.lang.StringBuffer sb, boolean verbose)
          Write the object into the string buffer for log dumping.
 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.
 long getNodeId()
           
 long getTransactionId()
           
 java.lang.String getType()
           
protected abstract  boolean isSoughtNode(long nid, CacheMode cacheMode)
           
 void latchShared()
           
 void latchShared(CacheMode ignore)
           
 void postFetchInit(DatabaseImpl db, long sourceLsn)
          Initialize a node that has been faulted in from the log.
 void readFromLog(java.nio.ByteBuffer itemBuffer, byte entryVersion)
          Initialize this object from the data in itemBuf.
 void releaseLatch()
           
 java.lang.String shortDescription()
           
 java.lang.String toString()
          Default toString method at the root of the tree.
 void verify(byte[] maxKey)
           
 void writeToLog(java.nio.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.Loggable
logicalEquals
 

Constructor Detail

Node

protected Node()
Only for subclasses.


Node

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

Method Detail

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()

latchShared

public void latchShared()
                 throws DatabaseException
Throws:
DatabaseException

latchShared

public void latchShared(CacheMode ignore)
                 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

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


isSoughtNode

protected abstract boolean isSoughtNode(long nid,
                                        CacheMode cacheMode)
                                 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 java.lang.String toString()
Default toString method at the root of the tree.

Overrides:
toString in class java.lang.Object

dump

public void dump(int nSpaces)

shortDescription

public java.lang.String shortDescription()

getType

public java.lang.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(java.nio.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(java.nio.ByteBuffer itemBuffer,
                        byte entryVersion)
                 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(java.lang.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()