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, VersionedLN

public class LN
extends Node
implements Loggable

An LN represents a Leaf Node in the JE tree.


Nested Class Summary
(package private) static class LN.LNWriteFailureException
           
 
Field Summary
 
Fields inherited from class com.sleepycat.je.tree.Node
NULL_NODE_ID
 
Constructor Summary
LN()
          Create an empty LN, to be filled in from the log.
LN(byte[] data)
           
LN(DatabaseEntry dbt)
           
LN(SizeofMarker marker, DatabaseEntry dbt)
          For Sizeof.
 
Method Summary
(package private)  void accountForDeferredWriteSubtreeRemoval(INList inList, IN subtreeParent)
          No need to do anything, stop the search.
(package private)  void accountForSubtreeRemoval(INList inList, LocalUtilizationTracker localTracker)
          No need to do anything, stop the search.
 void addExtraMarshaledMemorySize(BIN parentBIN)
          Account for FileSummaryLN's extra marshaled memory.
 String beginTag()
           
static byte[] copyEntryData(DatabaseEntry entry)
          Returns a byte array that is a complete copy of the data in a non-partial entry.
(package private)  LNLogEntry createLogEntry(LogEntryType entryType, DatabaseImpl dbImpl, byte[] key, long logAbortLsn, boolean logAbortKnownDeleted, Txn logTxn, ReplicationContext repContext)
           
 void delete()
           
 void dumpKey(StringBuilder sb, byte[] key)
           
 void dumpLog(StringBuilder sb, boolean verbose)
          Write the object into the string buffer for log dumping.
protected  void dumpLogAdditional(StringBuilder sb, boolean verbose)
           
 String dumpString(int nSpaces, boolean dumpTags)
           
 String endTag()
           
 byte[] getData()
           
 LogEntryType getGenericLogType()
          Returns the generic LogEntryType for this node.
 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()
           
protected  LogEntryType getLogType(boolean isInsert, boolean isTransactional)
           
 long getMemorySizeIncludedByParent()
          Compute the approximate size of this node in memory for evictor invocation purposes.
 long getVLSNSequence()
          Called by CursorImpl to get the record version.
 void incFetchStats(EnvironmentImpl envImpl, boolean isMiss)
          We categorize fetch stats by the type of node, so node subclasses update different stats.
 boolean isDeleted()
           
 boolean isDirty()
           
(package private)  boolean isEvictable(long lsn)
          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.
 boolean isLN()
           
(package private)  boolean isValidForDelete()
           
 long log(EnvironmentImpl envImpl, DatabaseImpl dbImpl, byte[] key, long oldLsn, boolean backgroundIO, ReplicationContext repContext)
          Convenience logging method.
 long log(EnvironmentImpl envImpl, DatabaseImpl dbImpl, byte[] key, long oldLsn, Locker locker, WriteLockInfo writeLockInfo, ReplicationContext repContext)
          Convenience logging method.
 boolean logicalEquals(Loggable other)
           
(package private)  void makeDeleted()
           
static LN makeLN(EnvironmentImpl envImpl, byte[] dataParam)
          Create a new LN from a byte array.
static LN makeLN(EnvironmentImpl envImpl, DatabaseEntry dbt)
          Create a new LN from a DatabaseEntry.
 void modify(byte[] newData)
           
 long optionalLog(EnvironmentImpl envImpl, DatabaseImpl dbImpl, byte[] key, byte[] oldKey, long oldLsn, Locker locker, WriteLockInfo writeLockInfo, ReplicationContext repContext)
          Convenience logging method.
 long optionalLogProvisional(EnvironmentImpl envImpl, DatabaseImpl dbImpl, byte[] key, long oldLsn, ReplicationContext repContext)
          Convenience logging method.
 void readFromLog(ByteBuffer itemBuffer, int entryVersion)
          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 releaseMemoryBudget()
          Release the memory budget for any objects referenced by this LN.
