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:
Loggable
Direct Known Subclasses:
DupCountLN, FileSummaryLN, MapLN, NameLN

public class LN
extends Node
implements Loggable

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.
 String beginTag()
           
protected  boolean canBeAncestor(boolean targetContainsDuplicates)
          A LN can never be the ancestor of another node.
(package private)  boolean canMemorySizeChangeDuringLogging()
          Returns whether this LN's memory size can change during logging, such as when a FileSummaryLN's size changes in the getLogSize or writeToLog method.
 byte[] copyData()
           
 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, boolean verbose)
           
 String dumpString(int nSpaces, boolean dumpTags)
           
 String endTag()
           
 byte[] getData()
           
 int getLastLoggedSize()
          Returns the total last logged log size, including the LNLogEntry overhead of this LN when it was last logged and the log entry header.
 int getLogSize()
           
 LogEntryType getLogType()
           
 long getMemorySizeIncludedByParent()
          Compute the approximate size of this node in memory for evictor invocation purposes.
protected  LogEntryType getTransactionalLogType()
          Log type for transactional entries
 boolean isDeleted()
           
 boolean isDirty()
           
(package private)  boolean isEvictable()
          Returns true by default, but is overridden by MapLN to prevent eviction of open databases.
(package private)  boolean isEvictableInexact()
          Returns true by default, but is overridden by MapLN to prevent eviction of open databases.
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, byte[] delDupKey, long oldLsn, int oldSize, Locker locker, boolean backgroundIO, boolean isProvisional)
          Log this LN.
 long logUpdateMemUsage(DatabaseImpl database, byte[] lnKey, long oldLsn, Locker locker, IN parent)
          Veriation of logUpdateMemUsage that specifies false for the backgroundIO parameter.
 long logUpdateMemUsage(DatabaseImpl database, byte[] lnKey, long oldLsn, Locker locker, IN parent, boolean backgroundIO)
          Logs an LN that is already present in the parent IN, adjusting the memory budget if the size of the LN changes during logging, such as for FileSummaryLNs.
