Class Heap
- All Implemented Interfaces:
Externalizable
,Serializable
,Comparable
,Formatable
,Storable
,TypedFormat
,Conglomerate
,StaticCompiledOpenConglomInfo
,DataValueDescriptor
,Orderable
- Direct Known Subclasses:
Heap_v10_2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
protected int[]
The array of collation id's for each column in the template.protected int
Format id of the conglomerate.private static final int
(package private) int[]
The format id's of each of the columns in the heap table.private boolean
Tells if there is at least one column in the conglomerate whose collation isn't StringDataValue.COLLATION_TYPE_UCS_BASIC.private ContainerKey
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
addColumn
(TransactionManager xact_manager, int column_id, Storable template_column, int collation_id) Add a column to the heap conglomerate.void
boot_create
(long containerid, DataValueDescriptor[] template) Create a heap conglomerate during the boot process.void
compressConglomerate
(TransactionManager xact_manager, Transaction rawtran) protected void
create
(Transaction rawtran, int segmentId, long input_containerid, DataValueDescriptor[] template, ColumnOrdering[] columnOrder, int[] collationIds, Properties properties, int conglom_format_id, int tmpFlag) Create a heap conglomerate.defragmentConglomerate
(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level) Open a heap compress scan.void
drop
(TransactionManager xact_manager) Drop this heap.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.return the "Conglomerate".final long
Get the containerid of conglomerate.Return dynamic information about the conglomerate to be dynamically reused in repeated execution of a statement.final ContainerKey
getId()
Get the id of the container of the conglomerate.getStaticCompiledConglomInfo
(TransactionController tc, long conglomId) Return static information about the conglomerate to be included in a a compiled plan.int
Return my format identifier.boolean
isNull()
Return whether the value is null or not.boolean
Is this conglomerate temporary?long
load
(TransactionManager xact_manager, boolean createConglom, RowLocationRetRowSource rowSource) Bulk load into the conglomerate.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 heap controller.(package private) static ConglomerateController
openByContainerKey
(ContainerKey container_key, TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, StaticCompiledOpenConglomInfo static_info, DynamicCompiledOpenConglomInfo dynamic_info) Open a heap controller given ContainerKey.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 heap 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.void
Restore the in-memory representation to the null value.toString()
Print this heap.void
Store the stored representation of column value in stream.protected void
Store the 10.2 format stored representation of column value in stream.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, cloneValue, coalesce, compare, compare, compare, compare, equals, getBoolean, getByte, getBytes, getDate, getDouble, getFloat, getInt, getLength, getLong, getNewNull, getObject, getShort, getStream, getString, getTime, getTimestamp, getTraceString, getTypeName, 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, setValueFromResultSet, typePrecedence, typeToBigDecimal
-
Field Details
-
conglom_format_id
protected int conglom_format_idFormat id of the conglomerate. -
id
-
format_ids
int[] format_idsThe format id's of each of the columns in the heap table. -
collation_ids
protected int[] collation_idsThe array of collation id's for each column in the template. -
hasCollatedTypes
private boolean hasCollatedTypesTells if there is at least one column in the conglomerate whose collation isn't StringDataValue.COLLATION_TYPE_UCS_BASIC. -
BASE_MEMORY_USAGE
private static final int BASE_MEMORY_USAGE -
CONTAINER_KEY_MEMORY_USAGE
private static final int CONTAINER_KEY_MEMORY_USAGE
-
-
Constructor Details
-
Heap
public Heap()Zero arg constructor for Monitor to create empty object.
-
-
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.- Specified by:
estimateMemoryUsage
in interfaceDataValueDescriptor
- Returns:
- the estimated memory usage
-
create
protected void create(Transaction rawtran, int segmentId, long input_containerid, DataValueDescriptor[] template, ColumnOrdering[] columnOrder, int[] collationIds, Properties properties, int conglom_format_id, int tmpFlag) throws StandardException Create a heap conglomerate.Create a heap conglomerate. This method is called from the heap factory to create a new instance of a heap.
- Throws:
StandardException
- Standard exception policy.
-
boot_create
Create a heap conglomerate during the boot process.Manufacture a Heap Conglomerate out of "thin" air, to boot strap the system. Create an in-memory Heap Conglomerate with the input parameters, The caller will use this to open the conglomerate conglomerate and read the "real" values from disk. Conglom-conglom is always on segment 0.
- Parameters:
containerid
- The container id of the conglomerate.template
- Object array describing the columns of the heap.
-
addColumn
public void addColumn(TransactionManager xact_manager, int column_id, Storable template_column, int collation_id) throws StandardException Add a column to the heap conglomerate.This routine update's the in-memory object version of the Heap Conglomerate to have one more column of the type described by the input template column.
- Specified by:
addColumn
in interfaceConglomerate
- Parameters:
xact_manager
- The TransactionController under which this operation takes place.column_id
- The column number to add this column at.template_column
- An instance of the column to be added to table.collation_id
- Collation id of the column added.- Throws:
StandardException
- Standard exception policy.
-
drop
Drop this heap.- Specified by:
drop
in interfaceConglomerate
- 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.
- Specified by:
fetchMaxOnBTree
in interfaceConglomerate
- 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.
-
getId
Get the id of the container of the conglomerate.Will have to change when a conglomerate could have more than one container. The ContainerKey is a combination of the container id and segment id.
- Specified by:
getId
in interfaceConglomerate
- Returns:
- The ContainerKey.
-
getContainerid
public final long getContainerid()Description copied from interface:Conglomerate
Get the containerid of conglomerate.Will have to change when a conglomerate could have more than one containerid.
- Specified by:
getContainerid
in interfaceConglomerate
- Returns:
- The containerid.
-
getDynamicCompiledConglomInfo
Return dynamic information about the conglomerate to be dynamically reused in repeated execution of a statement.The dynamic info is a set of variables to be used in a given ScanController or ConglomerateController. It can only be used in one controller at a time. It is up to the caller to insure the correct thread access to this info. The type of info in this is a scratch template for btree traversal, other scratch variables for qualifier evaluation, ...
- Specified by:
getDynamicCompiledConglomInfo
in interfaceConglomerate
- Returns:
- The dynamic information.
- Throws:
StandardException
- Standard exception policy.
-
getStaticCompiledConglomInfo
public StaticCompiledOpenConglomInfo getStaticCompiledConglomInfo(TransactionController tc, 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.
- Specified by:
getStaticCompiledConglomInfo
in interfaceConglomerate
- Parameters:
tc
- 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.
-
isTemporary
public boolean isTemporary()Is this conglomerate temporary?- Specified by:
isTemporary
in interfaceConglomerate
- Returns:
- whether conglomerate is temporary or not.
-
load
public long load(TransactionManager xact_manager, boolean createConglom, RowLocationRetRowSource rowSource) throws StandardException Bulk load into the conglomerate.- Specified by:
load
in interfaceConglomerate
- 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 exception policy.- 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 heap controller.- Specified by:
open
in interfaceConglomerate
- 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:
-
openByContainerKey
static ConglomerateController openByContainerKey(ContainerKey container_key, 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 heap controller given ContainerKey.Static routine to open a container given input of the ContainerKey. Routine will lock the container first, and then get the Heap from the conglomerate cache. This insures that interaction with the conglomerate cache is safe with respect to concurrent alter table's which may or may not commit. Currently only package accessible and only used by HeapPostCommit. Longer term would be better to change all of the open interfaces to get lock before accessing conglomerate cache rather than have a specific interface for HeapPostCommit.
- 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 heap scan controller.- Specified by:
openScan
in interfaceConglomerate
- Throws:
StandardException
- Standard exception policy.- See Also:
-
purgeConglomerate
public void purgeConglomerate(TransactionManager xact_manager, Transaction rawtran) throws StandardException - Specified by:
purgeConglomerate
in interfaceConglomerate
- Throws:
StandardException
-
compressConglomerate
public void compressConglomerate(TransactionManager xact_manager, Transaction rawtran) throws StandardException - Specified by:
compressConglomerate
in interfaceConglomerate
- Throws:
StandardException
-
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 heap compress scan.- Specified by:
defragmentConglomerate
in interfaceConglomerate
- 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:
-
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.
- Specified by:
openStoreCost
in interfaceConglomerate
- 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:
-
toString
Print this heap. -
getConglom
return the "Conglomerate".For heap just return "this", which both implements Conglomerate and StaticCompiledOpenConglomInfo.
- Specified by:
getConglom
in interfaceStaticCompiledOpenConglomInfo
- Returns:
- this
-
getTypeFormatId
public int getTypeFormatId()Return my format identifier.- Specified by:
getTypeFormatId
in interfaceTypedFormat
- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
- See Also:
-
isNull
public boolean isNull()Return whether the value is null or not. -
restoreToNull
public void restoreToNull()Restore the in-memory representation to the null value.- Specified by:
restoreToNull
in interfaceStorable
- See Also:
-
writeExternal_v10_2
Store the 10.2 format stored representation of column value in stream.This routine stores the 10.2 version the Heap, ie. the ACCESS_HEAP_V2_ID format. It is used by any database which has been created in 10.2 or a previous release and has not been hard upgraded to a version subsequent to 10.2.
- Throws:
IOException
-
writeExternal
Store the stored representation of column value in stream.This routine uses the current database version to either store the the 10.2 format (ACCESS_HEAP_V2_ID) or the current format (ACCESS_HEAP_V3_ID).
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
Restore the in-memory representation from the stream.- Specified by:
readExternal
in interfaceExternalizable
- Throws:
ClassNotFoundException
- Thrown if the stored representation is serialized and a class named in the stream could not be found.IOException
- See Also:
-