com.bigdata.service
Class CommitTimeIndex

java.lang.Object
  extended by com.bigdata.btree.AbstractBTree
      extended by com.bigdata.btree.BTree
          extended by com.bigdata.service.CommitTimeIndex
All Implemented Interfaces:
IAutoboxBTree, IBTreeStatistics, ICheckpointProtocol, IIndex, IIndexLocalCounter, ILinearList, ILocalBTreeView, IRangeQuery, ISimpleBTree, ICounterSetAccess, ICommitter

public class CommitTimeIndex
extends BTree

BTree whose keys are commit times. No values are stored in the BTree.

Version:
$Id: CommitTimeIndex.java 4523 2011-05-18 18:14:45Z thompsonbry $
Author:
Bryan Thompson
TODO:
Subclass BTree for long keys and arbitrary values and move the find() and findNext() methods onto that class and make the value type generic. That same logic is replicated right now in several places and there is no reason for that. Allow 0L for find(long), but check all callers first to see who might use that for error checking and then modify callers using 1L to use 0L. In fact, find(long) should probably accept the value to be returned in case there is no LTE entry (that is, in case the index is empty).

Nested Class Summary
protected static class CommitTimeIndex.TupleSerializer
          Encapsulates key and value formation.
 
Nested classes/interfaces inherited from class com.bigdata.btree.BTree
BTree.Counter, BTree.LeafCursor, BTree.NodeFactory, BTree.PartitionedCounter, BTree.Stack
 
Nested classes/interfaces inherited from class com.bigdata.btree.AbstractBTree
AbstractBTree.IBTreeCounters
 
Field Summary
 
Fields inherited from class com.bigdata.btree.BTree
counter, height, nentries, nleaves, nnodes, recordVersion
 
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, readOnly, 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
CommitTimeIndex(IRawStore store, Checkpoint checkpoint, IndexMetadata metadata, boolean readOnly)
          Load from the store.
 
Method Summary
 void add(long commitTime)
          Add an entry for the commitTime.
static CommitTimeIndex createTransient()
          Create a transient instance.
protected  long decodeKey(byte[] key)
           
protected  byte[] encodeKey(long commitTime)
          Encodes the commit time into a key.
 long find(long timestamp)
          Return the largest commitTime that is less than or equal to the given timestamp.
 long findIndexOf(long timestamp)
          Find the index having the largest timestamp that is less than or equal to the given timestamp.
 long findNext(long timestamp)
          Find the first commit time strictly greater than the timestamp.
 
Methods inherited from class com.bigdata.btree.BTree
_reopen, asReadOnly, create, createTransient, createViewCheckpoint, fireDirtyEvent, getBloomFilter, getCheckpoint, getCounter, getDirtyListener, getEntryCount, getHeight, getLastCommitTime, getLeafCount, getMetadataAddr, getMutableBTree, getNodeCount, getRecordVersion, getRevisionTimestamp, getRootAddr, getSourceCount, getSources, getStore, handleCommit, load, load, needsCheckpoint, newLeafCursor, newLeafCursor, readBloomFilter, removeAll, setDirtyListener, setIndexMetadata, setLastCommitTime, writeCheckpoint, writeCheckpoint2
 
Methods inherited from class com.bigdata.btree.AbstractBTree
assertNotReadOnly, assertNotTransient, close, contains, contains, decodeRecordAddr, dump, dump, encodeRecordAddr, getBranchingFactor, getBtreeCounters, getContainsTuple, getCounters, getIndexMetadata, getLookupTuple, getNodeSerializer, getResourceMetadata, getRightMostNode, getRoot, getRootOrFinger, getStatistics, getUtilization, getWriteTuple, indexOf, insert, insert, insert, isOpen, isReadOnly, isTransient, keyAt, lookup, lookup, lookup, rangeCheck, rangeCopy, rangeCount, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator, rangeIterator, rangeIterator, readNodeOrLeaf, recycle, 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
 

Constructor Detail

CommitTimeIndex

public CommitTimeIndex(IRawStore store,
                       Checkpoint checkpoint,
                       IndexMetadata metadata,
                       boolean readOnly)
Load from the store.

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

createTransient

public static CommitTimeIndex createTransient()
Create a transient instance.

Returns:
The new instance.

encodeKey

protected byte[] encodeKey(long commitTime)
Encodes the commit time into a key.

Parameters:
commitTime - The commit time.
Returns:
The corresponding key.

decodeKey

protected long decodeKey(byte[] key)

find

public long find(long timestamp)
Return the largest commitTime that is less than or equal to the given timestamp. This is used primarily to locate the commit point 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 point that not later than the start time of the transaction.

Parameters:
timestamp - The given timestamp.
Returns:
The timestamp -or- -1L iff there is no entry in the index which satisifies the probe.
Throws:
IllegalArgumentException - if timestamp is less than or equals to ZERO (0L).

findNext

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

Parameters:
timestamp - The timestamp. A value of ZERO (0) may be used to find the first commit time.
Returns:
The commit time -or- -1L if there is no commit record whose timestamp is strictly greater than timestamp.

findIndexOf

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

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

add

public void add(long commitTime)
Add an entry for the commitTime.

Parameters:
commitTime - A timestamp representing a commit time.
Throws:
IllegalArgumentException - if commitTime is 0L.


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