public class AbstractCommitTimeIndex<T extends ICommitTimeEntry> extends DelegateBTree implements ILinearList
BTree
mapping commitTime (long integers) to
ICommitTimeEntry
objects.
This class is thread-safe for concurrent readers and writers.
Modifier | Constructor and Description |
---|---|
protected |
AbstractCommitTimeIndex(BTree ndx) |
Modifier and Type | Method and Description |
---|---|
void |
add(T entry)
Add an entry under the commitTime associated with the entry.
|
T |
find(long timestamp)
Return the
IRootBlock identifying the journal having the largest
commitTime that is less than or equal to the given timestamp. |
T |
findByCommitCounter(long commitCounter)
Find the oldest entry whose commit counter is LTE the specified commit
counter.
|
long |
findIndexOf(long commitTime)
Find the index of the entry associated with the largest commitTime that
is less than or equal to the given timestamp.
|
T |
findNext(long timestamp)
Return the first entry whose commitTime is strictly greater than
the timestamp.
|
T |
getEntryByReverseIndex(int index)
Return the entry that is associated with the specified ordinal index
(origin ZERO) counting backwards from the most recent entry (0) towards
the earliest entry (nentries-1).
|
long |
getEntryCount() |
byte[] |
getKey(long commitTime)
Encodes the commit time into a key.
|
T |
getNewestEntry()
Find the the most recent entry (if any).
|
T |
getOldestEntry()
Find and return the oldest entry (if any).
|
Lock |
readLock()
Returns (but does not take) the
ReentrantReadWriteLock.ReadLock . |
void |
removeAll() |
Tuple<T> |
valueAt(long index,
Tuple<T> t) |
Lock |
writeLock()
Returns (but does not take) the
ReentrantReadWriteLock.WriteLock . |
indexOf, keyAt, valueAt
contains, contains, getCounter, getCounters, getIndexMetadata, getResourceMetadata, insert, insert, lookup, lookup, putIfAbsent, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator, remove, remove, submit, submit, submit, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
indexOf, keyAt, valueAt
protected AbstractCommitTimeIndex(BTree ndx)
public byte[] getKey(long commitTime)
commitTime
- The commit time.public Lock readLock()
ReentrantReadWriteLock.ReadLock
.public Lock writeLock()
ReentrantReadWriteLock.WriteLock
.public long getEntryCount()
public T find(long timestamp)
IRootBlock
identifying the journal having the largest
commitTime 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.timestamp
- The given timestamp.null
iff there are no journals in the index that
satisify the probe.IllegalArgumentException
- if timestamp is less than ZERO (0L).public T findNext(long timestamp)
timestamp
- The timestamp. A value of ZERO (0) may be used to find the
first entry.null
if there is
no entry whose timestamp is strictly greater than
timestamp.IllegalArgumentException
- if timestamp is less than ZERO (0L).public long findIndexOf(long commitTime)
commitTime
- The timestamp.-1
iff the index is empty.IllegalArgumentException
- if timestamp is less than ZERO (0L).public void add(T entry)
entry
- The entryIllegalArgumentException
- if commitTime is 0L
.IllegalArgumentException
- if rootBLock is null
.IllegalArgumentException
- if there is already an entry registered under for the
given timestamp.public T getOldestEntry()
null
if there are no entries.public T getNewestEntry()
null
if there are no entries.public T findByCommitCounter(long commitCounter)
null
if there is no such entry.IllegalArgumentException
- if commitCounter LT ZERO (0)
TODO It is possible to improve the performance for this for
large indices using a binary search. Each time we probe the
index we discover a specific commit counter value. If the
value is LT the target, we need to search above that probe.
If GT the target, we need to search below that problem.public T getEntryByReverseIndex(int index)
Note: The effective index is given by (entryCount-1)-index
.
If the effective index is LT ZERO (0) then there is no such entry and
this method will return null
.
index
- The index.null
if there is no such entry.IllegalArgumentException
- if index LT ZERO (0)
public void removeAll()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.