static byte[] resolvePartialEntry(DatabaseEntry entry, byte[] foundDataBytes)
          Merges the partial entry with the given byte array, effectively applying a partial entry to an existing record, and returns a enw byte array.
 void setDirty()
           
 byte[] setEmpty()
          Sets data to empty and returns old data.
 void setEntry(DatabaseEntry entry)
          Copies the non-deleted LN's byte array to the entry.
static void setEntry(DatabaseEntry entry, byte[] bytes)
          Copies the given byte array to the entry, copying only partial data if the entry is specified to be partial.
 void setLastLoggedSize(int size)
          Saves the last logged size.
 void setVLSNSequence(long seq)
          Called by LogManager after writing an LN with a newly assigned VLSN, and called by LNLogEntry after reading the LN with the VLSN from the log entry header.
 void writeToLog(ByteBuffer logBuffer)
          Serialize this object into the buffer.
 
Methods inherited from class com.sleepycat.je.tree.Node
containsDuplicates, dump, getLevel, getTransactionId, getType, isBIN, isCompressible, isIN, latchShared, latchShared, postFetchInit, releaseLatch, 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. If VLSNs are preserved for this environment, a VersionedLN will be created instead.


LN

LN(byte[] data)

LN

LN(DatabaseEntry dbt)

LN

public LN(SizeofMarker marker,
          DatabaseEntry dbt)
For Sizeof.

Method Detail

makeLN

public static LN makeLN(EnvironmentImpl envImpl,
                        byte[] dataParam)
Create a new LN from a byte array. Pass a null byte array to create a deleted LN.


makeLN

public static LN makeLN(EnvironmentImpl envImpl,
                        DatabaseEntry dbt)
Create a new LN from a DatabaseEntry.


getData

public byte[] getData()

isDeleted

public boolean isDeleted()

isLN

public boolean isLN()
Overrides:
isLN in class Node

makeDeleted

void makeDeleted()

isDirty

public boolean isDirty()

setDirty

public void setDirty()

getVLSNSequence

public long getVLSNSequence()
Called by CursorImpl to get the record version. If VLSNs are not preserved for this environment, returns -1 which is the sequence for VLSN.NULL_VLSN. If VLSNs are preserved for this environment, this method is overridden by VersionedLN which returns the VLSN sequence.


setVLSNSequence

public void setVLSNSequence(long seq)
Called by LogManager after writing an LN with a newly assigned VLSN, and called by LNLogEntry after reading the LN with the VLSN from the log entry header. If VLSNs are not preserved for this environment, does nothing. If VLSNs are preserved for this environment, this method is overridden by VersionedLN which stores the VLSN sequence.


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(long lsn)
              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 - from subclasses.

delete

public void delete()

modify

public void modify(byte[] newData)

setEmpty

public byte[] setEmpty()
Sets data to empty and returns old data. Called when converting an old format LN in a duplicates DB.


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,
                              LocalUtilizationTracker localTracker)
No need to do anything, stop the search.

Specified by:
accountForSubtreeRemoval in class Node

accountForDeferredWriteSubtreeRemoval

void accountForDeferredWriteSubtreeRemoval(INList inList,
                                           IN subtreeParent)
No need to do anything, stop the search.

Specified by:
accountForDeferredWriteSubtreeRemoval 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

releaseMemoryBudget

public void releaseMemoryBudget()
Release the memory budget for any objects referenced by this LN. For now, only release treeAdmin memory, because treeMemory is handled in aggregate at the IN level. Over time, transition all of the LN's memory budget to this, so we update the memory budget counters more locally. Called when we are releasing a LN for garbage collection.


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 envImpl,
                        DatabaseImpl dbImpl,
                        byte[] key,
                        byte[] oldKey,
                        long oldLsn,
                        Locker locker,
                        WriteLockInfo writeLockInfo,
                        ReplicationContext repContext)
                 throws DatabaseException
Convenience logging method. See logInternal. For a deferred-write database, the logging will not actually occur and a transient LSN may be returned.

Throws:
DatabaseException

