com.sleepycat.je.tree
Class ChildReference

java.lang.Object
  extended by com.sleepycat.je.tree.ChildReference
All Implemented Interfaces:
LogReadable, LogWritable

public final class ChildReference
extends Object
implements LogWritable, LogReadable

A ChildReference is a reference in the tree from parent to child. It contains a node reference, key, and LSN.


Constructor Summary
ChildReference()
          Construct an empty child reference, for reading from the log.
ChildReference(byte[] key, long lsn, boolean knownDeleted)
          Construct a ChildReference.
ChildReference(Node target, byte[] key, long lsn)
          Construct a ChildReference for inserting a new entry.
ChildReference(Node target, byte[] key, long lsn, byte existingState)
          Construct a ChildReference for inserting an existing entry.
 
Method Summary
(package private)  void clearKnownDeleted()
          Set knownDeleted to false.
(package private)  void clearPendingDeleted(int idx)
          Set pendingDeleted to false.
 void clearTarget()
          Clear the target for this ChildReference.
 void dumpLog(StringBuffer sb, boolean verbose)
          Write the object into the string buffer for log dumping.
(package private)  String dumpString(int nspaces, boolean dumpTags)
           
 Node fetchTarget(DatabaseImpl database, IN in)
          Fetch the target object that this ChildReference refers to.
 byte[] getKey()
          Return the key for this ChildReference.
 int getLogSize()
           
 long getLsn()
          Return the LSN for this ChildReference.
(package private)  byte getState()
           
 Node getTarget()
          Return the target for this ChildReference.
 long getTransactionId()
           
 boolean isKnownDeleted()
           
 boolean logEntryIsTransactional()
           
 void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion)
          Initialize this object from the data in itemBuf.
 void setKey(byte[] key)
          Set the key for this ChildReference.
(package private)  void setKnownDeleted()
          Set knownDeleted to true.
 void setLsn(long lsn)
          Sets the target LSN for this ChildReference.
(package private)  void setPendingDeleted(int idx)
          Set pendingDeleted to true.
 void setTarget(Node target)
          Sets the target for this ChildReference.
 String toString()
           
 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

ChildReference

ChildReference()
Construct an empty child reference, for reading from the log.


ChildReference

public ChildReference(Node target,
                      byte[] key,
                      long lsn)
Construct a ChildReference for inserting a new entry.


ChildReference

public ChildReference(Node target,
                      byte[] key,
                      long lsn,
                      byte existingState)
Construct a ChildReference for inserting an existing entry.


ChildReference

ChildReference(byte[] key,
               long lsn,
               boolean knownDeleted)
Construct a ChildReference.

Method Detail

getKey

public byte[] getKey()
Return the key for this ChildReference.


setKey

public void setKey(byte[] key)
Set the key for this ChildReference.


fetchTarget

public Node fetchTarget(DatabaseImpl database,
                        IN in)
                 throws DatabaseException
Fetch the target object that this ChildReference refers to. If the object is already in VM, then just return the reference to it. If the object is not in VM, then read the object from the log. If the object has been faulted in and the in arg is supplied, then the total memory size cache in the IN is invalidated.

Parameters:
database - The database that this ChildReference resides in.
in - The IN that this ChildReference lives in. If the target is fetched (i.e. it is null on entry), then the total in memory count is invalidated in the IN. May be null. For example, the root is a ChildReference and there is no parent IN when the rootIN is fetched in.
Returns:
the Node object representing the target node in the tree, or null if there is no target of this ChildReference, or null if a pendingDelete or knownDeleted entry has been cleaned.
Throws:
DatabaseException

getState

byte getState()

getTarget

public Node getTarget()
Return the target for this ChildReference.


setTarget

public void setTarget(Node target)
Sets the target for this ChildReference. No need to make dirty, that state only applies to key and LSN.


clearTarget

public void clearTarget()
Clear the target for this ChildReference. 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()
Return the LSN for this ChildReference.

Returns:
the LSN for this ChildReference.

setLsn

public void setLsn(long lsn)
Sets the target LSN for this ChildReference.

Parameters:
the - target LSN.

setPendingDeleted

void setPendingDeleted(int idx)
Set pendingDeleted to true.


clearPendingDeleted

void clearPendingDeleted(int idx)
Set pendingDeleted to false.


isKnownDeleted

public boolean isKnownDeleted()
Returns:
true if entry is deleted for sure.

setKnownDeleted

void setKnownDeleted()
Set knownDeleted to true.


clearKnownDeleted

void clearKnownDeleted()
Set knownDeleted to false.


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

Specified by:
readFromLog in interface LogReadable
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)

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

dumpString

String dumpString(int nspaces,
                  boolean dumpTags)

toString

public String toString()
Overrides:
toString in class Object


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