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.


Field Summary
static long NULL_NODE_ID
           
 
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
(package private) abstract  void accountForSubtreeRemoval(INList inList, LocalUtilizationTracker localTracker)
          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(StringBuilder sb, boolean verbose)
          Write the object into the string buffer for log dumping.
(package private)  String dumpString(int nSpaces, boolean dumpTags)
           
 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()
           
 String getType()
           
abstract  void incFetchStats(EnvironmentImpl envImpl, boolean isMiss)
          We categorize fetch stats by the type of node, so node subclasses update different stats.
protected abstract  boolean isSoughtNode(long nid, CacheMode cacheMode, boolean doFetch)
           
(package private) abstract  boolean isValidForDelete()
           
 void latchShared()
           
 void latchShared(CacheMode ignore)
           
(package private)  boolean matchLNByNodeId(TreeLocation location, long nodeId, CacheMode cachemode)
           
 void postFetchInit(DatabaseImpl db, long sourceLsn)
           
 void readFromLog(ByteBuffer itemBuffer, int entryVersion)
          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()
           
(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.Loggable
logicalEquals
 

Field Detail

NULL_NODE_ID

public static final long NULL_NODE_ID
See Also:
Constant Field Values
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
Throws:
DatabaseException - from subclasses.

getNodeId

public long getNodeId()

setNodeId

void setNodeId(long nid)

latchShared

public void latchShared()
                 throws DatabaseException
Throws:
DatabaseException - from subclasses.

latchShared

public void latchShared(CacheMode ignore)
                 throws DatabaseException
Throws:
DatabaseException - from subclasses.

releaseLatch

public void releaseLatch()

verify

public void verify(byte[] maxKey)
            throws DatabaseException
Throws:
DatabaseException - from subclasses.

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.


matchLNByNodeId

boolean matchLNByNodeId(TreeLocation location,
                        long nodeId,
                        CacheMode cachemode)
                  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,
                                       LocalUtilizationTracker localTracker)
                                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,
                                        CacheMode cacheMode,
                                        boolean doFetch)
                                 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()

incFetchStats

public abstract void incFetchStats(EnvironmentImpl envImpl,
                                   boolean isMiss)
We categorize fetch stats by the type of node, so node subclasses update different stats.


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,
                        int entryVersion)
Description copied from interface: Loggable
Initialize this object from the data in itemBuf.

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

dumpLog

public void dumpLog(StringBuilder 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.StringBuilder, 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 (c) 2004-2010 Oracle. All rights reserved.