Class TemporaryRowHolderImpl
- java.lang.Object
-
- org.apache.derby.impl.sql.execute.TemporaryRowHolderImpl
-
- All Implemented Interfaces:
TemporaryRowHolder
class TemporaryRowHolderImpl extends java.lang.Object implements 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
-
Constructor Summary
Constructors Constructor Description TemporaryRowHolderImpl(Activation activation, java.util.Properties properties, ResultDescription resultDescription)
Uses the default overflow to a conglomerate threshold (5).TemporaryRowHolderImpl(Activation activation, java.util.Properties properties, ResultDescription resultDescription, boolean isUniqueStream)
Uses the default overflow to a conglomerate threshold (5).TemporaryRowHolderImpl(Activation activation, java.util.Properties properties, ResultDescription resultDescription, int overflowToConglomThreshold, boolean isUniqueStream, boolean isVirtualMemHeap)
Create a temporary row holder with the defined overflow to conglom
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ExecRow
cloneRow(ExecRow inputRow)
void
close()
Clean uplong
getPositionIndexConglomId()
CursorResultSet
getResultSet()
Get a result set for scanning what has been inserted so far.long
getTemporaryConglomId()
Accessor to get the id of the temporary conglomerate.void
insert(ExecRow inputRow)
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 java.util.Properties
makeIndexProperties(DataValueDescriptor[] indexRowArray, long conglomId)
void
setRowHolderTypeToUniqueStream()
void
truncate()
Purge the row holder of all its rows.
-
-
-
Field Detail
-
DEFAULT_OVERFLOWTHRESHOLD
public static final int DEFAULT_OVERFLOWTHRESHOLD
- See Also:
- Constant Field Values
-
STATE_UNINIT
protected static final int STATE_UNINIT
- See Also:
- Constant Field Values
-
STATE_INSERT
protected static final int STATE_INSERT
- See Also:
- Constant Field Values
-
STATE_DRAIN
protected static final int STATE_DRAIN
- See Also:
- Constant Field Values
-
rowArray
protected ExecRow[] rowArray
-
lastArraySlot
protected int lastArraySlot
-
numRowsIn
private int numRowsIn
-
state
protected int state
-
CID
private long CID
-
conglomCreated
private boolean conglomCreated
-
cc
private ConglomerateController cc
-
properties
private java.util.Properties properties
-
scan
private ScanController scan
-
resultDescription
private ResultDescription resultDescription
-
activation
Activation activation
Activation 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
private ConglomerateController uniqueIndex_cc
-
positionIndex_cc
private ConglomerateController positionIndex_cc
-
uniqueIndexRow
private DataValueDescriptor[] uniqueIndexRow
-
positionIndexRow
private DataValueDescriptor[] positionIndexRow
-
destRowLocation
private RowLocation destRowLocation
-
position_sqllong
private SQLLongint position_sqllong
-
-
Constructor Detail
-
TemporaryRowHolderImpl
public TemporaryRowHolderImpl(Activation activation, java.util.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, java.util.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, java.util.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 Detail
-
insert
public void insert(ExecRow inputRow) throws StandardException
Insert a row- Specified by:
insert
in interfaceTemporaryRowHolder
- Parameters:
inputRow
- the row to insert- Throws:
StandardException
- on error
-
isRowAlreadyExist
private boolean isRowAlreadyExist(ExecRow inputRow) throws StandardException
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
private void insertToPositionIndex(int position, RowLocation rl) throws StandardException
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
public CursorResultSet 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
public void truncate() throws StandardException
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 java.util.Properties makeIndexProperties(DataValueDescriptor[] indexRowArray, long conglomId) throws StandardException
- Throws:
StandardException
-
setRowHolderTypeToUniqueStream
public void setRowHolderTypeToUniqueStream()
- Specified by:
setRowHolderTypeToUniqueStream
in interfaceTemporaryRowHolder
-
close
public void close() throws StandardException
Clean up- Specified by:
close
in interfaceTemporaryRowHolder
- Throws:
StandardException
- on error
-
-