Top Description Fields Constructors Methods
org.apache.derby.impl.store.access.btree

public Class OpenBTree

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.derby.impl.store.access.btree.BTreeController, org.apache.derby.impl.store.access.btree.BTreeCostController, org.apache.derby.impl.store.access.btree.BTreeScan
Imports
org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.store.access.conglomerate.LogicalUndo, .TransactionManager, org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo, .TransactionController, .SpaceInfo, org.apache.derby.iapi.store.raw.ContainerHandle, .LockingPolicy, .Transaction, org.apache.derby.iapi.types.DataValueDescriptor, org.apache.derby.impl.store.access.conglomerate.OpenConglomerateScratchSpace

An 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

Modifier and TypeField and Description
protected LogicalUndo
protected ContainerHandle
container

The (open) container which contains the b-tree.

protected long
err_containerid

The conglomerate containerid for error reporting.

private BTreeLockingPolicy
init_btree_locking_policy

The Locking Policy to use for for access to this btree.

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(), ...).

private boolean
protected int
init_lock_level

Table or page locking?

protected TransactionManager
init_open_user_scans

The user transaction that opened this B-tree.

private int
init_openmode

The ContainerHandle mode the container is opened with.

private Transaction
private TransactionManager
init_xact_manager

The TransactionManager that open'd this btree.

protected OpenConglomerateScratchSpace
runtime_mem

scratch space used for stuff like templates, export rows, ...

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
checkConsistency()

Check consistency of a btree.

public void
close()

Close the open conglomerate.

public void
debugConglomerate()

Dump information about tree into the log.

public boolean[]
public final BTree
public final ContainerHandle
public ContainerHandle

Returns:

The open container handle of the btree.
getContainerHandle
()

Return the container handle.

public long

Returns:

The total estimated number of rows in the conglomerate.
getEstimatedRowCount
()

Get the total estimated number of rows in the container.

public int
getHeight()

get height of the tree.

public final boolean
public final BTreeLockingPolicy
public final int
public final int
public final Transaction
public final OpenConglomerateScratchSpace
public SpaceInfo
public final TransactionManager
getXactMgr()

Public Accessors of This class:

public void
init(TransactionManager
The user transaction which opened this btree.
open_user_scans
,
TransactionManager
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.
xact_manager
,
ContainerHandle
The open container holding the index, if it is already open, else null which will mean this routine will open it.
input_container
,
Transaction
The current raw store transaction.
rawtran
,
boolean hold, int
The opening mode for the ContainerHandle.
open_mode
,
int lock_level, BTreeLockingPolicy btree_locking_policy, BTree
Readonly description of the conglomerate.
conglomerate
,
LogicalUndo
Logical undo object to associate with all updates done on this open btree.
undo
,
DynamicCompiledOpenConglomInfo dynamic_info)

Initialize the open conglomerate.

public final boolean
pack-priv void
isIndexableRowConsistent(DataValueDescriptor[] row)

Check if all the columns are Indexable and Storable.

public boolean
isTableLocked()

is the open btree table locked?

public ContainerHandle
reopen()

Open the container after it has been closed previously.

public void
setEstimatedRowCount(long
the estimated number of rows in the container.
count
)

Set the total estimated number of rows in the container.

public final void
public static boolean

Returns:

whether the latch has been released by this routine.
test_errors
(OpenBTree open_btree, String debug_string, BTreeRowPosition
the current scan position if the condition simulated by this call would have resulted in the position being saved
pos
,
BTreeLockingPolicy btree_locking_policy, LeafControlRow leaf, boolean input_latch_released)

Testing infrastructure to cause unusual paths through the code.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

btree_undoback to summary
protected LogicalUndo btree_undo
containerback to summary
protected ContainerHandle container

The (open) container which contains the b-tree.

err_containeridback to summary
protected long err_containerid

The conglomerate containerid for error reporting.

