public abstract class BPlusTree<L,T extends L> extends DataStructure implements IgniteTree<L,T>
Modifier and Type | Class and Description |
---|---|
protected static class |
BPlusTree.DestroyBag
Reuse bag for destroy.
|
IgniteTree.InvokeClosure<T>, IgniteTree.OperationType
Modifier and Type | Field and Description |
---|---|
protected long |
metaPageId |
Modifier | Constructor and Description |
---|---|
protected |
BPlusTree(String name,
int cacheId,
PageMemory pageMem,
IgniteWriteAheadLogManager wal,
AtomicLong globalRmvId,
long metaPageId,
ReuseList reuseList) |
protected |
BPlusTree(String name,
int cacheId,
PageMemory pageMem,
IgniteWriteAheadLogManager wal,
AtomicLong globalRmvId,
long metaPageId,
ReuseList reuseList,
IOVersions<? extends BPlusInnerIO<L>> innerIos,
IOVersions<? extends BPlusLeafIO<L>> leafIos) |
Modifier and Type | Method and Description |
---|---|
protected abstract int |
compare(BPlusIO<L> io,
long pageAddr,
int idx,
L row) |
long |
destroy()
Destroys tree.
|
long |
destroy(IgniteInClosure<L> c)
Destroys tree.
|
GridCursor<T> |
find(L lower,
L upper)
Returns a cursor from lower to upper bounds inclusive.
|
T |
findFirst()
Returns a value mapped to the lowest key, or
null if tree is empty |
T |
findLast()
Returns a value mapped to the greatest key, or
null if tree is empty |
T |
findOne(L row)
Returns the value to which the specified key is mapped, or
null if this tree contains no mapping for the
key. |
<R> R |
findOne(L row,
Object x) |
protected Iterable<Long> |
getFirstPageIds(long pageAddr) |
String |
getName() |
protected T |
getRow(BPlusIO<L> io,
long pageAddr,
int idx)
Get a full detached data row.
|
protected abstract T |
getRow(BPlusIO<L> io,
long pageAddr,
int idx,
Object x)
Get data row.
|
protected void |
initTree(boolean initNew)
Initialize new tree.
|
protected void |
initTree(boolean initNew,
int inlineSize)
Initialize new tree.
|
static void |
interruptAll()
Interrupt all operations on all threads and all indexes.
|
void |
invoke(L row,
Object z,
IgniteTree.InvokeClosure<T> c) |
protected BPlusInnerIO<L> |
latestInnerIO() |
protected BPlusLeafIO<L> |
latestLeafIO() |
String |
printTree()
For debug.
|
T |
put(T row)
Put value in this tree.
|
boolean |
putx(T row) |
T |
remove(L row)
Removes the mapping for a key from this tree if it is present.
|
boolean |
removex(L row) |
int |
rootLevel() |
protected void |
setIos(IOVersions<? extends BPlusInnerIO<L>> innerIos,
IOVersions<? extends BPlusLeafIO<L>> leafIos) |
long |
size()
!!!
|
String |
toString() |
static String |
treeName(String instance,
String type) |
void |
validateTree() |
acquirePage, allocatePage, allocatePageNoReuse, getCacheId, init, needWalDeltaRecord, onBeforeReadLock, onBeforeWriteLock, onReadLock, onReadUnlock, onWriteLock, onWriteUnlock, pageSize, randomInt, read, read, readLock, readUnlock, recyclePage, releasePage, tryWriteLock, write, write, write, write, writeLock, writeUnlock, writeUnlock
protected BPlusTree(String name, int cacheId, PageMemory pageMem, IgniteWriteAheadLogManager wal, AtomicLong globalRmvId, long metaPageId, ReuseList reuseList, IOVersions<? extends BPlusInnerIO<L>> innerIos, IOVersions<? extends BPlusLeafIO<L>> leafIos) throws IgniteCheckedException
name
- Tree name.cacheId
- Cache ID.pageMem
- Page memory.wal
- Write ahead log manager.globalRmvId
- Remove ID.metaPageId
- Meta page ID.reuseList
- Reuse list.innerIos
- Inner IO versions.leafIos
- Leaf IO versions.IgniteCheckedException
- If failed.protected BPlusTree(String name, int cacheId, PageMemory pageMem, IgniteWriteAheadLogManager wal, AtomicLong globalRmvId, long metaPageId, ReuseList reuseList) throws IgniteCheckedException
name
- Tree name.cacheId
- Cache ID.pageMem
- Page memory.wal
- Write ahead log manager.globalRmvId
- Remove ID.metaPageId
- Meta page ID.reuseList
- Reuse list.IgniteCheckedException
- If failed.protected void setIos(IOVersions<? extends BPlusInnerIO<L>> innerIos, IOVersions<? extends BPlusLeafIO<L>> leafIos)
innerIos
- Inner IO versions.leafIos
- Leaf IO versions.public final String getName()
protected final void initTree(boolean initNew) throws IgniteCheckedException
initNew
- True
if new tree should be created.IgniteCheckedException
- If failed.protected final void initTree(boolean initNew, int inlineSize) throws IgniteCheckedException
initNew
- True
if new tree should be created.inlineSize
- Inline size.IgniteCheckedException
- If failed.public final GridCursor<T> find(L lower, L upper) throws IgniteCheckedException
IgniteTree
find
in interface IgniteTree<L,T extends L>
lower
- Lower bound inclusive or null
if unbounded.upper
- Upper bound inclusive or null
if unbounded.IgniteCheckedException
- If failed.public T findFirst() throws IgniteCheckedException
null
if tree is emptyfindFirst
in interface IgniteTree<L,T extends L>
IgniteCheckedException
- If failed.public T findLast() throws IgniteCheckedException
null
if tree is emptyfindLast
in interface IgniteTree<L,T extends L>
IgniteCheckedException
- If failed.public final <R> R findOne(L row, Object x) throws IgniteCheckedException
row
- Lookup row for exact match.x
- Implementation specific argument, null
always means that we need to return full detached data row.null
.IgniteCheckedException
- If failed.public final T findOne(L row) throws IgniteCheckedException
IgniteTree
null
if this tree contains no mapping for the
key.findOne
in interface IgniteTree<L,T extends L>
row
- Lookup row for exact match.IgniteCheckedException
- If failed.public static String treeName(String instance, String type)
instance
- Instance name.type
- Tree type.public final String printTree() throws IgniteCheckedException
String
.IgniteCheckedException
- If failed.public final void validateTree() throws IgniteCheckedException
IgniteCheckedException
- If failed.public static void interruptAll()
public final T remove(L row) throws IgniteCheckedException
IgniteTree
remove
in interface IgniteTree<L,T extends L>
row
- Lookup row.IgniteCheckedException
- If failed.public final boolean removex(L row) throws IgniteCheckedException
row
- Lookup row.True
if removed row.IgniteCheckedException
- If failed.public void invoke(L row, Object z, IgniteTree.InvokeClosure<T> c) throws IgniteCheckedException
invoke
in interface IgniteTree<L,T extends L>
row
- Key.z
- Implementation specific argument, null
always means that we need a full detached data row.c
- Closure.IgniteCheckedException
- If failed.public final int rootLevel() throws IgniteCheckedException
IgniteCheckedException
- If failed.public final long size() throws IgniteCheckedException
size
in interface IgniteTree<L,T extends L>
IgniteCheckedException
- If failed.public final T put(T row) throws IgniteCheckedException
put
in interface IgniteTree<L,T extends L>
row
- Value to be associated with the specified key.IgniteCheckedException
- If failed.public boolean putx(T row) throws IgniteCheckedException
row
- New value.True
if replaced existing row.IgniteCheckedException
- If failed.public final long destroy() throws IgniteCheckedException
0
, otherwise it should return at least 2
(for meta page and root page), unless this tree is
used as metadata storage, or -1
if we don't have a reuse list and did not do recycling at all.IgniteCheckedException
- If failed.public final long destroy(IgniteInClosure<L> c) throws IgniteCheckedException
c
- Visitor closure. Visits only leaf pages.0
, otherwise it should return at least 2
(for meta page and root page), unless this tree is
used as metadata storage, or -1
if we don't have a reuse list and did not do recycling at all.IgniteCheckedException
- If failed.protected Iterable<Long> getFirstPageIds(long pageAddr)
pageAddr
- Meta page address.protected final BPlusInnerIO<L> latestInnerIO()
protected final BPlusLeafIO<L> latestLeafIO()
protected abstract int compare(BPlusIO<L> io, long pageAddr, int idx, L row) throws IgniteCheckedException
io
- IO.pageAddr
- Page address.idx
- Index of row in the given buffer.row
- Lookup row.Comparator.compare(Object, Object)
.IgniteCheckedException
- If failed.protected final T getRow(BPlusIO<L> io, long pageAddr, int idx) throws IgniteCheckedException
io
- IO.pageAddr
- Page address.idx
- Index.IgniteCheckedException
- If failed.protected abstract T getRow(BPlusIO<L> io, long pageAddr, int idx, Object x) throws IgniteCheckedException
canGetRowFromInner
is true
.io
- IO.pageAddr
- Page address.idx
- Index.x
- Implementation specific argument, null
always means that we need to return full detached data row.IgniteCheckedException
- If failed.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.0.0 Release Date : April 30 2017