Cached meta-data about a single B-Tree within a {@link Volume}. A Tree
object keeps track of the Volume
, the index root page, the index depth, various other statistics and the {@link 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 {@link Transaction} is notvisible 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 {@link Transaction}); all but one such transaction must roll back.
Tree
instances are created by {@link 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 {@link Volume#getTree(String,boolean)} for the samename 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 {@link Accumulator} instances thatmay 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.