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

java.lang.Object
  extended byorg.apache.derby.impl.sql.execute.TemporaryRowHolderImpl
All Implemented Interfaces:
TemporaryRowHolder

public 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.

Author:
jamie

Field Summary
private  ConglomerateController cc
           
protected  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  TransactionController tc
           
private  ConglomerateController uniqueIndex_cc
           
private  long uniqueIndexConglomId
           
private  boolean uniqueIndexCreated
           
private  DataValueDescriptor[] uniqueIndexRow
           
 
Constructor Summary
TemporaryRowHolderImpl(TransactionController tc, java.util.Properties properties, ResultDescription resultDescription)
          Uses the default overflow to a conglomerate threshold (5).
TemporaryRowHolderImpl(TransactionController tc, java.util.Properties properties, ResultDescription resultDescription, boolean isUniqueStream)
          Uses the default overflow to a conglomerate threshold (5).
TemporaryRowHolderImpl(TransactionController tc, 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()
           
 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

protected long CID

conglomCreated

private boolean conglomCreated

cc

private ConglomerateController cc

properties

private java.util.Properties properties

scan

private ScanController scan

tc

private TransactionController tc

resultDescription

private ResultDescription resultDescription

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(TransactionController tc,
                              java.util.Properties properties,
                              ResultDescription resultDescription)
Uses the default overflow to a conglomerate threshold (5).

Parameters:
tc - the xact controller
properties - the properties of the original table. Used to help the store use optimal page size, etc.

TemporaryRowHolderImpl

public TemporaryRowHolderImpl(TransactionController tc,
                              java.util.Properties properties,
                              ResultDescription resultDescription,
                              boolean isUniqueStream)
Uses the default overflow to a conglomerate threshold (5).

Parameters:
tc - the xact controller
properties - the properties of the original table. Used to help the store use optimal page size, etc.
isUniqueStream - - true , if it has to be temporary row holder unique stream

TemporaryRowHolderImpl

public TemporaryRowHolderImpl(TransactionController tc,
                              java.util.Properties properties,
                              ResultDescription resultDescription,
                              int overflowToConglomThreshold,
                              boolean isUniqueStream,
                              boolean isVirtualMemHeap)
Create a temporary row holder with the defined overflow to conglom

Parameters:
tc - the xact controller
properties - the properties of the original table. Used to help the store use optimal page size, etc.
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
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()
Specified by:
getTemporaryConglomId in interface TemporaryRowHolder

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 Mon 2007-06-04 09:58:47+0400, from revision ???

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.