com.sleepycat.je.tree
Class LN

java.lang.Object
  extended by com.sleepycat.je.tree.Node
      extended by com.sleepycat.je.tree.LN
All Implemented Interfaces:
LoggableObject, LogReadable, LogWritable
Direct Known Subclasses:
DupCountLN, FileSummaryLN, MapLN, NameLN

public class LN
extends Node
implements LoggableObject, LogReadable

An LN represents a Leaf Node in the JE tree.


Constructor Summary
LN()
          Create an empty LN, to be filled in from the log.
LN(byte[] data)
          Create a new LN from a byte array.
LN(DatabaseEntry dbt)
          Create a new LN from a DatabaseEntry.
 
Method Summary
(package private)  void accountForSubtreeRemoval(INList inList, UtilizationTracker tracker)
          No need to do anything, stop the search.
(package private)  void addToDirtyMap(Map dirtyMap)
          Add yourself to the dirty list if you're dirty.
 String beginTag()
           
protected  boolean canBeAncestor(boolean targetContainsDuplicates)
          A LN can never be the ancestor of another node.
 byte[] copyData()
           
 boolean countAsObsoleteWhenLogged()
          Returns true if this item should be counted as obsoleted when logged.
 long delete(DatabaseImpl database, byte[] lnKey, byte[] dupKey, long oldLsn, Locker locker)
          Delete this LN's data and log the new version.
 void dumpLog(StringBuffer sb, boolean verbose)
          Write the object into the string buffer for log dumping.
protected  void dumpLogAdditional(StringBuffer sb)
           
 String dumpString(int nSpaces, boolean dumpTags)
           
 String endTag()
           
 byte[] getData()
           
 int getLogSize()
           
 LogEntryType getLogType()
          All objects that are reponsible for a generating a type of log entry must implement this.
 long getMemorySizeIncludedByParent()
          Compute the approximate size of this node in memory for evictor invocation purposes.
protected  LogEntryType getTransactionalLogType()
          Log type for transactional entries
 long getTransactionId()
          Never called.
 boolean isDeleted()
           
protected  boolean isSoughtNode(long nid, boolean updateGeneration)
          A LN can never be a child in the search chain.
(package private)  boolean isValidForDelete()
           
 long log(EnvironmentImpl env, DatabaseId dbId, byte[] key, long oldLsn, Locker locker)
          Log this LN.
 boolean logEntryIsTransactional()
          Never called.
 long logProvisional(EnvironmentImpl env, DatabaseId dbId, byte[] key, long oldLsn)
          Log a provisional, non-txnal version of a ln.
(package private)  void makeDeleted()
           
 long modify(byte[] newData, DatabaseImpl database, byte[] lnKey, long oldLsn, Locker locker)
          Modify the LN's data and log the new version.
 void readFromLog(ByteBuffer itemBuffer, byte entryTypeVersion)
          Initialize this object from the data in itemBuf.
(package private)  void rebuildINList(INList inList)
          Add yourself to the in memory list if you're a type of node that should belong.
 void writeToLog(ByteBuffer logBuffer)
          Serialize this object into the buffer.
 
Methods inherited from class com.sleepycat.je.tree.Node
containsDuplicates, dump, getLastId, getLevel, getNextNodeId, getNodeId, getType, marshallOutsideWriteLatch, matchLNByNodeId, postFetchInit, postLogWork, setLastNodeId, setNodeId, shortDescription, toString, verify
 
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.LoggableObject
marshallOutsideWriteLatch, postLogWork
 

Constructor Detail

LN

public LN()
Create an empty LN, to be filled in from the log.


LN

public LN(byte[] data)
Create a new LN from a byte array.


LN

public LN(DatabaseEntry dbt)
Create a new LN from a DatabaseEntry.

Method Detail

getData

public byte[] getData()

copyData

public byte[] copyData()

isDeleted

public boolean isDeleted()

makeDeleted

void makeDeleted()

isValidForDelete

boolean isValidForDelete()
Specified by:
isValidForDelete in class Node
Returns:
true if you're part of a deletable subtree.

isSoughtNode

protected boolean isSoughtNode(long nid,
                               boolean updateGeneration)
A LN can never be a child in the search chain.

Specified by:
isSoughtNode in class Node
Returns:
true if you're an IN in the search path

canBeAncestor

