com.sleepycat.je.tree
Class ChildReference

java.lang.Object
  extended bycom.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
(package private) ChildReference()
          Construct an empty child reference, for reading from the log.
(package private) ChildReference(Key key, long lsn, boolean knownDeleted)
          Construct a ChildReference.
  ChildReference(Node target, Key key, long lsn)
          Construct a ChildReference.
 
Method Summary
(package private)  void clearKnownDeleted()
          Set knownDeleted 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.
(package private)  Node fetchTargetIgnoreKnownDeleted(DatabaseImpl database, IN in)
          Same as fetchTarget except that if knownDeleted is set this does not thrown an exception.
 Key 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)
          Initialize this object from the data in itemBuf.
 void setKey(Key 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.
 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,
                      Key key,
                      long lsn)
Construct a ChildReference.


ChildReference

ChildReference(Key key,
               long lsn,
               boolean knownDeleted)
Construct a ChildReference.

Method Detail

getKey

public Key getKey()
Return the key for this ChildReference.


setKey

public void setKey(Key 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.
Throws:
DatabaseException

fetchTargetIgnoreKnownDeleted

Node fetchTargetIgnoreKnownDeleted(DatabaseImpl database,
                                   IN in)
                             throws DatabaseException
Same as fetchTarget except that if knownDeleted is set this does not thrown an exception. This is needed by the compressor to fetch an LN so that it can lock it, even though it's marked as deleted.

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.


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

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


Copyright 2004 Sleepycat, Inc. All Rights Reserved.