|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.btree.AbstractBTree
com.bigdata.btree.IndexSegment
public class IndexSegment
An index segment is read-only btree corresponding to some key range of a potentially distributed index. The file format of the index segment includes a metadata record, the leaves of the segment in key order, and the nodes of the segment in an arbitrary order. It is possible to map or buffer the part of the file containing the index nodes or the entire file depending on application requirements.
Note: iterators returned by this class do not support removal (the nodes and leaves will all refuse mutation operations).
| Nested Class Summary | |
|---|---|
class |
IndexSegment.ImmutableLeafCursor
Cursor using the double-linked leaves for efficient scans. |
protected static class |
IndexSegment.ImmutableNodeFactory
Factory for immutable nodes and leaves used by the NodeSerializer. |
static class |
IndexSegment.IndexSegmentTupleCursor<E>
Implementation for an immutable IndexSegment. |
| Nested classes/interfaces inherited from class com.bigdata.btree.AbstractBTree |
|---|
AbstractBTree.IBTreeCounters |
| Field Summary |
|---|
| 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 | |
|---|---|
IndexSegment(IndexSegmentStore fileStore)
Open a read-only index segment. |
|
| Method Summary | |
|---|---|
protected void |
_reopen()
This method is responsible for setting up the root leaf (either new or read from the store), the bloom filter, etc. |
void |
close()
Extended to also close the backing file. |
protected void |
finalize()
Extended to explicitly close the IndexSegment and the backing
IndexSegmentStore. |
IndexSegment.ImmutableNodeFactory.ImmutableLeaf |
findLeaf(byte[] key)
|
long |
findLeafAddr(byte[] key)
Find the address of the leaf that would span the key. |
BloomFilter |
getBloomFilter()
Return the optional IBloomFilter, transparently
AbstractBTree.reopen()ing the index if necessary. |
ICounter |
getCounter()
Operation is disallowed - the counter is only stored in the mutable BTree. |
long |
getEntryCount()
The #of entries (aka tuples) in the AbstractBTree. |
int |
getHeight()
The height of the btree. |
long |
getLastCommitTime()
The value of the IndexSegmentCheckpoint.commitTime field. |
long |
getLeafCount()
The #of leaf nodes in the AbstractBTree. |
BTree |
getMutableBTree()
The BTree that is absorbing writes for the view. |
long |
getNodeCount()
The #of non-leaf nodes in the AbstractBTree. |
long |
getRevisionTimestamp()
The timestamp associated with unisolated writes on this index. |
int |
getSourceCount()
The #of AbstractBTrees sources for the view. |
AbstractBTree[] |
getSources()
An array containing the ordered sources in the view. |
IndexSegmentStore |
getStore()
Overridden to a more constrained type. |
IndexSegment.ImmutableLeafCursor |
newLeafCursor(byte[] key)
Return a cursor that may be used to efficiently locate and scan the leaves in the B+Tree. |
IndexSegment.ImmutableLeafCursor |
newLeafCursor(SeekEnum where)
Return a cursor that may be used to efficiently locate and scan the leaves in the B+Tree. |
IndexSegment.ImmutableNodeFactory.ImmutableLeaf |
readLeaf(long addr)
Type-safe method reads the leaf from the backing file given the address of that leaf. |
protected AbstractNode<?> |
readNodeOrLeaf(long addr)
Extended to transparently re-open the backing IndexSegmentStore. |
void |
removeAll()
Remove all entries in the B+Tree. |
String |
toString()
Fast summary information about the B+Tree. |
| Methods inherited from class com.bigdata.btree.AbstractBTree |
|---|
assertNotReadOnly, assertNotTransient, 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, recycle, remove, remove, remove, reopen, setBTreeCounters, submit, submit, submit, touch, valueAt, valueAt, writeNodeOrLeaf, writeNodeRecursive |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IndexSegment(IndexSegmentStore fileStore)
fileStore - The store containing the IndexSegment.IndexSegmentStore.loadIndexSegment()| Method Detail |
|---|
public final int getHeight()
IBTreeStatisticsheight := 0. A btree with a
root node and one level of leaves under it has height := 1.
Note that all leaves of a btree are at the same height (this is what is
means for the btree to be "balanced"). Also note that the height only
changes when we split or join the root node (a btree maintains balance by
growing and shrinking in levels from the top rather than the leaves).
getHeight in interface IBTreeStatisticsgetHeight in class AbstractBTreepublic final long getNodeCount()
IBTreeStatisticsAbstractBTree. This is zero (0)
for a new btree.
getNodeCount in interface IBTreeStatisticsgetNodeCount in class AbstractBTreepublic final long getLeafCount()
IBTreeStatisticsAbstractBTree. This is one (1) for a
new btree.
getLeafCount in interface IBTreeStatisticsgetLeafCount in class AbstractBTreepublic final long getEntryCount()
IBTreeStatisticsAbstractBTree. This is zero
(0) for a new B+Tree. When the B+Tree supports delete markers, this value
also includes tuples which have been marked as deleted.
getEntryCount in interface IBTreeStatisticsgetEntryCount in class AbstractBTreepublic String toString()
Overridden to be thread-safe without requiring any locks.
toString in class AbstractBTreepublic void close()
close in class AbstractBTreepublic final IndexSegmentStore getStore()
getStore in class AbstractBTree
protected void finalize()
throws Throwable
IndexSegment and the backing
IndexSegmentStore. A finalizer is necessary for this class
because we maintain IndexSegments in a weak value cache and do
not explicitly close then before their reference is cleared. This leads
to the IndexSegmentStore being left open. The finalizer fixes
that.
finalize in class ObjectThrowableprotected void _reopen()
AbstractBTreeAbstractBTree.reopen() once AbstractBTree.root has been show to be
null with double-checked locking. When invoked in this
context, the caller is guaranteed to hold a lock on this. This is
done to ensure that at most one thread gets to re-open the index from the
backing store.
_reopen in class AbstractBTreepublic final BloomFilter getBloomFilter()
AbstractBTreeIBloomFilter, transparently
AbstractBTree.reopen()ing the index if necessary.
getBloomFilter in interface ILocalBTreeViewgetBloomFilter in class AbstractBTreenull if there is no bloom
filter (including the case where there is a bloom filter but it
has been disabled since the BTree has grown too large and
the expected error rate of the bloom filter would be too high).public final long getLastCommitTime()
IndexSegmentCheckpoint.commitTime field.
getLastCommitTime in class AbstractBTreepublic final long getRevisionTimestamp()
AbstractBTree
The revision timestamp assigned by this method is
lastCommitTime+1. The reasoning is as follows. Revision
timestamps are assigned by the transaction manager when the transaction
is validated as part of its commit protocol. Therefore, revision
timestamps are assigned after the transaction write set is complete.
Further, the assigned revisionTimestamp will be strictly LT the
commitTime for that transaction. By using lastCommitTime+1
we are guaranteed that the revisionTimestamp for new writes (which will
be part of some future commit point) will always be strictly GT the
revisionTimestamp of historical writes (which were part of some prior
commit point).
Note: Unisolated operations using this timestamp ARE NOT validated. The timestamp is simply applied to the tuple when it is inserted or updated and will become part of the restart safe state of the B+Tree once the unisolated operation participates in a commit.
Note: If an unisolated operation were to execute concurrent with a
transaction commit for the same index then that could produce
inconsistent results in the index and could trigger concurrent
modification errors. In order to avoid such concurrent modification
errors, unisolated operations which are to be mixed with full
transactions MUST ensure that they have exclusive access to the
unisolated index before proceeding. There are two ways to do this: (1)
take the application off line for transactions; (2) submit your unisolated
operations to the IConcurrencyManager which will automatically
impose the necessary constraints on concurrent access to the unisolated
indices.
getRevisionTimestamp in class AbstractBTreeUnsupportedOperationException - always since the IndexSegment is read-only.public final ICounter getCounter()
BTree.
public final void removeAll()
AbstractBTree
Note: The IIndexManager defines methods for registering (adding)
and dropping indices vs removing the entries in an individual
AbstractBTree.
removeAll in class AbstractBTreeUnsupportedOperationException - always.public IndexSegment.ImmutableNodeFactory.ImmutableLeaf readLeaf(long addr)
Note: The parent is NOT set on the leaf but it MAY be defined if the leaf was read from cache.
addr - The address of a leaf.
protected AbstractNode<?> readNodeOrLeaf(long addr)
IndexSegmentStore.
readNodeOrLeaf in class AbstractBTreeaddr - The address in the store.
public IndexSegment.ImmutableNodeFactory.ImmutableLeaf findLeaf(byte[] key)
public long findLeafAddr(byte[] key)
key - The key
IllegalArgumentException - if the key is null.
RuntimeException - if the key does not lie within the optional key-range
constraints for an index partition.public IndexSegment.ImmutableLeafCursor newLeafCursor(SeekEnum where)
AbstractBTree
newLeafCursor in class AbstractBTreepublic IndexSegment.ImmutableLeafCursor newLeafCursor(byte[] key)
AbstractBTree
newLeafCursor in class AbstractBTreekey - The key (required).public BTree getMutableBTree()
ILocalBTreeViewBTree that is absorbing writes for the view.
public int getSourceCount()
ILocalBTreeViewAbstractBTrees sources for the view. This will be ONE
(1) if the view is a BTree.
public AbstractBTree[] getSources()
ILocalBTreeViewAbstractBTree then the
array will contain a single element which is that AbstractBTree.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||