(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.
 long optionalLog(EnvironmentImpl env, DatabaseImpl databaseImpl, byte[] key, long oldLsn, int oldSize, Locker locker)
          Log this LN if it's not part of a deferred-write db.
 long optionalLogProvisional(EnvironmentImpl env, DatabaseImpl databaseImpl, byte[] key, long oldLsn, int oldSize)
          Log a provisional, non-txnal version of an LN.
 long optionalLogUpdateMemUsage(DatabaseImpl database, byte[] lnKey, long oldLsn, Locker locker, IN parent)
          Veriation of logUpdateMemUsage that does not log for a DeferredWrite DB.
 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.
(package private)  void setDirty()
           
 void setLastLoggedSize(int size)
          Saves the last logged size.
 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, getTransactionId, getType, latchShared, matchLNByNodeId, postFetchInit, releaseLatch, 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.Loggable
getTransactionId
 

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

isDirty

public boolean isDirty()

setDirty

void setDirty()

isValidForDelete

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

isEvictableInexact

boolean isEvictableInexact()
Returns true by default, but is overridden by MapLN to prevent eviction of open databases. This method is meant to be a fast but not guaranteed check and is used during selection of BINs for LN stripping. [#13415]


isEvictable

boolean isEvictable()
              throws DatabaseException
Returns true by default, but is overridden by MapLN to prevent eviction of open databases. This method is meant to be a guaranteed check and is used after a BIN has been selected for LN stripping but before actually stripping an LN. [#13415]

Throws:
DatabaseException

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.

canMemorySizeChangeDuringLogging

boolean canMemorySizeChangeDuringLogging()
Returns whether this LN's memory size can change during logging, such as when a FileSummaryLN's size changes in the getLogSize or writeToLog method.


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

logUpdateMemUsage

public long logUpdateMemUsage(DatabaseImpl database,
                              byte[] lnKey,
                              long oldLsn,
                              Locker locker,
                              IN parent,
                              boolean backgroundIO)
                       throws DatabaseException
Logs an LN that is already present in the parent IN, adjusting the memory budget if the size of the LN changes during logging, such as for FileSummaryLNs. This method should be used when logging an LN that is already present in the IN and the memory size is not adjusted by other means (such as when logging before IN.insertEntry, or when using CursorImpl.delete or CursorImpl.putCurrent). Note that when logging after IN.insertEntry, this method must be called. The IN parent must be latched on entry and is left latched on return. [#15831]

Throws:
DatabaseException

logUpdateMemUsage

public long logUpdateMemUsage(DatabaseImpl database,
                              byte[] lnKey,
                              long oldLsn,
                              Locker locker,
                              IN parent)
                       throws DatabaseException
Veriation of logUpdateMemUsage that specifies false for the backgroundIO parameter.

Throws:
DatabaseException

optionalLogUpdateMemUsage

public long optionalLogUpdateMemUsage(DatabaseImpl database,
                                      byte[] lnKey,
                                      long oldLsn,
                                      Locker locker,
                                      IN parent)
                               throws DatabaseException
Veriation of logUpdateMemUsage that does not log for a DeferredWrite DB.

Throws:
DatabaseException

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

optionalLog

public long optionalLog(EnvironmentImpl env,
                        DatabaseImpl databaseImpl,
                        byte[] key,
                        long oldLsn,
                        int oldSize,
                        Locker locker)
                 throws DatabaseException
Log this LN if it's not part of a deferred-write db. Whether it's 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_LSN.
oldSize - is the size of the previous version or zero.
locker - owning locker.
Throws:
DatabaseException

optionalLogProvisional

public long optionalLogProvisional(EnvironmentImpl env,
                                   DatabaseImpl databaseImpl,
                                   byte[] key,
                                   long oldLsn,
                                   int oldSize)
                            throws DatabaseException
Log a provisional, non-txnal version of an 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_LSN.
oldSize - is the size of the previous version or zero.
Throws:
DatabaseException

log

public long log(EnvironmentImpl env,
                DatabaseId dbId,
                byte[] key,
                byte[] delDupKey,
                long oldLsn,
                int oldSize,
                Locker locker,
                boolean backgroundIO,
                boolean isProvisional)
         throws DatabaseException
Log this LN. Clear dirty bit. Whether it's logged as a transactional entry or not depends on the type of locker. Is public only for unit tests.

Parameters:
env - the environment.
dbId - database id of this node. (Not stored in LN)
key - key of this node. (Not stored in LN)
delDupKey - if non-null, the dupKey for deleting the LN.
oldLsn - is the LSN of the previous version or NULL_LSN.
oldSize - is the size of the previous version or zero.
locker - owning locker.
Throws:
DatabaseException

getTransactionalLogType

protected LogEntryType getTransactionalLogType()
Log type for transactional entries


getLogType

public LogEntryType getLogType()
Specified by:
getLogType in class Node
See Also:
Node.getLogType()

getLastLoggedSize

public int getLastLoggedSize()
Returns the total last logged log size, including the LNLogEntry overhead of this LN when it was last logged and the log entry header. Used for computing obsolete size when an LNLogEntry is not in hand.


setLastLoggedSize

public void setLastLoggedSize(int size)
Saves the last logged size.


getLogSize

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

readFromLog

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

Specified by:
readFromLog in interface Loggable
Overrides:
readFromLog in class Node
Throws:
LogException
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
Overrides:
dumpLog in class Node
Parameters:
sb - destination string buffer
verbose - if true, dump the full, verbose version
See Also:
Loggable.dumpLog(java.lang.StringBuffer, boolean)

dumpLogAdditional

protected void dumpLogAdditional(StringBuffer sb,
                                 boolean verbose)


Copyright 2004,2008 Oracle. All rights reserved.