optionalLogProvisional

public long optionalLogProvisional(EnvironmentImpl envImpl,
                                   DatabaseImpl dbImpl,
                                   byte[] key,
                                   long oldLsn,
                                   ReplicationContext repContext)
                            throws DatabaseException
Convenience logging method. See logInternal. For a deferred-write database, the logging will not actually occur and a transient LSN may be returned.

Throws:
DatabaseException

log

public long log(EnvironmentImpl envImpl,
                DatabaseImpl dbImpl,
                byte[] key,
                long oldLsn,
                boolean backgroundIO,
                ReplicationContext repContext)
         throws DatabaseException
Convenience logging method. See logInternal.

Throws:
DatabaseException

log

public long log(EnvironmentImpl envImpl,
                DatabaseImpl dbImpl,
                byte[] key,
                long oldLsn,
                Locker locker,
                WriteLockInfo writeLockInfo,
                ReplicationContext repContext)
         throws DatabaseException
Convenience logging method. See logInternal.

Throws:
DatabaseException

createLogEntry

LNLogEntry createLogEntry(LogEntryType entryType,
                          DatabaseImpl dbImpl,
                          byte[] key,
                          long logAbortLsn,
                          boolean logAbortKnownDeleted,
                          Txn logTxn,
                          ReplicationContext repContext)

incFetchStats

public void incFetchStats(EnvironmentImpl envImpl,
                          boolean isMiss)
Description copied from class: Node
We categorize fetch stats by the type of node, so node subclasses update different stats.

Specified by:
incFetchStats in class Node
See Also:
Node.incFetchStats(com.sleepycat.je.dbi.EnvironmentImpl, boolean)

getGenericLogType

public LogEntryType getGenericLogType()
Description copied from class: Node
Returns the generic LogEntryType for this node. Returning the actual type used to log the node is not always possible. Specifically, for LN nodes the generic type is less specific than the actual type used to log the node: + A non-transactional type is always returned. + LOG_INS_LN is returned rather than LOG_UPD_LN. + LOG_DEL_LN is returned rather than LOG_DEL_DUPLN.

Specified by:
getGenericLogType in class Node
See Also:
Node.getGenericLogType()

getLogType

protected LogEntryType getLogType(boolean isInsert,
                                  boolean isTransactional)

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

Specified by:
readFromLog in interface Loggable
Overrides:
readFromLog in class Node
See Also:
Loggable.readFromLog(java.nio.ByteBuffer, int)

logicalEquals

public boolean logicalEquals(Loggable other)
Specified by:
logicalEquals in interface Loggable
Returns:
true if these two loggable items are logically the same. Used for replication testing.
See Also:
Loggable.logicalEquals(com.sleepycat.je.log.Loggable)

dumpLog

public void dumpLog(StringBuilder 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.StringBuilder, boolean)

dumpKey

public void dumpKey(StringBuilder sb,
                    byte[] key)

dumpLogAdditional

protected void dumpLogAdditional(StringBuilder sb,
                                 boolean verbose)

addExtraMarshaledMemorySize

public void addExtraMarshaledMemorySize(BIN parentBIN)
Account for FileSummaryLN's extra marshaled memory. [#17462]


setEntry

public void setEntry(DatabaseEntry entry)
Copies the non-deleted LN's byte array to the entry. Does not support partial data.


setEntry

public static void setEntry(DatabaseEntry entry,
                            byte[] bytes)
Copies the given byte array to the entry, copying only partial data if the entry is specified to be partial. If the byte array is null, clears the entry.


copyEntryData

public static byte[] copyEntryData(DatabaseEntry entry)
Returns a byte array that is a complete copy of the data in a non-partial entry.


resolvePartialEntry

public static byte[] resolvePartialEntry(DatabaseEntry entry,
                                         byte[] foundDataBytes)
Merges the partial entry with the given byte array, effectively applying a partial entry to an existing record, and returns a enw byte array.



Copyright (c) 2004-2012 Oracle. All rights reserved.