Class TemporaryRowHolderImpl
java.lang.Object
org.apache.derby.impl.sql.execute.TemporaryRowHolderImpl
- All Implemented Interfaces:
TemporaryRowHolder
This is a class that is used to temporarily
(non-persistently) hold rows that are used in
language execution. It will store them in an
array, or a temporary conglomerate, depending
on the number of rows.
It is used for deferred DML processing.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Activation
Activation object with local state information.private ConglomerateController
private long
private boolean
static final int
private RowLocation
private boolean
private boolean
protected int
private int
private SQLLongint
private ConglomerateController
private long
private boolean
private DataValueDescriptor[]
private Properties
private ResultDescription
protected ExecRow[]
private ScanController
protected int
protected static final int
protected static final int
protected static final int
private ConglomerateController
private long
private boolean
private DataValueDescriptor[]
-
Constructor Summary
ConstructorsConstructorDescriptionTemporaryRowHolderImpl
(Activation activation, Properties properties, ResultDescription resultDescription) Uses the default overflow to a conglomerate threshold (5).TemporaryRowHolderImpl
(Activation activation, Properties properties, ResultDescription resultDescription, boolean isUniqueStream) Uses the default overflow to a conglomerate threshold (5).TemporaryRowHolderImpl
(Activation activation, Properties properties, ResultDescription resultDescription, int overflowToConglomThreshold, boolean isUniqueStream, boolean isVirtualMemHeap) Create a temporary row holder with the defined overflow to conglom -
Method Summary
Modifier and TypeMethodDescriptionprivate ExecRow
void
close()
Clean uplong
Get a result set for scanning what has been inserted so far.long
Accessor to get the id of the temporary conglomerate.void
Insert a rowprivate void
insertToPositionIndex
(int position, RowLocation rl) Maintain an index that will allow us to read from the temporary heap in the order we inserted.private boolean
isRowAlreadyExist
(ExecRow inputRow) Maintain an unique index based on the input row's row location in the base table, this index make sures that we don't insert duplicate rows into the temporary heap.private Properties
makeIndexProperties
(DataValueDescriptor[] indexRowArray, long conglomId) void
void
truncate()
Purge the row holder of all its rows.
-
Field Details
-
DEFAULT_OVERFLOWTHRESHOLD
public static final int DEFAULT_OVERFLOWTHRESHOLD- See Also:
-
STATE_UNINIT
protected static final int STATE_UNINIT- See Also:
-
STATE_INSERT
protected static final int STATE_INSERT- See Also:
-
STATE_DRAIN
protected static final int STATE_DRAIN- See Also:
-
rowArray
-
lastArraySlot
protected int lastArraySlot -
numRowsIn
private int numRowsIn -
state
protected int state -
CID
private long CID -
conglomCreated
private boolean conglomCreated -
cc
-
properties
-
scan
-
resultDescription
-
activation
Activation activationActivation object with local state information. -
isUniqueStream
private boolean isUniqueStream -
isVirtualMemHeap
private boolean isVirtualMemHeap -
uniqueIndexCreated
private boolean uniqueIndexCreated -
positionIndexCreated
private boolean positionIndexCreated -
uniqueIndexConglomId
private long uniqueIndexConglomId -
positionIndexConglomId
private long positionIndexConglomId -
uniqueIndex_cc
-
positionIndex_cc
-
uniqueIndexRow
-
positionIndexRow
-
destRowLocation
-
position_sqllong
-
-
Constructor Details
-
TemporaryRowHolderImpl
public TemporaryRowHolderImpl(Activation activation, Properties properties, ResultDescription resultDescription) Uses the default overflow to a conglomerate threshold (5).- Parameters:
activation
- the activationproperties
- the properties of the original table. Used to help the store use optimal page size, etc.resultDescription
- the result description. Relevant for the getResultDescription call on the result set returned by getResultSet. May be null
-
TemporaryRowHolderImpl
public TemporaryRowHolderImpl(Activation activation, Properties properties, ResultDescription resultDescription, boolean isUniqueStream) Uses the default overflow to a conglomerate threshold (5).- Parameters:
activation
- the activationproperties
- the properties of the original table. Used to help the store use optimal page size, etc.resultDescription
- the result description. Relevant for the getResultDescription call on the result set returned by getResultSet. May be nullisUniqueStream
- - true , if it has to be temporary row holder unique stream
-
TemporaryRowHolderImpl
public TemporaryRowHolderImpl(Activation activation, Properties properties, ResultDescription resultDescription, int overflowToConglomThreshold, boolean isUniqueStream, boolean isVirtualMemHeap) Create a temporary row holder with the defined overflow to conglom- Parameters:
activation
- the activationproperties
- the properties of the original table. Used to help the store use optimal page size, etc.resultDescription
- the result description. Relevant for the getResultDescription call on the result set returned by getResultSet. May be nulloverflowToConglomThreshold
- on an attempt to insert this number of rows, the rows will be put into a temporary conglomerate.
-
-
Method Details
-
cloneRow
-
insert
Insert a row- Specified by:
insert
in interfaceTemporaryRowHolder
- Parameters:
inputRow
- the row to insert- Throws:
StandardException
- on error
-
isRowAlreadyExist
Maintain an unique index based on the input row's row location in the base table, this index make sures that we don't insert duplicate rows into the temporary heap.- Parameters:
inputRow
- the row we are inserting to temporary row holder- Throws:
StandardException
- on error
-
insertToPositionIndex
Maintain an index that will allow us to read from the temporary heap in the order we inserted.- Parameters:
position
- - the number of the row we are inserting into heaprl
- the row to Location in the temporary heap- Throws:
StandardException
- on error
-
getResultSet
Get a result set for scanning what has been inserted so far.- Specified by:
getResultSet
in interfaceTemporaryRowHolder
- Returns:
- a result set to use
-
truncate
Purge the row holder of all its rows. Resets the row holder so that it can accept new inserts. A cheap way to recycle a row holder.- Throws:
StandardException
- on error
-
getTemporaryConglomId
public long getTemporaryConglomId()Accessor to get the id of the temporary conglomerate. Temporary conglomerates have negative ids. An id equal to zero means that no temporary conglomerate has been created.- Specified by:
getTemporaryConglomId
in interfaceTemporaryRowHolder
- Returns:
- Conglomerate ID of temporary conglomerate
-
getPositionIndexConglomId
public long getPositionIndexConglomId()- Specified by:
getPositionIndexConglomId
in interfaceTemporaryRowHolder
-
makeIndexProperties
private Properties makeIndexProperties(DataValueDescriptor[] indexRowArray, long conglomId) throws StandardException - Throws:
StandardException
-
setRowHolderTypeToUniqueStream
public void setRowHolderTypeToUniqueStream()- Specified by:
setRowHolderTypeToUniqueStream
in interfaceTemporaryRowHolder
-
close
Clean up- Specified by:
close
in interfaceTemporaryRowHolder
- Throws:
StandardException
- on error
-