org.h2.mvstore.db

## Class MVTable

- java.lang.Object
- - org.h2.engine.DbObjectBase
  - - org.h2.schema.SchemaObjectBase
    - - org.h2.table.Table
      - - org.h2.table.TableBase
        - - org.h2.table.RegularTable
          - - org.h2.mvstore.db.MVTable

All Implemented Interfaces:
  DbObject, SchemaObject

    public class MVTable
    extends RegularTable

A table stored in a MVStore.

### Field Summary

Fields
`static DebuggingThreadLocal<java.util.ArrayList<java.lang.String>>` `EXCLUSIVE_LOCKS` The table names this thread has exclusively locked.
`static DebuggingThreadLocal<java.util.ArrayList<java.lang.String>>` `SHARED_LOCKS` The tables names this thread has a shared lock on.
`static DebuggingThreadLocal<java.lang.String>` `WAITING_FOR_LOCK` The table name this thread is waiting to lock.

### Fields inherited from class org.h2.table.RegularTable

`containsLargeObject, lockExclusiveSession, lockSharedSessions`

### Fields inherited from class org.h2.table.Table

`columns, compareMode, isHidden, TYPE_CACHED, TYPE_MEMORY`

### Fields inherited from class org.h2.engine.DbObjectBase

`comment, database, trace`

### Fields inherited from interface org.h2.engine.DbObject

`AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, TRIGGER, USER`

### Constructor Summary

Constructors
Constructor and Description
`MVTable(CreateTableData data, MVTableEngine.Store store)`

### Method Summary

Methods
`Index` `addIndex(Session session, java.lang.String indexName, int indexId, IndexColumn[] cols, IndexType indexType, boolean create, java.lang.String indexComment)` Create an index for this table
`void` `addRow(Session session, Row row)` Add a row to the table and all indexes.
`void` `close(Session session)` Close the table object and flush changes.
`void` `commit()` Mark the transaction as committed, so that the modification counter of the database is incremented.
`long` `getDiskSpaceUsed()`
`java.util.ArrayList<Index>` `getIndexes()` Get all indexes for this table.
`java.lang.String` `getMapName()`
`long` `getMaxDataModificationId()` Get the last data modification id.
`Row` `getRow(Session session, long key)` Get the given row.
`long` `getRowCount(Session session)` Get the row count for this table.
`long` `getRowCountApproximation()` Get the approximated row count for this table.
`Index` `getScanIndex(Session session)` Get the scan index to iterate through all rows.
`Index` `getUniqueIndex()` Get any unique index for this table if one exists.
`boolean` `isMVStore()`
`boolean` `lock(Session session, boolean exclusive, boolean forceLockEvenInMvcc)` Lock the table for the given session.
`Row` `lockRow(Session session, Row row)` Locks row, preventing any updated to it, except from the session specified.
`void` `removeChildrenAndResources(Session session)` Remove all dependent objects and free all resources (files, blocks in files) of this object.
`void` `removeRow(Session session, Row row)` Remove a row from the table and all indexes.
`void` `truncate(Session session)` Remove all rows from the table and indexes.
`void` `unlock(Session s)` Release the lock for this session.
`void` `updateRow(Session session, Row oldRow, Row newRow)` Update a row to the table and all indexes.

### Methods inherited from class org.h2.table.RegularTable

`addRowsToIndex, canDrop, canGetRowCount, canTruncate, checkDeadlock, checkRename, checkSupportAlter, getContainsLargeObject, getDeadlockDetails, getRowIdColumn, getTableType, isDeterministic, isLockedExclusively, isLockedExclusivelyBy, sortRows, toString`

### Methods inherited from class org.h2.table.TableBase

`getCreateSQL, getDropSQL, getMainIndexColumn, isGlobalTemporary`

### Methods inherited from class org.h2.table.Table

`addConstraint, addDependencies, addDependentView, addSequence, addSynonym, addTrigger, canReference, checkWritingAllowed, compareValues, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getCreateSQLForCopy, getDefaultValue, getDependentViews, getIndex, getIndexForColumn, getOnCommitDrop, getOnCommitTruncate, getOnUpdateValue, getPrimaryKey, getScanIndex, getTemplateRow, getTemplateSimpleRow, getType, hasInsteadOfTrigger, hasSelectTrigger, isHidden, isPersistData, isPersistIndexes, isQueryComparable, isTableExpression, isView, removeColumnExpressionsDependencies, removeConstraint, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setHidden, setOnCommitDrop, setOnCommitTruncate, setTableExpression, updateRows, validateConvertUpdateSequence`

### Methods inherited from class org.h2.schema.SchemaObjectBase

`getSchema, getSQL, getSQL`

### Methods inherited from class org.h2.engine.DbObjectBase