protected boolean canBeAncestor(boolean targetContainsDuplicates)
A LN can never be the ancestor of another node.

Specified by:
canBeAncestor in class Node
Returns:
true if you can be the ancestor of the target IN. Currently the determining factor is whether the target IN contains duplicates.

delete

public long delete(DatabaseImpl database,
                   byte[] lnKey,
                   byte[] dupKey,
                   long oldLsn,
                   Locker locker)
            throws DatabaseException
Delete this LN's data and log the new version.

Throws:
DatabaseException

modify

public long modify(byte[] newData,
                   DatabaseImpl database,
                   byte[] lnKey,
                   long oldLsn,
                   Locker locker)
            throws DatabaseException
Modify the LN's data and log the new version.

Throws:
DatabaseException

addToDirtyMap

void addToDirtyMap(Map dirtyMap)
Add yourself to the dirty list if you're dirty. LNs are never dirty.


rebuildINList

void rebuildINList(INList inList)
Add yourself to the in memory list if you're a type of node that should belong.

Specified by:
rebuildINList in class Node

accountForSubtreeRemoval

void accountForSubtreeRemoval(INList inList,
                              UtilizationTracker tracker)
No need to do anything, stop the search.

Specified by:
accountForSubtreeRemoval in class Node

getMemorySizeIncludedByParent

public long getMemorySizeIncludedByParent()
Compute the approximate size of this node in memory for evictor invocation purposes.

Overrides:
getMemorySizeIncludedByParent in class Node

beginTag

public String beginTag()

endTag

public String endTag()

dumpString

public String dumpString(int nSpaces,
                         boolean dumpTags)
Overrides:
dumpString in class Node

logProvisional

public long logProvisional(EnvironmentImpl env,
                           DatabaseId dbId,
                           byte[] key,
                           long oldLsn)
                    throws DatabaseException
Log a provisional, non-txnal version of a ln.

Parameters:
env - the environment.
dbId - database id of this node. (Not stored in LN)
key - key of this node. (Not stored in LN)
oldLsn - is the LSN of the previous version or null.
Throws:
DatabaseException

log

public long log(EnvironmentImpl env,
                DatabaseId dbId,
                byte[] key,
                long oldLsn,
                Locker locker)
         throws DatabaseException
Log this LN. Whether its logged as a transactional entry or not depends on the type of locker.

Parameters:
env - the environment.
dbId - database id of this node. (Not stored in LN)
key - key of this node. (Not stored in LN)
oldLsn - is the LSN of the previous version or null.
locker - owning locker.
Throws:
DatabaseException

getTransactionalLogType

protected LogEntryType getTransactionalLogType()
Log type for transactional entries


countAsObsoleteWhenLogged

public boolean countAsObsoleteWhenLogged()
Description copied from interface: LoggableObject
Returns true if this item should be counted as obsoleted when logged. This currently applies to deleted LNs only.

Specified by:
countAsObsoleteWhenLogged in interface LoggableObject
Overrides:
countAsObsoleteWhenLogged in class Node
See Also:
LoggableObject.countAsObsoleteWhenLogged()

getLogType

public LogEntryType getLogType()
Description copied from interface: LoggableObject
All objects that are reponsible for a generating a type of log entry must implement this.

Specified by:
getLogType in interface LoggableObject
Specified by:
getLogType in class Node
Returns:
the type of log entry
See Also:
LoggableObject.getLogType()

getLogSize

public int getLogSize()
Specified by:
getLogSize in interface LogWritable
Overrides:
getLogSize in class Node
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
Overrides:
writeToLog in class Node
Parameters:
logBuffer - is the destination buffer
See Also:
LogWritable.writeToLog(java.nio.ByteBuffer)

readFromLog

public void readFromLog(ByteBuffer itemBuffer,
                        byte entryTypeVersion)
                 throws LogException
Description copied from interface: LogReadable
Initialize this object from the data in itemBuf.

Specified by:
readFromLog in interface LogReadable
Overrides:
readFromLog in class Node
Throws:
LogException
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
Overrides:
dumpLog in class Node
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()
Never called.

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()
Never called.

Specified by:
getTransactionId in interface LogReadable
Returns:
return the transaction id if this log entry is transactional, 0 otherwise.
See Also:
LogReadable.getTransactionId()

dumpLogAdditional

protected void dumpLogAdditional(StringBuffer sb)


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