Class OpenBTree
- java.lang.Object
-
- org.apache.derby.impl.store.access.btree.OpenBTree
-
- Direct Known Subclasses:
BTreeController,BTreeCostController,BTreeScan
public class OpenBTree extends java.lang.ObjectAn open b-tree contains fields and methods common to scans and controllers.Concurrency Notes
An instance of an open b-tree is owned by a single context. The b-tree code assumes that the context ensures that only one thread at a time is using the open b-tree. The open b-tree itself does not enforce or check this.
-
-
Field Summary
Fields Modifier and Type Field Description protected LogicalUndobtree_undoprotected ContainerHandlecontainerThe (open) container which contains the b-tree.protected longerr_containeridThe conglomerate containerid for error reporting.private BTreeLockingPolicyinit_btree_locking_policyThe Locking Policy to use for for access to this btree.private BTreeinit_conglomerateThe following group of fields are all basic input parameters which are provided by the calling code when doing any sort of operation requiring an open conglomerate (openScan(), open(), openCostController(), ...).private booleaninit_holdprotected intinit_lock_levelTable or page locking?protected TransactionManagerinit_open_user_scansThe user transaction that opened this B-tree.private intinit_openmodeThe ContainerHandle mode the container is opened with.private Transactioninit_rawtranprivate TransactionManagerinit_xact_managerThe TransactionManager that open'd this btree.protected OpenConglomerateScratchSpaceruntime_memscratch space used for stuff like templates, export rows, ...
-
Constructor Summary
Constructors Constructor Description OpenBTree()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckConsistency()Check consistency of a btree.voidclose()Close the open conglomerate.voiddebugConglomerate()Dump information about tree into the log.boolean[]getColumnSortOrderInfo()BTreegetConglomerate()ContainerHandlegetContainer()ContainerHandlegetContainerHandle()Return the container handle.longgetEstimatedRowCount()Get the total estimated number of rows in the container.intgetHeight()get height of the tree.booleangetHold()BTreeLockingPolicygetLockingPolicy()intgetLockLevel()intgetOpenMode()TransactiongetRawTran()OpenConglomerateScratchSpacegetRuntimeMem()SpaceInfogetSpaceInfo()TransactionManagergetXactMgr()Public Accessors of This class:voidinit(TransactionManager open_user_scans, TransactionManager xact_manager, ContainerHandle input_container, Transaction rawtran, boolean hold, int open_mode, int lock_level, BTreeLockingPolicy btree_locking_policy, BTree conglomerate, LogicalUndo undo, DynamicCompiledOpenConglomInfo dynamic_info)Initialize the open conglomerate.booleanisClosed()(package private) voidisIndexableRowConsistent(DataValueDescriptor[] row)Check if all the columns are Indexable and Storable.booleanisTableLocked()is the open btree table locked?ContainerHandlereopen()Open the container after it has been closed previously.voidsetEstimatedRowCount(long count)Set the total estimated number of rows in the container.voidsetLockingPolicy(BTreeLockingPolicy policy)static booleantest_errors(OpenBTree open_btree, java.lang.String debug_string, BTreeRowPosition pos, BTreeLockingPolicy btree_locking_policy, LeafControlRow leaf, boolean input_latch_released)Testing infrastructure to cause unusual paths through the code.
-
-
-
Field Detail
-
init_conglomerate
private BTree init_conglomerate
The following group of fields are all basic input parameters which are provided by the calling code when doing any sort of operation requiring an open conglomerate (openScan(), open(), openCostController(), ...). These are just saved values from what was initially input.
-
init_xact_manager
private TransactionManager init_xact_manager
The TransactionManager that open'd this btree. In the case of Internal transactions used by split this will be the internal transaction, and init_open_user_scans will be the user transaction that began the internal transaction.
-
init_rawtran
private Transaction init_rawtran
-
init_openmode
private int init_openmode
The ContainerHandle mode the container is opened with. Remember this so that if the BTree needs to do SMO with another transaction, it would open the container with the same mode.
-
init_lock_level
protected int init_lock_level
Table or page locking?
-
init_hold
private boolean init_hold
-
init_btree_locking_policy
private BTreeLockingPolicy init_btree_locking_policy
The Locking Policy to use for for access to this btree.
-
container
protected ContainerHandle container
The (open) container which contains the b-tree.
-
err_containerid
protected long err_containerid
The conglomerate containerid for error reporting.
-
init_open_user_scans
protected TransactionManager init_open_user_scans
The user transaction that opened this B-tree.
-
btree_undo
protected LogicalUndo btree_undo
-
runtime_mem
protected OpenConglomerateScratchSpace runtime_mem
scratch space used for stuff like templates, export rows, ...
-
-
Method Detail
-
getXactMgr
public final TransactionManager getXactMgr()
Public Accessors of This class:
-
getRawTran
public final Transaction getRawTran()
-
getLockLevel
public final int getLockLevel()
-
getContainer
public final ContainerHandle getContainer()
-
getOpenMode
public final int getOpenMode()
-
getConglomerate
public final BTree getConglomerate()
-
getHold
public final boolean getHold()
-
getLockingPolicy
public final BTreeLockingPolicy getLockingPolicy()
-
setLockingPolicy
public final void setLockingPolicy(BTreeLockingPolicy policy)
-
isClosed
public final boolean isClosed()
-
getRuntimeMem
public final OpenConglomerateScratchSpace getRuntimeMem()
-
getEstimatedRowCount
public long getEstimatedRowCount() throws StandardExceptionGet the total estimated number of rows in the container.The number is a rough estimate and may be grossly off. In general the server will cache the row count and then occasionally write the count unlogged to a backing store. If the system happens to shutdown before the store gets a chance to update the row count it may wander from reality.
This call is currently only supported on Heap conglomerates, it will throw an exception if called on btree conglomerates.
- Returns:
- The total estimated number of rows in the conglomerate.
- Throws:
StandardException- Standard exception policy.
-
setEstimatedRowCount
public void setEstimatedRowCount(long count) throws StandardExceptionSet the total estimated number of rows in the container.Often, after a scan, the client of RawStore has a much better estimate of the number of rows in the container than what store has. For instance if we implement some sort of update statistics command, or just after a create index a complete scan will have been done of the table. In this case this interface allows the client to set the estimated row count for the container, and store will use that number for all future references.
This call is currently only supported on Heap conglomerates, it will throw an exception if called on btree conglomerates.
- Parameters:
count- the estimated number of rows in the container.- Throws:
StandardException- Standard exception policy.
-
checkConsistency
public void checkConsistency() throws StandardExceptionCheck consistency of a btree.Read in root and check consistency of entire tree. Currently raises sanity check errors.
RESOLVE (mikem) if this is to be supported in non-sanity servers what should it do?
- Throws:
StandardException- Standard exception policy.
-
isTableLocked
public boolean isTableLocked()
is the open btree table locked?
-
init
public void init(TransactionManager open_user_scans, TransactionManager xact_manager, ContainerHandle input_container, Transaction rawtran, boolean hold, int open_mode, int lock_level, BTreeLockingPolicy btree_locking_policy, BTree conglomerate, LogicalUndo undo, DynamicCompiledOpenConglomInfo dynamic_info) throws StandardException
Initialize the open conglomerate.If container is null, open the container, otherwise use the container passed in. The container is always opened with no locking, it is up to the caller to make the appropriate container locking call.
- Parameters:
open_user_scans- The user transaction which opened this btree.xact_manager- The current transaction, usually the same as "open_user_scans", but in the case of split it is the internal xact nested below the user xact.input_container- The open container holding the index, if it is already open, else null which will mean this routine will open it.rawtran- The current raw store transaction.open_mode- The opening mode for the ContainerHandle.conglomerate- Readonly description of the conglomerate.undo- Logical undo object to associate with all updates done on this open btree.- Throws:
StandardException- Standard exception policy.
-
reopen
public ContainerHandle reopen() throws StandardException
Open the container after it has been closed previously.Open the container, obtaining necessary locks. Most work is actually done by RawStore.openContainer(). Will only reopen() if the container is not already open.
- Throws:
StandardException- Standard exception policy.
-
close
public void close() throws StandardExceptionClose the open conglomerate.- Throws:
StandardException
-
isIndexableRowConsistent
void isIndexableRowConsistent(DataValueDescriptor[] row) throws StandardException
Check if all the columns are Indexable and Storable. Eventually this routine could check whether all the types were right also.- Throws:
StandardException- Standard Exception Policy.
-
getContainerHandle
public ContainerHandle getContainerHandle()
Return the container handle.- Returns:
- The open container handle of the btree.
-
getHeight
public int getHeight() throws StandardExceptionget height of the tree.Read in root and return the height (number of levels) of the tree. The level of a tree is 0 in the leaf and increases by 1 for each level of the tree as you go up the tree.
- Throws:
StandardException- Standard exception policy.
-
debugConglomerate
public void debugConglomerate() throws StandardExceptionDump information about tree into the log.Traverse the tree dumping info about tree into the log.
- Throws:
StandardException- Standard exception policy.
-
test_errors
public static boolean test_errors(OpenBTree open_btree, java.lang.String debug_string, BTreeRowPosition pos, BTreeLockingPolicy btree_locking_policy, LeafControlRow leaf, boolean input_latch_released) throws StandardException
Testing infrastructure to cause unusual paths through the code.Through the use of debug flags allow test code to cause otherwise hard to cause paths through the code.
- Parameters:
pos- the current scan position if the condition simulated by this call would have resulted in the position being saved- Returns:
- whether the latch has been released by this routine.
- Throws:
StandardException- Standard exception policy.
-
getSpaceInfo
public SpaceInfo getSpaceInfo() throws StandardException
- Throws:
StandardException
-
getColumnSortOrderInfo
public boolean[] getColumnSortOrderInfo() throws StandardException- Throws:
StandardException
-
-