`getComment, getDatabase, getId, getModificationId, getName, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.h2.engine.DbObject

`getComment, getDatabase, getId, getName, isTemporary, setComment, setTemporary`

### Field Detail

#### WAITING_FOR_LOCK

    public static final DebuggingThreadLocal<java.lang.String> WAITING_FOR_LOCK

The table name this thread is waiting to lock.

#### EXCLUSIVE_LOCKS

    public static final DebuggingThreadLocal<java.util.ArrayList<java.lang.String>> EXCLUSIVE_LOCKS

The table names this thread has exclusively locked.

#### SHARED_LOCKS

    public static final DebuggingThreadLocal<java.util.ArrayList<java.lang.String>> SHARED_LOCKS

The tables names this thread has a shared lock on.

### Constructor Detail

#### MVTable

    public MVTable(CreateTableData data,
           MVTableEngine.Store store)

### Method Detail

#### getMapName

    public java.lang.String getMapName()

#### lock

    public boolean lock(Session session,
               boolean exclusive,
               boolean forceLockEvenInMvcc)

Description copied from class: `Table`
Lock the table for the given session. This method waits until the lock is granted.

Specified by:
  `lock` in class `Table`
Parameters:
  `session` - the session
  `exclusive` - true for write locks, false for read locks
  `forceLockEvenInMvcc` - lock even in the MVCC mode
Returns:
  true if the table was already exclusively locked by this session.

#### unlock

    public void unlock(Session s)

Description copied from class: `Table`
Release the lock for this session.

Specified by:
  `unlock` in class `Table`
Parameters:
  `s` - the session

#### close

    public void close(Session session)

Description copied from class: `Table`
Close the table object and flush changes.

Specified by:
  `close` in class `Table`
Parameters:
  `session` - the session

#### getRow

    public Row getRow(Session session,
             long key)

Description copied from class: `Table`
Get the given row.

Overrides:
  `getRow` in class `Table`
Parameters:
  `session` - the session
  `key` - the primary key
Returns:
  the row

#### addIndex

    public Index addIndex(Session session,
                 java.lang.String indexName,
                 int indexId,
                 IndexColumn[] cols,
                 IndexType indexType,
                 boolean create,
                 java.lang.String indexComment)

Description copied from class: `Table`
Create an index for this table

Specified by:
  `addIndex` in class `Table`
Parameters:
  `session` - the session
  `indexName` - the name of the index
  `indexId` - the id
  `cols` - the index columns
  `indexType` - the index type
  `create` - whether this is a new index
  `indexComment` - the comment
Returns:
  the index

#### removeRow

    public void removeRow(Session session,
                 Row row)

Description copied from class: `Table`
Remove a row from the table and all indexes.

Specified by:
  `removeRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

#### truncate

    public void truncate(Session session)

Description copied from class: `Table`
Remove all rows from the table and indexes.

Specified by:
  `truncate` in class `Table`
Parameters:
  `session` - the session

#### addRow

    public void addRow(Session session,
              Row row)

Description copied from class: `Table`
Add a row to the table and all indexes.

Specified by:
  `addRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

#### updateRow

    public void updateRow(Session session,
                 Row oldRow,
                 Row newRow)

Description copied from class: `Table`
Update a row to the table and all indexes.

Overrides:
  `updateRow` in class `Table`
Parameters:
  `session` - the session
  `oldRow` - the row to update
  `newRow` - the row with updated values (_rowid_ suppose to be the same)

#### lockRow

    public Row lockRow(Session session,
              Row row)

Description copied from class: `Table`
Locks row, preventing any updated to it, except from the session specified.

Overrides:
  `lockRow` in class `Table`
Parameters:
  `session` - the session
  `row` - to lock
Returns:
  locked row, or null if row does not exist anymore

#### getScanIndex

    public Index getScanIndex(Session session)

Description copied from class: `Table`
Get the scan index to iterate through all rows.

Specified by:
  `getScanIndex` in class `Table`
Parameters:
  `session` - the session
Returns:
  the index

#### getUniqueIndex

    public Index getUniqueIndex()

Description copied from class: `Table`
Get any unique index for this table if one exists.

Specified by:
  `getUniqueIndex` in class `Table`
Returns:
  a unique index

#### getIndexes

    public java.util.ArrayList<Index> getIndexes()

Description copied from class: `Table`
Get all indexes for this table.

Specified by:
  `getIndexes` in class `Table`
Returns:
  the list of indexes

#### getMaxDataModificationId

    public long getMaxDataModificationId()

Description copied from class: `Table`
Get the last data modification id.

Specified by:
  `getMaxDataModificationId` in class `Table`
Returns:
  the modification id

#### removeChildrenAndResources

    public void removeChildrenAndResources(Session session)

Description copied from class: `DbObjectBase`
Remove all dependent objects and free all resources (files, blocks in files) of this object.

Specified by:
  `removeChildrenAndResources` in interface `DbObject`
Overrides:
  `removeChildrenAndResources` in class `Table`
Parameters:
  `session` - the session

#### getRowCount

    public long getRowCount(Session session)

Description copied from class: `Table`
Get the row count for this table.

Specified by:
  `getRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  the row count

#### getRowCountApproximation

    public long getRowCountApproximation()

Description copied from class: `Table`
Get the approximated row count for this table.

Specified by:
  `getRowCountApproximation` in class `Table`
Returns:
  the approximated row count

#### getDiskSpaceUsed

    public long getDiskSpaceUsed()

Specified by:
  `getDiskSpaceUsed` in class `Table`

#### isMVStore

    public boolean isMVStore()

Overrides:
  `isMVStore` in class `Table`

#### commit

    public void commit()

Mark the transaction as committed, so that the modification counter of the database is incremented.