org.apache.derby.impl.sql.execute
Class TemporaryRowHolderImpl

java.lang.Object
  extended by 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
(package private)  Activation activation
          Activation object with local state information.
private  ConglomerateController cc
           
private  long CID
           
private  boolean conglomCreated
           
static int DEFAULT_OVERFLOWTHRESHOLD
           
private  RowLocation destRowLocation
           
private  boolean isUniqueStream
           
private  boolean isVirtualMemHeap
           
protected  int lastArraySlot
           
private  int numRowsIn
           
private  SQLLongint position_sqllong
           
private  ConglomerateController positionIndex_cc
           
private  long positionIndexConglomId
           
private  boolean positionIndexCreated
           
private  DataValueDescriptor[] positionIndexRow
           
private  java.util.Properties properties
           
private  ResultDescription resultDescription
           
protected  ExecRow[] rowArray
           
private  ScanController scan
           
protected  int state
           
protected static int STATE_DRAIN
           
protected static int STATE_INSERT
           
protected static int STATE_UNINIT
           
private  ConglomerateController uniqueIndex_cc
           
private  long uniqueIndexConglomId
           
private  boolean uniqueIndexCreated
           
private  DataValueDescriptor[] uniqueIndexRow
           
 
Constructor Summary
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
private  ExecRow cloneRow(ExecRow inputRow)
           
 void close()
          Clean up
 long 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 row
private  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 activation
properties - 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 activation
properties - 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
isUniqueStream - - 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 activation
properties - 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
overflowToConglomThreshold - on an attempt to insert this number of rows, the rows will be put into a temporary conglomerate.
Method Detail

cloneRow

private ExecRow cloneRow(ExecRow inputRow)

insert

public void insert(ExecRow inputRow)
            throws StandardException
Insert a row

Specified by:
insert in interface TemporaryRowHolder
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 heap
rl - 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 interface TemporaryRowHolder
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 interface TemporaryRowHolder
Returns:
Conglomerate ID of temporary conglomerate

getPositionIndexConglomId

public long getPositionIndexConglomId()
Specified by:
getPositionIndexConglomId in interface TemporaryRowHolder

makeIndexProperties

private java.util.Properties makeIndexProperties(DataValueDescriptor[] indexRowArray,
                                                 long conglomId)
                                          throws StandardException
Throws:
StandardException

setRowHolderTypeToUniqueStream

public void setRowHolderTypeToUniqueStream()
Specified by:
setRowHolderTypeToUniqueStream in interface TemporaryRowHolder

close

public void close()
           throws StandardException
Clean up

Specified by:
close in interface TemporaryRowHolder
Throws:
StandardException - on error

Built on Thu 2010-12-23 20:49:13+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.