public class IndexSegment extends AbstractBTree
Note: iterators returned by this class do not support removal (the nodes and leaves will all refuse mutation operations).
| Modifier and Type | Class and Description |
|---|---|
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. |
AbstractBTree.IBTreeCountersbranchingFactor, debug, DEBUG, dumpLog, error, ERROR_CLOSED, ERROR_ERROR_STATE, ERROR_LESS_THAN_ZERO, ERROR_READ_ONLY, ERROR_TOO_LARGE, ERROR_TRANSIENT, INFO, log, metadata, ndistinctOnWriteRetentionQueue, nodeSer, readOnly, root, store, storeCache, writeRetentionQueue| Constructor and Description |
|---|
IndexSegment(IndexSegmentStore fileStore)
Open a read-only index segment.
|
| Modifier and Type | Method and Description |
|---|---|
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. |
ICheckpoint |
getCheckpoint()
Returns the most recent
ICheckpoint record. |
ICounter |
getCounter()
Operation is disallowed - the counter is only stored in the mutable
BTree. |
IDirtyListener |
getDirtyListener()
Return the
IDirtyListener. |
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. |
long |
getMetadataAddr()
The address at which the most recent
IndexMetadata record was
written. |
BTree |
getMutableBTree()
The
BTree that is absorbing writes for the view. |
long |
getNodeCount()
The #of non-leaf nodes in the
AbstractBTree. |
long |
getRecordVersion()
The value of the record version number that will be assigned to the next
node or leaf written onto the backing store.
|
long |
getRevisionTimestamp()
The timestamp associated with unisolated writes on this index.
|
long |
getRootAddr()
The address of the last written root of the persistent data structure
-or-
0L if there is no root. |
int |
getSourceCount()
The #of
AbstractBTrees sources for the view. |
AbstractBTree[] |
getSources()
An array containing the ordered sources in the view.
|
IndexSegmentStore |
getStore()
The backing store.
|
long |
handleCommit(long commitTime)
Flush dirty state to the store in preparation for an atomic commit and
return the address from which the persistence capable data structure may
be reloaded.
|
void |
invalidate(Throwable t)
Mark an
ICommitter as invalid. |
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.
|
void |
setDirtyListener(IDirtyListener listener)
Set or clear the listener (there can be only one).
|
void |
setLastCommitTime(long lastCommitTime)
Sets the lastCommitTime.
|
String |
toString()
Fast summary information about the B+Tree.
|
long |
writeCheckpoint()
Checkpoint operation must
#flush() dirty nodes, dirty persistent
data structures, etc, write a new Checkpoint record on the
backing store, save a reference to the current Checkpoint, and
return the address of that Checkpoint record. |
Checkpoint |
writeCheckpoint2()
Checkpoint operation must
#flush() dirty nodes, dirty persistent
data structures, etc, write a new Checkpoint record on the
backing store, save a reference to the current Checkpoint, and
return the address of that Checkpoint record. |
assertNotReadOnly, assertNotTransient, contains, contains, decodeRecordAddr, dump, dump, dumpPages, encodeRecordAddr, getBranchingFactor, getBtreeCounters, getContainsTuple, getCounters, getIndexMetadata, getLevel, getLevel, getLookupTuple, getNodeSerializer, getReadLockCount, getResourceMetadata, getRightMostNode, getRoot, getRootOrFinger, getStatistics, getUtilization, getWriteTuple, indexOf, insert, insert, insert, isBalanced, isOpen, isReadOnly, isTransient, keyAt, lookup, lookup, lookup, putIfAbsent, rangeCheck, rangeCopy, rangeCount, rangeCount, rangeCount, rangeCountExact, rangeCountExactWithDeleted, rangeIterator, rangeIterator, rangeIterator, rangeIterator, rangeIterator, readLock, recycle, remove, remove, remove, reopen, scan, setBTreeCounters, submit, submit, submit, touch, valueAt, valueAt, writeLock, writeNodeOrLeaf, writeNodeRecursive, writeNodeRecursiveCallersThread, writeNodeRecursiveConcurrentpublic IndexSegment(IndexSegmentStore fileStore)
fileStore - The store containing the IndexSegment.IndexSegmentStore.loadIndexSegment()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).ISimpleTreeIndexAccess.isBalanced()public final long getNodeCount()
IBTreeStatisticsAbstractBTree. This is zero (0)
for a new btree.public final long getLeafCount()
IBTreeStatisticsAbstractBTree. This is one (1) for a
new btree.public 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 interface ISimpleTreeIndexAccessgetEntryCount in class AbstractBTreepublic final ICheckpoint getCheckpoint()
ICheckpointProtocolICheckpoint record.ICheckpoint record and never
null.public long getRecordVersion()
ICheckpointProtocolpublic long getMetadataAddr()
ICheckpointProtocolIndexMetadata record was
written.public long getRootAddr()
ICheckpointProtocol0L if there is no root. A 0L return may be
an indication that an empty data structure will be created on demand.public void setLastCommitTime(long lastCommitTime)
ICheckpointProtocol
Note: The lastCommitTime is set by a combination of the
AbstractJournal and Name2Addr based on the actual
commitTime of the commit during which an Name2Addr.Entry for that index was
last committed. It is set for both historical index reads and unisolated
index reads using Name2Addr.Entry.commitTime. The lastCommitTime for an
unisolated index will advance as commits are performed with that index.
lastCommitTime - The timestamp of the last committed state of this index.public long writeCheckpoint()
ICheckpointProtocol#flush() dirty nodes, dirty persistent
data structures, etc, write a new Checkpoint record on the
backing store, save a reference to the current Checkpoint, and
return the address of that Checkpoint record.
Note: A checkpoint by itself is NOT an atomic commit. The commit protocol
is at the store level and uses Checkpoints to ensure that the
state of the persistence capable data structure is current on the backing
store.
Checkpoint record for the
persistence capable was written onto the store. The data
structure can be reloaded from this Checkpoint record.public Checkpoint writeCheckpoint2()
ICheckpointProtocol#flush() dirty nodes, dirty persistent
data structures, etc, write a new Checkpoint record on the
backing store, save a reference to the current Checkpoint, and
return the address of that Checkpoint record.
Note: A checkpoint by itself is NOT an atomic commit. The commit protocol
is at the store level and uses Checkpoints to ensure that the
state of the persistence capable data structure is current on the backing
store.
Checkpoint record for the persistent data structure
which was written onto the store. The persistent data structure
can be reloaded from this Checkpoint record.public IDirtyListener getDirtyListener()
ICheckpointProtocolIDirtyListener.public void setDirtyListener(IDirtyListener listener)
ICheckpointProtocollistener - The listener.public long handleCommit(long commitTime)
ICommittercommitTime - The timestamp assigned to the commit.public void invalidate(Throwable t)
ICommitterICommitter as invalid. This will prevent it from allowing
any writes through to the backing store.t - A cause (required).https://jira.blazegraph.com/browse/BLZG-1953public String toString()
Overridden to be thread-safe without requiring any locks.
toString in class AbstractBTreepublic void close()
close in interface ICheckpointProtocolclose in class AbstractBTreepublic final IndexSegmentStore getStore()
Overridden to a more constrained type.
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.protected 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 interface ICheckpointProtocolgetLastCommitTime in class AbstractBTreeICheckpointProtocol.getLastCommitTime()public 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 interface ISimpleIndexAccessremoveAll 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 keyIllegalArgumentException - 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)
AbstractBTreenewLeafCursor in class AbstractBTreepublic IndexSegment.ImmutableLeafCursor newLeafCursor(byte[] key)
AbstractBTreenewLeafCursor 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.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.