public class Heap extends GenericConglomerate implements Conglomerate, StaticCompiledOpenConglomInfo
Modifier and Type | Field and Description |
---|---|
private static int |
BASE_MEMORY_USAGE |
protected int[] |
collation_ids
The array of collation id's for each column in the template.
|
protected int |
conglom_format_id
Format id of the conglomerate.
|
private static int |
CONTAINER_KEY_MEMORY_USAGE |
(package private) int[] |
format_ids
The format id's of each of the columns in the heap table.
|
private boolean |
hasCollatedTypes
Tells if there is at least one column in the conglomerate whose collation
isn't StringDataValue.COLLATION_TYPE_UCS_BASIC.
|
private ContainerKey |
id |
UNKNOWN_LOGICAL_LENGTH
ORDER_OP_EQUALS, ORDER_OP_GREATEROREQUALS, ORDER_OP_GREATERTHAN, ORDER_OP_LESSOREQUALS, ORDER_OP_LESSTHAN
Constructor and Description |
---|
Heap()
Zero arg constructor for Monitor to create empty object.
|
Modifier and Type | Method and Description |
---|---|
void |
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,
java.util.Properties properties,
int conglom_format_id,
int tmpFlag)
Create a heap conglomerate.
|
ScanManager |
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 |
estimateMemoryUsage()
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.
|
DataValueDescriptor |
getConglom()
return the "Conglomerate".
|
long |
getContainerid()
Get the containerid of conglomerate.
|
DynamicCompiledOpenConglomInfo |
getDynamicCompiledConglomInfo()
Return dynamic information about the conglomerate to be dynamically
reused in repeated execution of a statement.
|
ContainerKey |
getId()
Get the id of the container of the conglomerate.
|
StaticCompiledOpenConglomInfo |
getStaticCompiledConglomInfo(TransactionController tc,
long conglomId)
Return static information about the conglomerate to be included in a
a compiled plan.
|
int |
getTypeFormatId()
Return my format identifier.
|
boolean |
isNull()
Return whether the value is null or not.
|
boolean |
isTemporary()
Is this conglomerate temporary?
|
long |
load(TransactionManager xact_manager,
boolean createConglom,
RowLocationRetRowSource rowSource)
Bulk load into the conglomerate.
|
ConglomerateController |
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.
|
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)
Open a heap scan controller.
|
StoreCostController |
openStoreCost(TransactionManager xact_manager,
Transaction rawtran)
Return an open StoreCostController for the conglomerate.
|
void |
purgeConglomerate(TransactionManager xact_manager,
Transaction rawtran) |
void |
readExternal(java.io.ObjectInput in)
Restore the in-memory representation from the stream.
|
void |
restoreToNull()
Restore the in-memory representation to the null value.
|
java.lang.String |
toString()
Print this heap.
|
protected void |
writeExternal_v10_2(java.io.ObjectOutput out)
Store the 10.2 format stored representation of column value in stream.
|
void |
writeExternal(java.io.ObjectOutput out)
Store the stored representation of column value in stream.
|
cloneValue, compare, getLength, getNewNull, getObject, getString, getTypeName, hasCollatedColumns, setFrom, setValueFromResultSet
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
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
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
protected int conglom_format_id
private ContainerKey id
int[] format_ids
protected int[] collation_ids
private boolean hasCollatedTypes
private static final int BASE_MEMORY_USAGE
private static final int CONTAINER_KEY_MEMORY_USAGE
public int estimateMemoryUsage()
DataValueDescriptor
estimateMemoryUsage
in interface DataValueDescriptor
protected void create(Transaction rawtran, int segmentId, long input_containerid, DataValueDescriptor[] template, ColumnOrdering[] columnOrder, int[] collationIds, java.util.Properties properties, int conglom_format_id, int tmpFlag) throws StandardException
Create a heap conglomerate. This method is called from the heap factory to create a new instance of a heap.
StandardException
- Standard exception policy.public void boot_create(long containerid, DataValueDescriptor[] template)
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.
containerid
- The container id of the conglomerate.template
- Object array describing the columns of the heap.public void addColumn(TransactionManager xact_manager, int column_id, Storable template_column, int collation_id) throws StandardException
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.
addColumn
in interface Conglomerate
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.xact_manager
- The TransactionController under which this
operation takes place.StandardException
- Standard exception policy.public void drop(TransactionManager xact_manager) throws StandardException
drop
in interface Conglomerate
StandardException
- Standard exception policy.Conglomerate.drop(org.apache.derby.iapi.store.access.conglomerate.TransactionManager)
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
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.
fetchMaxOnBTree
in interface Conglomerate
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).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.xact_manager
- The TransactionController under which this
operation takes place.rawtran
- The raw store xact to associate all ops with.locking_policy
- The LockingPolicy to use to open the conglomerate.StandardException
- Standard exception policy.public final ContainerKey getId()
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.
getId
in interface Conglomerate
public final long getContainerid()
Conglomerate
Will have to change when a conglomerate could have more than one containerid.
getContainerid
in interface Conglomerate
public DynamicCompiledOpenConglomInfo getDynamicCompiledConglomInfo() throws StandardException
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, ...
getDynamicCompiledConglomInfo
in interface Conglomerate
StandardException
- Standard exception policy.public StaticCompiledOpenConglomInfo getStaticCompiledConglomInfo(TransactionController tc, long conglomId) throws StandardException
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.
getStaticCompiledConglomInfo
in interface Conglomerate
conglomId
- The identifier of the conglomerate to open.tc
- The TransactionController under which this operation
takes place.StandardException
- Standard exception policy.public boolean isTemporary()
isTemporary
in interface Conglomerate
public long load(TransactionManager xact_manager, boolean createConglom, RowLocationRetRowSource rowSource) throws StandardException
load
in interface Conglomerate
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.StandardException
- Standard exception policy.Conglomerate.load(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, boolean, org.apache.derby.iapi.store.access.RowLocationRetRowSource)
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
in interface Conglomerate
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.StandardException
- Standard exception policy.Conglomerate.open(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, org.apache.derby.iapi.store.raw.Transaction, boolean, int, int, org.apache.derby.iapi.store.raw.LockingPolicy, org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo, org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo)
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
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.
StandardException
- Standard exception policy.Conglomerate.open(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, org.apache.derby.iapi.store.raw.Transaction, boolean, int, int, org.apache.derby.iapi.store.raw.LockingPolicy, org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo, org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo)
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
openScan
in interface Conglomerate
StandardException
- Standard exception policy.Conglomerate.openScan(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, org.apache.derby.iapi.store.raw.Transaction, boolean, int, int, org.apache.derby.iapi.store.raw.LockingPolicy, int, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.iapi.types.DataValueDescriptor[], int, org.apache.derby.iapi.store.access.Qualifier[][], org.apache.derby.iapi.types.DataValueDescriptor[], int, org.apache.derby.iapi.store.access.StaticCompiledOpenConglomInfo, org.apache.derby.iapi.store.access.DynamicCompiledOpenConglomInfo)
public void purgeConglomerate(TransactionManager xact_manager, Transaction rawtran) throws StandardException
purgeConglomerate
in interface Conglomerate
StandardException
public void compressConglomerate(TransactionManager xact_manager, Transaction rawtran) throws StandardException
compressConglomerate
in interface Conglomerate
StandardException
public ScanManager defragmentConglomerate(TransactionManager xact_manager, Transaction rawtran, boolean hold, int open_mode, int lock_level, LockingPolicy locking_policy, int isolation_level) throws StandardException
defragmentConglomerate
in interface Conglomerate
hold
- see openScan()open_mode
- see openScan()lock_level
- see openScan()isolation_level
- see openScan()StandardException
- Standard exception policy.Conglomerate.defragmentConglomerate(org.apache.derby.iapi.store.access.conglomerate.TransactionManager, org.apache.derby.iapi.store.raw.Transaction, boolean, int, int, org.apache.derby.iapi.store.raw.LockingPolicy, int)
public StoreCostController openStoreCost(TransactionManager xact_manager, Transaction rawtran) throws StandardException
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.
openStoreCost
in interface Conglomerate
xact_manager
- The TransactionController under which this
operation takes place.rawtran
- raw transaction context in which scan is managed.StandardException
- Standard exception policy.StoreCostController
public java.lang.String toString()
toString
in class java.lang.Object
public DataValueDescriptor getConglom()
For heap just return "this", which both implements Conglomerate and StaticCompiledOpenConglomInfo.
getConglom
in interface StaticCompiledOpenConglomInfo
public int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
TypedFormat.getTypeFormatId()
public boolean isNull()
isNull
in interface Storable
Storable.isNull()
public void restoreToNull()
restoreToNull
in interface Storable
Storable.restoreToNull()
protected void writeExternal_v10_2(java.io.ObjectOutput out) throws java.io.IOException
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.
java.io.IOException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
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).
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.lang.ClassNotFoundException
- Thrown if the stored representation
is serialized and a class named in
the stream could not be found.java.io.IOException
Externalizable.readExternal(java.io.ObjectInput)
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.