com.caucho.db.table
Class Table

java.lang.Object
  extended by com.caucho.db.block.BlockStore
      extended by com.caucho.db.table.Table

@Module
public class Table
extends BlockStore

Table format:

 Block 0: allocation table
 Block 1: fragment table
 Block 2: table definition
   0    - store data
   1024 - table data
    1024 - index pointers
   2048 - CREATE text
 Block 3: first data
 


Field Summary
static int INLINE_BLOB_SIZE
           
static byte ROW_ALLOC
           
static long ROW_CLOCK_MIN
           
static byte ROW_MASK
           
static byte ROW_VALID
           
 
Fields inherited from class com.caucho.db.block.BlockStore
_blockManager, _database, ALLOC_DATA, ALLOC_FREE, ALLOC_INDEX, ALLOC_INODE_PTR, ALLOC_MASK, ALLOC_MINI_FRAG, ALLOC_ROW, BLOCK_BITS, BLOCK_INDEX_MASK, BLOCK_MASK, BLOCK_OFFSET_MASK, BLOCK_SIZE, DATA_START, DATABASE_CORRUPT_EVENT, MINI_FRAG_ALLOC_OFFSET, MINI_FRAG_PER_BLOCK, MINI_FRAG_SIZE, STORE_CREATE_END
 
Method Summary
 void close()
          Closes the store.
 void create()
          Creates the table.
 TableIterator createTableIterator()
           
 Column getAutoIncrementColumn()
          Returns the auto-increment column.
 Column getColumn(java.lang.String name)
          Returns the column for the given column name.
 int getColumnIndex(java.lang.String name)
          Returns the column index for the given column name.
 Column[] getColumns()
           
 Constraint[] getConstraints()
          Returns the table's constraints.
 int getRowLength()
          Returns the length of a row.
 long insert(QueryContext queryContext, DbTransaction xa, java.util.ArrayList<Column> columns, java.util.ArrayList<Expr> values)
          Inserts a new row, returning the row address.
 void insertRow(QueryContext queryContext, DbTransaction xa, java.util.ArrayList<Column> columns, java.util.ArrayList<Expr> values, Block block, int rowOffset)
           
static Table loadFromFile(Database db, java.lang.String name)
          Loads the table from the file.
 long nextAutoIncrement(QueryContext context)
          Returns the next auto-increment value.
 java.lang.String toString()
           
 void validate()
          Rebuilds the indexes
 
Methods inherited from class com.caucho.db.block.BlockStore
addressToBlockId, allocateBlock, allocateIndexBlock, allocateIndirectBlock, allocateMiniFragment, allocateRow, assertStoreActive, blockIdToAddress, blockIdToAddress, blockIdToIndex, blockIndexToAddr, codeToName, create, create, createMmap, createNoMmap, deallocateBlock, deleteMiniFragment, fatalCorrupted, firstBlock, firstRowBlock, flush, getAllocation, getAllocationByAddress, getAllocationTable, getBlockCount, getBlockManager, getFileSize, getId, getName, getReadWrite, getWriteLock, init, isClosed, isFlushDirtyBlocksOnCommit, isIndexBlock, isInodePtrBlock, isRowBlock, loadBlock, readBlock, readBlock, readBlock, readBlock, readBlockLong, readBlockNoLock, readLong, readMiniFragment, readMiniFragment, readMiniFragmentLong, readMiniFragmentNoLock, remove, saveAllocation, setEnableMmap, setFlushDirtyBlocksOnCommit, validateBlockId, writeBlock, writeBlock, writeBlockLong, writeLong, writeMiniFragment, writeMiniFragment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

INLINE_BLOB_SIZE

public static final int INLINE_BLOB_SIZE
See Also:
Constant Field Values

ROW_CLOCK_MIN

public static final long ROW_CLOCK_MIN
See Also:
Constant Field Values

ROW_VALID

public static final byte ROW_VALID
See Also:
Constant Field Values

ROW_ALLOC

public static final byte ROW_ALLOC
See Also:
Constant Field Values

ROW_MASK

public static final byte ROW_MASK
See Also:
Constant Field Values
Method Detail

getRowLength

public int getRowLength()
Returns the length of a row.


getColumns

public final Column[] getColumns()

getConstraints

public final Constraint[] getConstraints()
Returns the table's constraints.


getAutoIncrementColumn

public Column getAutoIncrementColumn()
Returns the auto-increment column.


getColumn

public Column getColumn(java.lang.String name)
Returns the column for the given column name.

Parameters:
name - the column name
Returns:
the column

getColumnIndex

public int getColumnIndex(java.lang.String name)
                   throws java.sql.SQLException
Returns the column index for the given column name.

Parameters:
name - the column name
Returns:
the column index.
Throws:
java.sql.SQLException

loadFromFile

public static Table loadFromFile(Database db,
                                 java.lang.String name)
                          throws java.io.IOException,
                                 java.sql.SQLException
Loads the table from the file.

Throws:
java.io.IOException
java.sql.SQLException

create

public void create()
            throws java.io.IOException,
                   java.sql.SQLException
Creates the table.

Overrides:
create in class BlockStore
Throws:
java.io.IOException
java.sql.SQLException

validate

public void validate()
              throws java.sql.SQLException
Rebuilds the indexes

Throws:
java.sql.SQLException

createTableIterator

public TableIterator createTableIterator()

nextAutoIncrement

public long nextAutoIncrement(QueryContext context)
                       throws java.sql.SQLException
Returns the next auto-increment value.

Throws:
java.sql.SQLException

insert

public long insert(QueryContext queryContext,
                   DbTransaction xa,
                   java.util.ArrayList<Column> columns,
                   java.util.ArrayList<Expr> values)
            throws java.io.IOException,
                   java.sql.SQLException
Inserts a new row, returning the row address.

Throws:
java.io.IOException
java.sql.SQLException

insertRow

public void insertRow(QueryContext queryContext,
                      DbTransaction xa,
                      java.util.ArrayList<Column> columns,
                      java.util.ArrayList<Expr> values,
                      Block block,
                      int rowOffset)
               throws java.sql.SQLException
Throws:
java.sql.SQLException

close

public void close()
Description copied from class: BlockStore
Closes the store.

Overrides:
close in class BlockStore

toString

public java.lang.String toString()
Overrides:
toString in class BlockStore