Package org.h2.mvstore.db
Class MVTable
- java.lang.Object
-
- org.h2.engine.DbObject
-
- org.h2.schema.SchemaObject
-
- org.h2.table.Table
-
- org.h2.table.TableBase
-
- org.h2.mvstore.db.MVTable
-
-
Field Summary
Fields Modifier and Type Field Description static DebuggingThreadLocal<java.util.ArrayList<java.lang.String>>EXCLUSIVE_LOCKSThe table names this thread has exclusively locked.static DebuggingThreadLocal<java.util.ArrayList<java.lang.String>>SHARED_LOCKSThe table names this thread has a shared lock on.static DebuggingThreadLocal<java.lang.String>WAITING_FOR_LOCKThe table name this thread is waiting to lock.-
Fields inherited from class org.h2.table.Table
columns, compareMode, EXCLUSIVE_LOCK, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCK
-
Fields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USER
-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Constructor Summary
Constructors Constructor Description MVTable(CreateTableData data, Store store)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexaddIndex(SessionLocal session, java.lang.String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, java.lang.String indexComment)Create an index for this tablevoidaddRow(SessionLocal session, Row row)Add a row to the table and all indexes.booleancanDrop()Check if this table can be dropped.booleancanGetRowCount(SessionLocal session)Check if the row count can be retrieved quickly.booleancanTruncate()Check if this table can be truncated.java.util.ArrayList<SessionLocal>checkDeadlock(SessionLocal session, SessionLocal clash, java.util.Set<SessionLocal> visited)Check if a deadlock occurred.voidcheckSupportAlter()Check if this table supports ALTER TABLE.voidclose(SessionLocal session)Close the table object and flush changes.booleangetContainsLargeObject()longgetDiskSpaceUsed(boolean total, boolean approximate)java.util.List<Index>getIndexes()Get all indexes for this table.intgetMainIndexColumn()Returns ID of main index column, orSearchRow.ROWID_INDEX.java.lang.StringgetMapName()longgetMaxDataModificationId()Get the last data modification id.RowgetRow(SessionLocal session, long key)Get the given row.longgetRowCount(SessionLocal session)Get the row count for this table.longgetRowCountApproximation(SessionLocal session)Get the approximated row count for this table.ColumngetRowIdColumn()Get the row id column if this table has one.IndexgetScanIndex(SessionLocal session)Get the scan index to iterate through all rows.TableTypegetTableType()Get the table type nameprotected voidinvalidate()Set the main attributes to null to make sure the object is no longer used.booleanisDeterministic()Check if the table is deterministic.booleanisLockedExclusively()Check if this table is locked exclusively.booleanisLockedExclusivelyBy(SessionLocal session)Check if the table is exclusively locked by this session.booleanisRowLockable()Views, function tables, links, etc.booleanlock(SessionLocal session, int lockType)Lock the table for the given session.RowlockRow(SessionLocal session, Row row, int timeoutMillis)Locks row, preventing any updated to it, except from the session specified.voidremoveChildrenAndResources(SessionLocal session)Delete all dependent children objects and resources of this object.voidremoveRow(SessionLocal session, Row row)Remove a row from the table and all indexes.voidsetModificationDataId(long nextModificationDataId)java.lang.StringtoString()longtruncate(SessionLocal session)Remove all rows from the table and indexes.voidunlock(SessionLocal s)Release the lock for this session.voidupdateRow(SessionLocal session, Row oldRow, Row newRow)Update a row to the table and all indexes.voidupdateRows(SessionLocal session, LocalResult rows, java.lang.Runnable cancellationCheck)Update a list of rows in this table.-
Methods inherited from class org.h2.table.TableBase
getCreateSQL, getCreateSQLForMeta, getDropSQL, getMainIndexColumn, isGlobalTemporary
-
Methods inherited from class org.h2.table.Table
addConstraint, addDependencies, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canReference, checkWritingAllowed, compareValues, convertInsertRow, convertUpdateRow, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getIdentityColumn, getIndex, getIndexForColumn, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRowFactory, getScanIndex, getSQLTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isInsertable, isPersistData, isPersistIndexes, isQueryComparable, isView, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setOnCommitDrop, setOnCommitTruncate
-
Methods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQL
-
Methods inherited from class org.h2.engine.DbObject
checkRename, equals, getComment, getCreateSQLForCopy, getDatabase, getId, getModificationId, getName, hashCode, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
-
-
-
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 table names this thread has a shared lock on.
-
-
Constructor Detail
-
MVTable
public MVTable(CreateTableData data, Store store)
-
-
Method Detail
-
getMapName
public java.lang.String getMapName()
-
lock
public boolean lock(SessionLocal session, int lockType)
Description copied from class:TableLock the table for the given session. This method waits until the lock is granted.
-
unlock
public void unlock(SessionLocal s)
Description copied from class:TableRelease the lock for this session.
-
close
public void close(SessionLocal session)
Description copied from class:TableClose the table object and flush changes.
-
getRow
public Row getRow(SessionLocal session, long key)
Description copied from class:TableGet the given row.
-
addIndex
public Index addIndex(SessionLocal session, java.lang.String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, java.lang.String indexComment)
Description copied from class:TableCreate an index for this table- Specified by:
addIndexin classTable- Parameters:
session- the sessionindexName- the name of the indexindexId- the idcols- the index columnsuniqueColumnCount- the count of unique columnsindexType- the index typecreate- whether this is a new indexindexComment- the comment- Returns:
- the index
-
removeRow
public void removeRow(SessionLocal session, Row row)
Description copied from class:TableRemove a row from the table and all indexes.
-
truncate
public long truncate(SessionLocal session)
Description copied from class:TableRemove all rows from the table and indexes.
-
addRow
public void addRow(SessionLocal session, Row row)
Description copied from class:TableAdd a row to the table and all indexes.
-
updateRow
public void updateRow(SessionLocal session, Row oldRow, Row newRow)
Description copied from class:TableUpdate a row to the table and all indexes.
-
lockRow
public Row lockRow(SessionLocal session, Row row, int timeoutMillis)
Description copied from class:TableLocks row, preventing any updated to it, except from the session specified.
-
getScanIndex
public Index getScanIndex(SessionLocal session)
Description copied from class:TableGet the scan index to iterate through all rows.- Specified by:
getScanIndexin classTable- Parameters:
session- the session- Returns:
- the index
-
getIndexes
public java.util.List<Index> getIndexes()
Description copied from class:TableGet all indexes for this table.- Specified by:
getIndexesin classTable- Returns:
- the list of indexes
-
getMaxDataModificationId
public long getMaxDataModificationId()
Description copied from class:TableGet the last data modification id.- Specified by:
getMaxDataModificationIdin classTable- Returns:
- the modification id
-
removeChildrenAndResources
public void removeChildrenAndResources(SessionLocal session)
Description copied from class:DbObjectDelete all dependent children objects and resources of this object.- Overrides:
removeChildrenAndResourcesin classTable- Parameters:
session- the session
-
getRowCount
public long getRowCount(SessionLocal session)
Description copied from class:TableGet the row count for this table.- Specified by:
getRowCountin classTable- Parameters:
session- the session- Returns:
- the row count
-
getRowCountApproximation
public long getRowCountApproximation(SessionLocal session)
Description copied from class:TableGet the approximated row count for this table.- Specified by:
getRowCountApproximationin classTable- Parameters:
session- the session- Returns:
- the approximated row count
-
getDiskSpaceUsed
public long getDiskSpaceUsed(boolean total, boolean approximate)- Overrides:
getDiskSpaceUsedin classTable
-
isRowLockable
public boolean isRowLockable()
Description copied from class:TableViews, function tables, links, etc. do not support locks- Overrides:
isRowLockablein classTable- Returns:
- true if table supports row-level locks
-
setModificationDataId
public void setModificationDataId(long nextModificationDataId)
-
getMainIndexColumn
public int getMainIndexColumn()
Description copied from class:TableReturns ID of main index column, orSearchRow.ROWID_INDEX.- Overrides:
getMainIndexColumnin classTable- Returns:
- ID of main index column, or
SearchRow.ROWID_INDEX
-
updateRows
public void updateRows(SessionLocal session, LocalResult rows, java.lang.Runnable cancellationCheck)
Description copied from class:TableUpdate a list of rows in this table.- Overrides:
updateRowsin classTable- Parameters:
session- the sessionrows- a list of row pairs of the form old row, new row, old row, new row,...cancellationCheck- action executed periodically to check cancellation
-
canDrop
public boolean canDrop()
Description copied from class:TableCheck if this table can be dropped.
-
canGetRowCount
public boolean canGetRowCount(SessionLocal session)
Description copied from class:TableCheck if the row count can be retrieved quickly.- Specified by:
canGetRowCountin classTable- Parameters:
session- the session- Returns:
- true if it can
-
canTruncate
public boolean canTruncate()
Description copied from class:TableCheck if this table can be truncated.- Overrides:
canTruncatein classTable- Returns:
- true if it can
-
checkDeadlock
public java.util.ArrayList<SessionLocal> checkDeadlock(SessionLocal session, SessionLocal clash, java.util.Set<SessionLocal> visited)
Description copied from class:TableCheck if a deadlock occurred. This method is called recursively. There is a circle if the session to be tested has already being visited. If this session is part of the circle (if it is the clash session), the method must return an empty object array. Once a deadlock has been detected, the methods must add the session to the list. If this session is not part of the circle, or if no deadlock is detected, this method returns null.- Overrides:
checkDeadlockin classTable- Parameters:
session- the session to be tested forclash- set with sessions already visited, and null when starting verificationvisited- set with sessions already visited, and null when starting verification- Returns:
- an object array with the sessions involved in the deadlock, or null
-
checkSupportAlter
public void checkSupportAlter()
Description copied from class:TableCheck if this table supports ALTER TABLE.- Specified by:
checkSupportAlterin classTable
-
getContainsLargeObject
public boolean getContainsLargeObject()
-
getRowIdColumn
public Column getRowIdColumn()
Description copied from class:TableGet the row id column if this table has one.- Overrides:
getRowIdColumnin classTable- Returns:
- the row id column, or null
-
getTableType
public TableType getTableType()
Description copied from class:TableGet the table type name- Specified by:
getTableTypein classTable- Returns:
- the table type name
-
isDeterministic
public boolean isDeterministic()
Description copied from class:TableCheck if the table is deterministic.- Specified by:
isDeterministicin classTable- Returns:
- true if it is
-
isLockedExclusively
public boolean isLockedExclusively()
Description copied from class:TableCheck if this table is locked exclusively.- Overrides:
isLockedExclusivelyin classTable- Returns:
- true if it is.
-
isLockedExclusivelyBy
public boolean isLockedExclusivelyBy(SessionLocal session)
Description copied from class:TableCheck if the table is exclusively locked by this session.- Overrides:
isLockedExclusivelyByin classTable- Parameters:
session- the session- Returns:
- true if it is
-
invalidate
protected void invalidate()
Description copied from class:DbObjectSet the main attributes to null to make sure the object is no longer used.- Overrides:
invalidatein classDbObject
-
-