Class B2I
- All Implemented Interfaces:
Externalizable
,Serializable
,Comparable
,Formatable
,Storable
,TypedFormat
,Conglomerate
,DataValueDescriptor
,Orderable
- The B2I object is stored on disk, and holds the store specific information needed to access/describe the conglomerate. This includes information such as the format ids of the columns, the conglomerate id of the base table, the location of row location column.
-
Access to all the interfaces start by making a call off the
Conglomerate interface. So for instance to get a scan on the
conglomerate method
openScan
should be called.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
(package private) long
The id of the conglomerate which contains the base table.(package private) static final int
private static final String
private static final String
(package private) int
The column id (zero-based integer index) of the column which holds the row location to the base conglomerate.Fields inherited from class org.apache.derby.impl.store.access.btree.BTree
ascDescInfo, collation_ids, conglom_format_id, format_ids, hasCollatedTypes, id, nKeyFields, PROPERTY_ALLOWDUPLICATES, PROPERTY_MAX_ROWS_PER_PAGE_PARAMETER, PROPERTY_NKEYFIELDS, PROPERTY_NUNIQUECOLUMNS, PROPERTY_PARENTLINKS, PROPERTY_UNIQUE_WITH_DUPLICATE_NULLS, ROOTPAGEID
Fields inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
UNKNOWN_LOGICAL_LENGTH
Fields inherited from interface org.apache.derby.iapi.types.Orderable
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
compressConglomerate
(TransactionManager xact_manager, Transaction rawtran) void
create
(TransactionManager xact_manager, int segmentId, long input_conglomid, DataValueDescriptor[] template, ColumnOrdering[] columnOrder, int[] collationIds, Properties properties, int temporaryFlag) Create an empty secondary index b-tree, using the generic b-tree to do the generic part of the creation process.defragmentConglomerate
(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level) Open a b-tree compress scan.void
drop
(TransactionManager xact_manager) Drop this b-tree secondary index.int
Estimate the memory usage in bytes of the data value and the overhead of the class.boolean
fetchMaxOnBTree
(TransactionManager xact_manager, Transaction rawtran, long conglomId, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level, FormatableBitSet scanColumnList, DataValueDescriptor[] fetchRow) Retrieve the maximum value row in an ordered conglomerate.protected BTreeLockingPolicy
getBtreeLockingPolicy
(Transaction rawtran, int lock_level, int mode, int isolation_level, ConglomerateController base_cc, OpenBTree open_btree) Create a new btree locking policy from scratch.getStaticCompiledConglomInfo
(TransactionController xact_manager, long conglomId) Return static information about the conglomerate to be included in a a compiled plan.int
Return my format identifier.long
load
(TransactionManager xact_manager, boolean createConglom, RowLocationRetRowSource rowSource) Bulk Load a B-tree secondary index.final ConglomerateController
lockTable
(TransactionManager xact_manager, int open_mode, int lock_level, int isolation_level) Lock the base table.open
(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) Open a b-tree controller.openScan
(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level, FormatableBitSet scanColumnList, DataValueDescriptor[] startKeyValue, int startSearchOperator, Qualifier[][] qualifier, DataValueDescriptor[] stopKeyValue, int stopSearchOperator, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) Open a b-tree secondary index scan controller.openStoreCost
(TransactionManager xact_manager, Transaction rawtran) Return an open StoreCostController for the conglomerate.void
purgeConglomerate
(TransactionManager xact_manager, Transaction rawtran) void
Restore the in-memory representation from the stream.private void
Private methods of B2I, arranged alphabetically.void
Store the stored representation of the column value in the stream.void
Store the stored representation of the column value in the stream.void
Store the stored representation of the column value in the stream.Methods inherited from class org.apache.derby.impl.store.access.btree.BTree
addColumn, create, createTemplate, getContainerid, getDynamicCompiledConglomInfo, getId, isNull, isTemporary, isUnique, isUniqueWithDuplicateNulls, restoreToNull, setUniqueWithDuplicateNulls, toString
Methods inherited from class org.apache.derby.impl.store.access.conglomerate.GenericConglomerate
cloneValue, compare, getLength, getNewNull, getObject, getString, getTypeName, hasCollatedColumns, setFrom, setValueFromResultSet
Methods inherited from class org.apache.derby.iapi.types.DataType
checkHostVariable, cloneHolder, coalesce, compare, compare, compare, compareTo, dataTypeConversion, equals, equals, flip, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getShort, getStream, getTime, getTimestamp, getTraceString, greaterOrEquals, greaterThan, hasStream, in, invalidFormat, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, outOfRange, readExternalFromArray, recycle, setBigDecimal, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, throwLangSetMismatch, typePrecedence, typeToBigDecimal
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.derby.iapi.types.DataValueDescriptor
checkHostVariable, cloneHolder, coalesce, compare, compare, compare, equals, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLong, getShort, getStream, getTime, getTimestamp, getTraceString, greaterOrEquals, greaterThan, hasStream, in, isNotNull, isNullOp, lessOrEquals, lessThan, normalize, notEquals, readExternalFromArray, recycle, setBigDecimal, setInto, setInto, setObjectForCast, setToNull, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, typePrecedence, typeToBigDecimal
-
Field Details
-
PROPERTY_BASECONGLOMID
- See Also:
-
PROPERTY_ROWLOCCOLUMN
- See Also:
-
FORMAT_NUMBER
static final int FORMAT_NUMBER- See Also:
-
baseConglomerateId
long baseConglomerateIdThe id of the conglomerate which contains the base table. Row locations inserted into this secondary index are assumed to refer to that conglomerate. Used to obtain table/row locks on the base table rows which the index rows point at. -
rowLocationColumn
int rowLocationColumnThe column id (zero-based integer index) of the column which holds the row location to the base conglomerate. The default value of RowLocationColumn is the last key column. Used to obtain table/row locks on the base table rows with the index rows point at. Currently, RowLocationColumn must be the last key column. -
BASE_MEMORY_USAGE
private static final int BASE_MEMORY_USAGE
-
-
Constructor Details
-
B2I
public B2I()
-
-
Method Details
-
estimateMemoryUsage
public int estimateMemoryUsage()Description copied from interface:DataValueDescriptor
Estimate the memory usage in bytes of the data value and the overhead of the class.- Returns:
- the estimated memory usage
-
getBtreeLockingPolicy
protected BTreeLockingPolicy getBtreeLockingPolicy(Transaction rawtran, int lock_level, int mode, int isolation_level, ConglomerateController base_cc, OpenBTree open_btree) throws StandardException Create a new btree locking policy from scratch.- Specified by:
getBtreeLockingPolicy
in classBTree
- Throws:
StandardException
- Standard exception policy.
-
lockTable
public final ConglomerateController lockTable(TransactionManager xact_manager, int open_mode, int lock_level, int isolation_level) throws StandardException Lock the base table.Assumes that segment of the base container is the same as the segment of the btree segment.
RESOLVE - we really want to get the lock without opening the container. raw store will be providing this.
- Specified by:
lockTable
in classBTree
- Parameters:
xact_manager
- Transaction to associate the lock with.- Throws:
StandardException
- Standard exception policy.
-
traverseRight
private void traverseRight()Private methods of B2I, arranged alphabetically. -
create
public void create(TransactionManager xact_manager, int segmentId, long input_conglomid, DataValueDescriptor[] template, ColumnOrdering[] columnOrder, int[] collationIds, Properties properties, int temporaryFlag) throws StandardException Create an empty secondary index b-tree, using the generic b-tree to do the generic part of the creation process. This routine opens the newly created container, adds a single page, and makes this page the root by inserting a LeafControlRow onto this page at slot 0 and marking in that control row that the page is a root page. The following properties are specific to the b-tree secondary index:- "baseConglomerateId" (integer). The conglomerate id of the base conglomerate is never actually accessed by the b-tree secondary index implementation, it only serves as a namespace for row locks. This property is required.
- "rowLocationColumn" (integer). The zero-based index into the row which the b-tree secondary index will assume holds a @see RowLocation of the base row in the base conglomerate. This value will be used for acquiring locks. In this implementation RowLocationColumn must be the last key column. This property is required.
- Throws:
StandardException
- Standard exception policy.- See Also:
-
fetchMaxOnBTree
public boolean fetchMaxOnBTree(TransactionManager xact_manager, Transaction rawtran, long conglomId, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level, FormatableBitSet scanColumnList, DataValueDescriptor[] fetchRow) throws StandardException Retrieve the maximum value row in an ordered conglomerate.Returns true and fetches the rightmost row of an ordered conglomerate into "fetchRow" if there is at least one row in the conglomerate. If there are no rows in the conglomerate it returns false.
Non-ordered conglomerates will not implement this interface, calls will generate a StandardException.
RESOLVE - this interface is temporary, long term equivalent (and more) functionality will be provided by the openBackwardScan() interface.
- Parameters:
xact_manager
- The TransactionController under which this operation takes place.rawtran
- The raw store xact to associate all ops with.conglomId
- The identifier of the conglomerate to open the scan for.open_mode
- Specifiy flags to control opening of table. OPENMODE_FORUPDATE - if set open the table for update otherwise open table shared.lock_level
- One of (MODE_TABLE, MODE_RECORD, or MODE_NONE).locking_policy
- The LockingPolicy to use to open the conglomerate.isolation_level
- The isolation level to lock the conglomerate at. One of (ISOLATION_READ_COMMITTED or ISOLATION_SERIALIZABLE).scanColumnList
- A description of which columns to return from every fetch in the scan. template, and scanColumnList work together to describe the row to be returned by the scan - see RowUtil for description of how these three parameters work together to describe a "row".fetchRow
- The row to retrieve the maximum value into.- Returns:
- boolean indicating if a row was found and retrieved or not.
- Throws:
StandardException
- Standard exception policy.
-
load
public long load(TransactionManager xact_manager, boolean createConglom, RowLocationRetRowSource rowSource) throws StandardException Bulk Load a B-tree secondary index.- Specified by:
load
in interfaceConglomerate
- Specified by:
load
in classBTree
- Parameters:
xact_manager
- The TransactionController under which this operation takes place.createConglom
- If true, the conglomerate is being created in the same operation as the openAndLoadConglomerate. The enables further optimization as recovery does not require page allocation to be logged.rowSource
- Where the rows come from.- Returns:
- The number of rows loaded.
- Throws:
StandardException
- Standard Derby Error policy. raise SQLState.STORE_CONGLOMERATE_DUPLICATE_KEY_EXCEPTION if a duplicate key is detected in the load.- See Also:
-
open
public ConglomerateController open(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) throws StandardException Open a b-tree controller.- Specified by:
open
in interfaceConglomerate
- Specified by:
open
in classBTree
- Parameters:
xact_manager
- The access xact to associate all ops on cc with.rawtran
- The raw store xact to associate all ops on cc with.open_mode
- A bit mask of TransactionController.MODE_* bits, indicating info about the open.lock_level
- Either TransactionController.MODE_TABLE or TransactionController.MODE_RECORD, as passed into the openConglomerate() call.locking_policy
- The LockingPolicy to use to open the conglomerate.- Returns:
- The open ConglomerateController.
- Throws:
StandardException
- Standard exception policy.- See Also:
-
openScan
public ScanManager openScan(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level, FormatableBitSet scanColumnList, DataValueDescriptor[] startKeyValue, int startSearchOperator, Qualifier[][] qualifier, DataValueDescriptor[] stopKeyValue, int stopSearchOperator, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) throws StandardException Open a b-tree secondary index scan controller.- Throws:
StandardException
- Standard exception policy.- See Also:
-
defragmentConglomerate
public ScanManager defragmentConglomerate(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level) throws StandardException Open a b-tree compress scan.B2I does not support a compress scan.
- Parameters:
hold
- see openScan()open_mode
- see openScan()lock_level
- see openScan()isolation_level
- see openScan()- Returns:
- The GroupFetchScanController to be used to fetch the rows.
- Throws:
StandardException
- Standard exception policy.- See Also:
-
purgeConglomerate
public void purgeConglomerate(TransactionManager xact_manager, Transaction rawtran) throws StandardException - Throws:
StandardException
-
compressConglomerate
public void compressConglomerate(TransactionManager xact_manager, Transaction rawtran) throws StandardException - Throws:
StandardException
-
openStoreCost
public StoreCostController openStoreCost(TransactionManager xact_manager, Transaction rawtran) throws StandardException Return an open StoreCostController for the conglomerate.Return an open StoreCostController which can be used to ask about the estimated row counts and costs of ScanController and ConglomerateController operations, on the given conglomerate.
- Parameters:
xact_manager
- The TransactionController under which this operation takes place.rawtran
- raw transaction context in which scan is managed.- Returns:
- The open StoreCostController.
- Throws:
StandardException
- Standard exception policy.- See Also:
-
drop
Drop this b-tree secondary index.- Specified by:
drop
in interfaceConglomerate
- Specified by:
drop
in classBTree
- Throws:
StandardException
- Standard exception policy.- See Also:
-
getStaticCompiledConglomInfo
public StaticCompiledOpenConglomInfo getStaticCompiledConglomInfo(TransactionController xact_manager, long conglomId) throws StandardException Return static information about the conglomerate to be included in a a compiled plan.The static info would be valid until any ddl was executed on the conglomid, and would be up to the caller to throw away when that happened. This ties in with what language already does for other invalidation of static info. The type of info in this would be containerid and array of format id's from which templates can be created. The info in this object is read only and can be shared among as many threads as necessary.
- Parameters:
xact_manager
- The TransactionController under which this operation takes place.conglomId
- The identifier of the conglomerate to open.- Returns:
- The static compiled information.
- Throws:
StandardException
- Standard exception policy.
-
getTypeFormatId
public int getTypeFormatId()Return my format identifier.- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
- See Also:
-
writeExternal_v10_2
Store the stored representation of the column value in the stream.For more detailed description of the ACCESS_B2I_V3_ID format see documentation at top of file.
- Throws:
IOException
- See Also:
-
writeExternal_v10_3
Store the stored representation of the column value in the stream.For more detailed description of the ACCESS_B2I_V3_ID and ACCESS_B2I_V4_ID formats see documentation at top of file.
- Throws:
IOException
- See Also:
-
writeExternal
Store the stored representation of the column value in the stream.For more detailed description of the ACCESS_B2I_V3_ID and ACCESS_B2I_V5_ID formats see documentation at top of file.
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classBTree
- Throws:
IOException
- thrown by writeObject()- See Also:
-
readExternal
Restore the in-memory representation from the stream.- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classBTree
- Throws:
ClassNotFoundException
- Thrown if the stored representation is serialized and a class named in the stream could not be found.IOException
- thrown by readObject()- See Also:
-