com.bigdata.journal
Class CommitRecordIndex

java.lang.Object
  extended by com.bigdata.btree.AbstractBTree
      extended by com.bigdata.btree.BTree
          extended by com.bigdata.journal.CommitRecordIndex
All Implemented Interfaces:
IAutoboxBTree, IIndex, ILinearList, ILocalBTreeView, IRangeQuery, ISimpleBTree, ICommitter

public class CommitRecordIndex
extends BTree

BTree mapping commit times to ICommitRecords. The keys are the long integers corresponding to the timestamps assigned to commit points in the store. The values are CommitRecordIndex.Entry objects recording the commit time of the index and the address of the ICommitRecord for that commit time. A canonicalizing cache is maintained such that the caller will never observe distinct concurrent instances of the same ICommitRecord. This in turn facilitates canonicalizing caches for objects loaded from that ICommitRecord.


Nested Class Summary
static class CommitRecordIndex.CommitRecordIndexTupleSerializer
          Encapsulates key and value formation for the CommitRecordIndex.
static class CommitRecordIndex.Entry
          An entry in the persistent index.
 
Nested classes/interfaces inherited from class com.bigdata.btree.BTree
BTree.Counter, BTree.LeafCursor, BTree.NodeFactory, BTree.PartitionedCounter, BTree.Stack
 
Field Summary
 
Fields inherited from class com.bigdata.btree.BTree
counter, height, nentries, nleaves, nnodes
 
Fields inherited from class com.bigdata.btree.AbstractBTree
branchingFactor, debug, DEBUG, dumpLog, ERROR_CLOSED, ERROR_LESS_THAN_ZERO, ERROR_READ_ONLY, ERROR_TOO_LARGE, ERROR_TRANSIENT, INFO, log, metadata, ndistinctOnWriteRetentionQueue, nodeSer, root, store, storeCache, writeRetentionQueue
 
Fields inherited from interface com.bigdata.btree.IRangeQuery
ALL, CURSOR, DEFAULT, DELETED, FIXED_LENGTH_SUCCESSOR, KEYS, NONE, PARALLEL, READONLY, REMOVEALL, REVERSE, VALS
 
Constructor Summary
CommitRecordIndex(IRawStore store, Checkpoint checkpoint, IndexMetadata metadata)
          Load from the store.
 
Method Summary
 void add(long commitRecordAddr, ICommitRecord commitRecord)
          Add an entry for a commit record.
static CommitRecordIndex create(IRawStore store)
          Create a new instance.
static CommitRecordIndex createTransient()
           
 ICommitRecord fetchCommitRecord(CommitRecordIndex.Entry entry)
          Materialize a commit record, from cache if possible.
 ICommitRecord find(long timestamp)
          Return the ICommitRecord having the largest timestamp that is less than or equal to the given timestamp.
 int findIndexOf(long timestamp)
          Find the index of the ICommitRecord having the largest timestamp that is less than or equal to the given timestamp.
 ICommitRecord findNext(long timestamp)
          Find the first commit record strictly greater than the timestamp.
 ICommitRecord get(long commitTime)
          Return the ICommitRecord with the given timestamp (exact match).
 boolean hasTimestamp(long commitTime)
          Existence test for a commit record with the specified commit timestamp (exact match).
protected  ICommitRecord loadCommitRecord(IRawStore store, long addr)
          Re-load a commit record from the store.
 
Methods inherited from class com.bigdata.btree.BTree
_reopen, create, createTransient, fireDirtyEvent, flush, getBloomFilter, getCheckpoint, getCounter, getDirtyListener, getEntryCount, getHeight, getLastCommitTime, getLeafCount, getMutableBTree, getNodeCount, getSourceCount, getSources, getStore, handleCommit, isReadOnly, load, load, needsCheckpoint, newLeafCursor, newLeafCursor, readBloomFilter, removeAll, setDirtyListener, setIndexMetadata, setLastCommitTime, setReadOnly, writeCheckpoint, writeCheckpoint2
 
