|
||||||||||
| 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. |
| 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, 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. |
int |
getEntryCount()
The #of entries (aka values) in the AbstractBTree. |
int |
getHeight()
The height of the btree. |
long |
getLastCommitTime()
The value of the IndexSegmentCheckpoint.commitTime field. |
int |
getLeafCount()
The #of leaf nodes in the AbstractBTree. |
int |
getNodeCount()
The #of non-leaf nodes in the AbstractBTree. |
IndexSegmentStore |
getStore()
Overridden to a more constrained type. |
boolean |
isReadOnly()
Return true iff this B+Tree is read-only. |
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()
Note: This is synchronized in order to prevent a concurrent process from closing the IndexSegment during this method. |
| 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()
AbstractBTreeheight := 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 class AbstractBTreepublic final int getLeafCount()
AbstractBTreeAbstractBTree. This is one (1) for a
new btree.
getLeafCount in class AbstractBTreepublic final int getNodeCount()
AbstractBTreeAbstractBTree. This is zero (0)
for a new btree.
getNodeCount in class AbstractBTreepublic final int getEntryCount()
AbstractBTreeAbstractBTree. This is zero
(0) for a new B+Tree. Note that this value is tracked explicitly so it
requires no IOs.
getEntryCount in class AbstractBTreepublic String toString()
IndexSegment during this method. In particular,
getEntryCount() uses the IndexSegmentCheckpoint and that
is only available while the IndexSegmentStore is open.
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 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 boolean isReadOnly()
AbstractBTreetrue iff this B+Tree is read-only.
isReadOnly in class AbstractBTreepublic final long getLastCommitTime()
IndexSegmentCheckpoint.commitTime field.
getLastCommitTime in class AbstractBTreepublic 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).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||