public class Tree extends Object
Cached meta-data about a single B-Tree within a Volume
. A
Tree
object keeps track of the Volume
, the index
root page, the index depth, various other statistics and the
Accumulator
s for a B-Tree.
As of Persistit 3.3, this class supports version within transactions. A new
Tree
created within the cope of a Transaction
is not
visible within the other transactions until it commits. Similarly, if a
Tree
is removed within the scope of a transaction, other
transactions that started before the current transaction commits will
continue to be able to read and write the Tree
. As a
side-effect, the physical storage for a Tree
is not deallocated
until there are no remaining active transactions that started before the
commit timestamp of the current transaction. Concurrent transactions that
attempt to create or remove the same Tree
instance are subject
to a a write-write dependency (see Transaction
); all but one such
transaction must roll back.
Tree
instances are created by
Volume.getTree(String, boolean)
. If the Volume
already
has a B-Tree with the specified name, then the Tree
object
returned by getTree
reflects the stored information. Otherwise,
getTree
can create a new B-Tree. In either case, the
Tree
is merely a transient in-memory cache for the B-Tree
information ultimately stored on disk.
Persistit ensures that Tree
instances are unique, that is, for a
given Volume
and name, there is only one Tree
. if
multiple threads call Volume.getTree(String, boolean)
for the same
name on the same volume, the first such call will create a new
Tree
instance and subsequent calls will return the same
instance.
Each Tree
may have up to 64 Accumulator
instances that
may be used to aggregate statistical information such as counters.
Accumulator
s work within the MVCC transaction scheme to provide
highly concurrent access to a small number of variables that would otherwise
cause a significant performance degradation.
Modifier and Type | Class and Description |
---|---|
static class |
Tree.TreeVersionException
Unchecked wrapper for PersistitException thrown while trying to acquire a
TreeVersion.
|
Modifier and Type | Field and Description |
---|---|
protected Persistit |
_persistit |
static long |
DEFAULT_MAX_WAIT_TIME
Default maximum time to wait for access to this resource.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Object |
getAppCache() |
int |
getDepth() |
long |
getGeneration() |
int |
getHandle() |
Accumulator.MaxAccumulator |
getMaxAccumulator(int index)
Return a
MaxAccumulator for this Tree and the
specified index value between 0 and 63, inclusive. |
Accumulator.MinAccumulator |
getMinAccumulator(int index)
Return a
MinAccumulator for this Tree and the
specified index value between 0 and 63, inclusive. |
String |
getName() |
long |
getRootPageAddr()
Returns the page address of the root page of this
Tree . |
Accumulator.SeqAccumulator |
getSeqAccumulator(int index)
Return a
SeqAccumulator for this Tree and the
specified index value between 0 and 63, inclusive. |
TreeStatistics |
getStatistics() |
String |
getStatusCode() |
static String |
getStatusCode(int state) |
String |
getStatusDisplayString() |
Accumulator.SumAccumulator |
getSumAccumulator(int index)
Return a
SumAccumulator for this Tree and the
specified index value between 0 and 63, inclusive. |
Volume |
getVolume() |
Thread |
getWriterThread() |
int |
hashCode() |
boolean |
isAvailable(boolean writer) |
boolean |
isDeleted() |
boolean |
isTemporary() |
boolean |
isValid() |
void |
setAppCache(Object appCache)
Store an Object with this Tree for the convenience of an application.
|
String |
toString() |
public static final long DEFAULT_MAX_WAIT_TIME
protected final Persistit _persistit
public boolean isDeleted() throws TimeoutException, PersistitInterruptedException
public Volume getVolume()
Tree
.public String getName()
Tree
's namepublic long getRootPageAddr()
Tree
. The
root page will be a data page if the Tree
has only one page,
or will be the top index page of the B-Tree.public int getDepth()
Tree
.public long getGeneration()
public TreeStatistics getStatistics()
TreeStatistics
object containing approximate
counts of records added, removed and fetched from this
Treepublic String toString()
Tree
, including its
name, its internal tree index, its root page address, and its
depth.public void setAppCache(Object appCache)
appCache
- the object to be cached for application convenience.public Object getAppCache()
public int getHandle()
Tree
in the
journalpublic Accumulator.SumAccumulator getSumAccumulator(int index) throws PersistitException
SumAccumulator
for this Tree
and the
specified index value between 0 and 63, inclusive. If the
Tree
does not yet have an Accumulator
with the
specified index, this method creates one. Otherwise the previously
created Accumulator
, which must be a
SumAccumulator
, is returned.index
- Application-controlled value between 0 and 63, inclusive.Accumulator
IllegalStateException
- if the previously created instance is not a
SumAccumulator
PersistitException
public Accumulator.SeqAccumulator getSeqAccumulator(int index) throws PersistitException
SeqAccumulator
for this Tree
and the
specified index value between 0 and 63, inclusive. If the
Tree
does not yet have an Accumulator
with the
specified index, this method creates one. Otherwise the previously
created Accumulator
, which must be a
SeqAccumulator
, is returned.index
- Application-controlled value between 0 and 63, inclusive.Accumulator
IllegalStateException
- if the previously created instance is not a
SeqAccumulator
PersistitException
public Accumulator.MinAccumulator getMinAccumulator(int index) throws PersistitException
MinAccumulator
for this Tree
and the
specified index value between 0 and 63, inclusive. If the
Tree
does not yet have an Accumulator
with the
specified index, this method creates one. Otherwise the previously
created Accumulator
, which must be a
MinAccumulator
, is returned.index
- Application-controlled value between 0 and 63, inclusive.Accumulator
IllegalStateException
- if the previously created instance is not a
MinAccumulator
PersistitException
public Accumulator.MaxAccumulator getMaxAccumulator(int index) throws PersistitException
MaxAccumulator
for this Tree
and the
specified index value between 0 and 63, inclusive. If the
Tree
does not yet have an Accumulator
with the
specified index, this method creates one. Otherwise the previously
created Accumulator
, which must be a
MaxAccumulator
, is returned.index
- Application-controlled value between 0 and 63, inclusive.Accumulator
IllegalStateException
- if the previously created instance is not a
MaxAccumulator
PersistitException
public boolean isAvailable(boolean writer)
public boolean isValid()
public boolean isTemporary()
public String getStatusCode()
public String getStatusDisplayString()
public static String getStatusCode(int state)
public Thread getWriterThread()
Copyright © 2025 Open Identity Platform Community. All rights reserved.