init_btree_locking_policyback to summary
private BTreeLockingPolicy init_btree_locking_policy

The Locking Policy to use for for access to this btree.

init_conglomerateback to summary
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_holdback to summary
private boolean init_hold
init_lock_levelback to summary
protected int init_lock_level

Table or page locking?

init_open_user_scansback to summary
protected TransactionManager init_open_user_scans

The user transaction that opened this B-tree.

init_openmodeback to summary
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_rawtranback to summary
private Transaction init_rawtran
init_xact_managerback to summary
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.

runtime_memback to summary
protected OpenConglomerateScratchSpace runtime_mem

scratch space used for stuff like templates, export rows, ...

Constructor Detail

OpenBTreeback to summary
public OpenBTree()

Method Detail

checkConsistencyback to summary
public void checkConsistency() throws StandardException

Check 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?

Exceptions
StandardException:
Standard exception policy.
closeback to summary
public void close() throws StandardException

Close the open conglomerate.

debugConglomerateback to summary
public void debugConglomerate() throws StandardException

Dump information about tree into the log.

Traverse the tree dumping info about tree into the log.

Exceptions
StandardException:
Standard exception policy.
getColumnSortOrderInfoback to summary
public boolean[] getColumnSortOrderInfo() throws StandardException
getConglomerateback to summary
public final BTree getConglomerate()
getContainerback to summary
public final ContainerHandle getContainer()
getContainerHandleback to summary
public ContainerHandle getContainerHandle()

Return the container handle.

Returns:ContainerHandle

The open container handle of the btree.

getEstimatedRowCountback to summary
public long getEstimatedRowCount() throws StandardException

Get 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:long

The total estimated number of rows in the conglomerate.

Exceptions
StandardException:
Standard exception policy.
getHeightback to summary
public int getHeight() throws StandardException

get 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.

Exceptions
StandardException:
Standard exception policy.
getHoldback to summary
public final boolean getHold()
getLockingPolicyback to summary
public final BTreeLockingPolicy getLockingPolicy()
getLockLevelback to summary
public final int getLockLevel()
getOpenModeback to summary
public final int getOpenMode()
getRawTranback to summary
public final Transaction getRawTran()
getRuntimeMemback to summary
public final OpenConglomerateScratchSpace getRuntimeMem()
getSpaceInfoback to summary
public SpaceInfo getSpaceInfo() throws StandardException
getXactMgrback to summary
public final TransactionManager getXactMgr()

Public Accessors of This class:

initback to summary
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:TransactionManager

The user transaction which opened this btree.

xact_manager:TransactionManager

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:ContainerHandle

The open container holding the index, if it is already open, else null which will mean this routine will open it.

rawtran:Transaction

The current raw store transaction.

open_mode:int

The opening mode for the ContainerHandle.

conglomerate:BTree

Readonly description of the conglomerate.

undo:LogicalUndo

Logical undo object to associate with all updates done on this open btree.

Exceptions
StandardException:
Standard exception policy.
isClosedback to summary
public final boolean isClosed()
isIndexableRowConsistentback to summary
pack-priv 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.

Exceptions
StandardException:
Standard Exception Policy.
isTableLockedback to summary
public boolean isTableLocked()

is the open btree table locked?

reopenback to summary
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.

Exceptions
StandardException:
Standard exception policy.
setEstimatedRowCountback to summary
public void setEstimatedRowCount(long count) throws StandardException

Set 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:long

the estimated number of rows in the container.

Exceptions
StandardException:
Standard exception policy.
setLockingPolicyback to summary
public final void setLockingPolicy(BTreeLockingPolicy policy)
test_errorsback to summary
public static boolean test_errors(OpenBTree open_btree, 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:BTreeRowPosition

the current scan position if the condition simulated by this call would have resulted in the position being saved

Returns:boolean

whether the latch has been released by this routine.

Exceptions
StandardException:
Standard exception policy.