Methods inherited from class com.bigdata.btree.AbstractBTree
assertNotReadOnly, assertNotTransient, close, contains, contains, dump, dump, getBranchingFactor, getBtreeCounters, getContainsTuple, getCounters, getDynamicCounterSet, getIndexMetadata, getLookupTuple, getNodeSerializer, getResourceMetadata, getRightMostNode, getRoot, getRootOrFinger, getStaticCounterSet, getUtilization, getWriteTuple, indexOf, insert, insert, insert, isOpen, isTransient, keyAt, lookup, lookup, lookup, rangeCheck, rangeCopy, rangeCount, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator, rangeIterator, rangeIterator, readNodeOrLeaf, remove, remove, remove, reopen, setBTreeCounters, submit, submit, submit, toString, touch, valueAt, valueAt, writeNodeOrLeaf, writeNodeRecursive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.bigdata.btree.IIndex
getCounters, getIndexMetadata, getResourceMetadata, submit, submit, submit
 
Methods inherited from interface com.bigdata.btree.ISimpleBTree
contains, insert, lookup, remove
 
Methods inherited from interface com.bigdata.btree.IAutoboxBTree
contains, insert, lookup, remove
 
Methods inherited from interface com.bigdata.btree.IRangeQuery
rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator
 

Constructor Detail

CommitRecordIndex

public CommitRecordIndex(IRawStore store,
                         Checkpoint checkpoint,
                         IndexMetadata metadata)
Load from the store.

Parameters:
store - The backing store.
checkpoint - The Checkpoint record.
metadataId - The metadata record for the index.
Method Detail

create

public static CommitRecordIndex create(IRawStore store)
Create a new instance.

Parameters:
store - The backing store.
Returns:
The new instance.

createTransient

public static CommitRecordIndex createTransient()

hasTimestamp

public boolean hasTimestamp(long commitTime)
Existence test for a commit record with the specified commit timestamp (exact match).

Parameters:
commitTime - The commit timestamp.
Returns:
true iff such an ICommitRecord exists in the index with that commit timestamp (exact match(.

get

public ICommitRecord get(long commitTime)
Return the ICommitRecord with the given timestamp (exact match).

Parameters:
commitTime - The commit time.
Returns:
The ICommitRecord index or null iff there is no ICommitTimestamp for that commit time.

find

public ICommitRecord find(long timestamp)
Return the ICommitRecord having the largest timestamp that is less than or equal to the given timestamp. This is used primarily to locate the commit record that will serve as the ground state for a transaction having timestamp as its start time. In this context the LTE search identifies the most recent commit state that not later than the start time of the transaction.

Parameters:
timestamp - The given timestamp (may be negative for historical reads or positive for transaction identifiers, but MAY NOT be ITx.UNISOLATED NOR ITx.READ_COMMITTED).
Returns:
The commit record -or- null iff there are no ICommitRecords in the index that satisify the probe.
See Also:
get(long)

findNext

public ICommitRecord findNext(long timestamp)
Find the first commit record strictly greater than the timestamp.

Parameters:
timestamp - The timestamp.
Returns:
The commit record -or- null if there is no commit record whose timestamp is strictly greater than timestamp.

fetchCommitRecord

public ICommitRecord fetchCommitRecord(CommitRecordIndex.Entry entry)
Materialize a commit record, from cache if possible.

Note: This DOES NOT perform lookup of the commit time!

Parameters:
entry - An CommitRecordIndex.Entry.
Returns:
The ICommitRecord.
See Also:
get(long)

findIndexOf

public int findIndexOf(long timestamp)
Find the index of the ICommitRecord having the largest timestamp that is less than or equal to the given timestamp.

Returns:
The index of the ICommitRecord having the largest timestamp that is less than or equal to the given timestamp -or- -1 iff there are no ICommitRecords defined.

loadCommitRecord

protected ICommitRecord loadCommitRecord(IRawStore store,
                                         long addr)
Re-load a commit record from the store.

Parameters:
store - The store.
addr - The address of the ICommitRecord.
Returns:
The ICommitRecord loaded from the specified address.

add

public void add(long commitRecordAddr,
                ICommitRecord commitRecord)
Add an entry for a commit record.

Parameters:
commitRecordAddr - The address at which that commit record was written on the store.
commitRecord - The commit record.
Throws:
IllegalArgumentException - if commitRecord is null.
IllegalArgumentException - if there is already a ICommitRecord registered under for the ICommitRecord.getTimestamp().
IllegalArgumentException - if addr is invalid.


Copyright © 2006-2009 SYSTAP, LLC. All Rights Reserved.