public final class FileSummaryLN extends LN
The contents of the FileSummaryLN are not fixed until the moment at which the LN is added to the log. A base summary object contains the summary last added to the log. A tracked summary object contains live summary info being updated in real time. The tracked summary is added to the base summary just before logging it, and then the tracked summary is reset. This ensures that the logged summary will accurately reflect the totals calculated at the point in the log where the LN is added.
This is all done in the writeToLog method, which operates under the log write latch. All utilization tracking must be done under the log write latch.
In record version 1, obsolete offset tracking was added and multiple records are stored for a single file rather than a single record. Each record contains the offsets that were tracked since the last record was written.
The key is 8 bytes: 4 bytes for the file number followed by 4 bytes for the sequence number. The lowest valued key for a given file contains the most recent summary information, while to get a complete list of obsolete offsets all records for the file must be read. A range search using just the first 4 bytes can be used to find the most recent record -- this is possible because the sequence number values are decreasing over time for a given file. Here are example keys for three summary records in file 1:
(file=1, sequence=Integer.MAX_VALUE - 300) (file=1, sequence=Integer.MAX_VALUE - 200) (file=1, sequence=Integer.MAX_VALUE - 100)
The sequence number is the number of obsolete entries counted so far, subtracted from Integer.MAX_VALUE to cause the latest written record to have the lowest key.
Version 0: Keys are old format strings. No obsolete detail is present.
Version 1: Keys are two 4 byte integers: {file, sequence}. Obsolete detail is present. Some offsets may be invalid if RMW was used.
Version 2: The RMW problem with invalid offsets was corrected. There is no data format change; all versions of JE 2.0.x can read version 1.
UtilizationProfile
LN.LNWriteFailureException
NULL_NODE_ID
Constructor and Description |
---|
FileSummaryLN()
Creates an empty LN to be filled in from the log.
|
FileSummaryLN(FileSummary baseSummary)
Creates a new LN with a given base summary.
|
Modifier and Type | Method and Description |
---|---|
void |
addExtraMarshaledMemorySize(BIN parentBIN)
Adds the extra memory used by obsoleteOffsets to the parent BIN memory
size.
|
java.lang.String |
beginTag() |
void |
dumpKey(java.lang.StringBuilder sb,
byte[] key) |
protected void |
dumpLogAdditional(java.lang.StringBuilder sb,
boolean verbose)
Dump additional fields.
|
java.lang.String |
dumpString(int nSpaces,
boolean dumpTags) |
java.lang.String |
endTag() |
FileSummary |
getBaseSummary()
Returns the base summary for the file that is stored in the LN.
|
static long |
getFileNumber(byte[] bytes)
Convert a FileSummaryLN key from a byte array to a long.
|
int |
getLogSize()
This log entry type is configured to perform marshaling (getLogSize and
writeToLog) under the write log mutex.
|
protected LogEntryType |
getLogType(boolean isInsert,
boolean isTransactional)
Return the correct log type for a FileSummaryLN.
|
long |
getMemorySizeIncludedByParent()
Overrides this method to add space occupied by this object's fields.
|
PackedOffsets |
getObsoleteOffsets()
Returns the obsolete offsets for the file.
|
TrackedFileSummary |
getTrackedSummary()
Returns the tracked summary, or null if setTrackedSummary was not
called.
|
static boolean |
hasStringKey(byte[] bytes)
Returns true if the given key for this LN is a String file number key.
|
boolean |
logicalEquals(Loggable other) |
(package private) void |
makeDeleted()
Clear out the obsoleteOffsets to save memory when the LN is deleted.
|
static LN |
makeDeletedLN()
Creates a deleted FileSummaryLN.
|
static byte[] |
makeFullKey(long fileNum,
int sequence)
Returns the full two-part key for a given file number and unique
sequence.
|
static byte[] |
makePartialKey(long fileNum)
Returns the first 4 bytes of the key for the given file number.
|
void |
postFetchInit(DatabaseImpl db,
long sourceLsn)
Initialize a node that has been faulted in from the log.
|
void |
readFromLog(java.nio.ByteBuffer itemBuffer,
int entryVersion)
Initialize this object from the data in itemBuf.
|
void |
setTrackedSummary(TrackedFileSummary trackedSummary)
Sets the live summary object that will be added to the base summary at
the time the LN is logged.
|
java.lang.String |
toString()
Default toString method at the root of the tree.
|
void |
writeToLog(java.nio.ByteBuffer logBuffer)
Serialize this object into the buffer.
|
accountForDeferredWriteSubtreeRemoval, accountForSubtreeRemoval, copyEntryData, createLogEntry, delete, dumpLog, getData, getGenericLogType, getLastLoggedSize, getVLSNSequence, incFetchStats, isDeleted, isDirty, isEvictable, isEvictableInexact, isLN, isValidForDelete, log, log, makeLN, makeLN, modify, optionalLog, optionalLogProvisional, rebuildINList, releaseMemoryBudget, resolvePartialEntry, setDirty, setEmpty, setEntry, setEntry, setLastLoggedSize, setVLSNSequence
containsDuplicates, dump, getLevel, getTransactionId, getType, isBIN, isCompressible, isIN, latchShared, latchShared, releaseLatch, verify
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getTransactionId
public FileSummaryLN(FileSummary baseSummary)
public FileSummaryLN()
public static LN makeDeletedLN()
public void setTrackedSummary(TrackedFileSummary trackedSummary)
public TrackedFileSummary getTrackedSummary()
public FileSummary getBaseSummary()
public PackedOffsets getObsoleteOffsets()
public static boolean hasStringKey(byte[] bytes)
public static long getFileNumber(byte[] bytes)
public static byte[] makePartialKey(long fileNum)
public static byte[] makeFullKey(long fileNum, int sequence)
sequence
- is a unique identifier for the LN for the given file,
and must be greater than the last sequence.public void postFetchInit(DatabaseImpl db, long sourceLsn) throws DatabaseException
postFetchInit
in class Node
DatabaseException
- from subclasses.public java.lang.String toString()
Node
public java.lang.String dumpString(int nSpaces, boolean dumpTags)
dumpString
in class LN
protected void dumpLogAdditional(java.lang.StringBuilder sb, boolean verbose)
dumpLogAdditional
in class LN
protected LogEntryType getLogType(boolean isInsert, boolean isTransactional)
getLogType
in class LN
public int getLogSize()
getLogSize
in interface Loggable
getLogSize
in class LN
LN.getLogSize()
public void writeToLog(java.nio.ByteBuffer logBuffer)
Loggable
writeToLog
in interface Loggable
writeToLog
in class LN
logBuffer
- is the destination bufferLN.writeToLog(java.nio.ByteBuffer)
public void readFromLog(java.nio.ByteBuffer itemBuffer, int entryVersion)
Loggable
readFromLog
in interface Loggable
readFromLog
in class LN
LN.readFromLog(java.nio.ByteBuffer, int)
public boolean logicalEquals(Loggable other)
logicalEquals
in interface Loggable
logicalEquals
in class LN
Should never be replicated.
public long getMemorySizeIncludedByParent()
getMemorySizeIncludedByParent
in class LN
void makeDeleted()
makeDeleted
in class LN
public void addExtraMarshaledMemorySize(BIN parentBIN)
The obsoleteOffsets memory size is not intially budgeted in the usual way because PackedOffsets.pack (which changes the memory size) is called during marshalling (see getOffset). This amount is not counted in the parent IN size in the usual way, because LN logging / marshalling occurs after the LN is inserted in the BIN and its memory size has been counted (see CursorImpl.putInternal).
Note that the tree memory usage cannot be updated directly in getOffsets because the tree memory usage must always be the sum of all IN sizes, and it is reset to this sum each checkpoint.
addExtraMarshaledMemorySize
in class LN
Copyright (c) 2004-2012 Oracle. All rights reserved.