com.sleepycat.je.tree
Class ChildReference

java.lang.Object
  extended by com.sleepycat.je.tree.ChildReference
All Implemented Interfaces:
Loggable

public class ChildReference
extends Object
implements Loggable

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(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
 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.
 boolean getMigrate()
          Get the entry migrate status.
(package private)  byte getState()
           
 Node getTarget()
          Return the target for this ChildReference.
 long getTransactionId()
           
 boolean isKnownDeleted()
           
 void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion)
          Initialize this object from the data in itemBuf.
 void setKey(byte[] key)
          Set the key for this ChildReference.
 void setLsn(long lsn)
          Sets the target LSN for this ChildReference.
 void setMigrate(boolean migrate)
          Set the entry migrate status.
 void setTarget(Node target)
          Sets the target for this ChildReference.
 String toString()
           
(package private)  void updateLsnAfterOptionalLog(DatabaseImpl dbImpl, long lsn)
          Do deferredWrite optional logging check.
 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.

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.

updateLsnAfterOptionalLog

void updateLsnAfterOptionalLog(DatabaseImpl dbImpl,
                               long lsn)
Do deferredWrite optional logging check.


isKnownDeleted

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

getMigrate

public boolean getMigrate()
Get the entry migrate status.


setMigrate

public void setMigrate(boolean migrate)
Set the entry migrate status.


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

dumpString

String dumpString(int nspaces,
                  boolean dumpTags)

toString

public String toString()
Overrides:
toString in class Object


Copyright 2004,2008 Oracle. All rights reserved.