Class GridH2Table
- java.lang.Object
-
- org.h2.engine.DbObjectBase
-
- org.h2.schema.SchemaObjectBase
-
- org.h2.table.Table
-
- org.h2.table.TableBase
-
- org.apache.ignite.internal.processors.query.h2.opt.GridH2Table
-
- All Implemented Interfaces:
org.h2.engine.DbObject,org.h2.schema.SchemaObject
public class GridH2Table extends org.h2.table.TableBaseH2 Table implementation.
-
-
Constructor Summary
Constructors Constructor Description GridH2Table(org.h2.command.ddl.CreateTableData createTblData, GridH2RowDescriptor desc, H2TableDescriptor tblDesc, GridCacheContextInfo<?,?> cacheInfo)Creates table.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddColumns(List<QueryField> cols)Add new columns to this table.org.h2.index.IndexaddIndex(org.h2.engine.Session ses, String idxName, int idxId, org.h2.table.IndexColumn[] cols, org.h2.index.IndexType idxType, boolean create, String idxComment)voidaddRow(org.h2.engine.Session ses, org.h2.result.Row row)voidaddSystemIndex(org.h2.index.Index idx)@Nullable GridCacheContextcacheContext()intcacheId()GridCacheContextInfocacheInfo()StringcacheName()booleancanDrop()booleancanGetRowCount()voidcheckRename()voidcheckSupportAlter()static voidcheckTablesVersions(org.h2.engine.Session s)voidclose(org.h2.engine.Session ses)voiddestroy()Destroy the table.voiddropColumns(List<String> cols)Drop columns.@Nullable org.h2.table.IndexColumngetAffinityKeyColumn()org.h2.table.Column[]getColumns()longgetDiskSpaceUsed()@Nullable org.h2.table.IndexColumngetExplicitAffinityKeyColumn()ArrayList<org.h2.index.Index>getIndexes()longgetMaxDataModificationId()longgetRowCount(@Nullable org.h2.engine.Session ses)longgetRowCountApproximation()org.h2.index.IndexgetScanIndex(org.h2.engine.Session ses)org.h2.table.TableTypegetTableType()org.h2.index.IndexgetUniqueIndex()QueryTableidentifier()StringidentifierString()org.h2.table.IndexColumnindexColumn(int col, int sorting)Creates index column for table.static voidinsertHack(boolean val)Set insert hack flag.static booleaninsertHackRequired(String sql)Check whether insert hack is required.booleanisColumnForPartitionPruning(org.h2.table.Column col)Check whether passed column can be used for partition pruning.booleanisColumnForPartitionPruningStrict(org.h2.table.Column col)Check whether passed column could be used for partition transfer during partition pruning on joined tables and for external affinity calculation (e.g. on thin clients).booleanisCustomAffinityMapper()booleanisDeterministic()booleanisLockedExclusively()booleanisLockedExclusivelyBy(org.h2.engine.Session ses)booleanisPartitioned()booleanlock(org.h2.engine.Session ses, boolean exclusive, boolean force)voidmarkRebuildFromHashInProgress(boolean value)Mark or unmark index rebuild state.voidproposeUserIndex(org.h2.index.Index idx)Add index that is in an intermediate state and is still being built, thus is not used in queries until it is promoted.static voidreadLockTables(org.h2.engine.Session s)booleanrebuildFromHashInProgress()voidremove(CacheDataRow row)Remove row.voidremoveChildrenAndResources(org.h2.engine.Session ses)voidremoveIndex(org.h2.index.Index h2Idx)voidremoveRow(org.h2.engine.Session ses, org.h2.result.Row row)voidrollbackUserIndex(String idxName)Remove user index without promoting it.GridH2RowDescriptorrowDescriptor()protected voidsetColumns(org.h2.table.Column[] columns)H2TableDescriptortableDescriptor()ObjectStatisticstableStatistics()Get actual table statistics if exists.voidtruncate(org.h2.engine.Session ses)voidunlock(org.h2.engine.Session ses)static voidunlockTables(org.h2.engine.Session s)voidupdate(CacheDataRow row, @Nullable CacheDataRow prevRow)Updates table for given key.-
Methods inherited from class org.h2.table.Table
addConstraint, addDependencies, addDependentView, addSequence, addSynonym, addTrigger, canReference, canTruncate, checkDeadlock, checkWritingAllowed, commit, compareTypeSafe, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getCompareMode, getConstraints, getCreateSQLForCopy, getDefaultValue, getDependentViews, getIndex, getIndexForColumn, getOnCommitDrop, getOnCommitTruncate, getOnUpdateValue, getPrimaryKey, getRow, getRowIdColumn, getScanIndex, getTemplateRow, getTemplateSimpleRow, getType, hasSelectTrigger, isHidden, isMVStore, isPersistData, isPersistIndexes, isQueryComparable, isTableExpression, isView, removeConstraint, removeDependentView, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setHidden, setOnCommitDrop, setOnCommitTruncate, setTableExpression, updateRows, validateConvertUpdateSequence
-
Methods inherited from class org.h2.engine.DbObjectBase
getComment, getDatabase, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString
-
-
-
-
Constructor Detail
-
GridH2Table
public GridH2Table(org.h2.command.ddl.CreateTableData createTblData, GridH2RowDescriptor desc, H2TableDescriptor tblDesc, GridCacheContextInfo<?,?> cacheInfo)Creates table.- Parameters:
createTblData- Table description.desc- Row descriptor.tblDesc- Indexes factory.cacheInfo- Cache context info.
-
-
Method Detail
-
addSystemIndex
public void addSystemIndex(org.h2.index.Index idx)
-
isPartitioned
public boolean isPartitioned()
- Returns:
trueIf this is a partitioned table.
-
getAffinityKeyColumn
@Nullable public @Nullable org.h2.table.IndexColumn getAffinityKeyColumn()
- Returns:
- Affinity key column or
nullif not available.
-
getExplicitAffinityKeyColumn
@Nullable public @Nullable org.h2.table.IndexColumn getExplicitAffinityKeyColumn()
- Returns:
- Explicit affinity key column or
nullif not available (skip _KEY column or it's alias).
-
isColumnForPartitionPruning
public boolean isColumnForPartitionPruning(org.h2.table.Column col)
Check whether passed column can be used for partition pruning.- Parameters:
col- Column.- Returns:
Trueif affinity key column.
-
isColumnForPartitionPruningStrict
public boolean isColumnForPartitionPruningStrict(org.h2.table.Column col)
Check whether passed column could be used for partition transfer during partition pruning on joined tables and for external affinity calculation (e.g. on thin clients).Note that it is different from
isColumnForPartitionPruning(Column)method in that not every column which qualifies for partition pruning can be used by thin clients or join partition pruning logic.Consider the following schema:
CREATE TABLE dept (id PRIMARY KEY); CREATE TABLE emp (id, dept_id AFFINITY KEY, PRIMARY KEY(id, dept_id));
For expression-based partition pruning on "emp" table on the server side we may use both "_KEY" and "dept_id" columns, as passing them through standard affinity workflow will yield the same result: dept_id -> part _KEY -> dept_id -> partBut we cannot use "_KEY" on thin client side, as it doesn't know how to extract affinity key field properly. Neither we can perform partition transfer in JOINs when "_KEY" is used.
This is OK as data is collocated, so we can merge partitions extracted from both tables:
SELECT * FROM dept d INNER JOIN emp e ON d.id = e.dept_id WHERE e.dept_id=? AND d.id=?
But this is not OK as joined data is not collocated, and tables form distinct collocation groups:SELECT * FROM dept d INNER JOIN emp e ON d.id = e._KEY WHERE e.dept_id=? AND d.id=?
NB: The last query is not logically correct and will produce empty result. However, it is correct from SQL perspective, so we should make incorrect assumptions about partitions as it may make situation even worse.- Parameters:
col- Column.- Returns:
Trueif column could be used for partition extraction on both server and client sides and for partition transfer in joins.
-
isCustomAffinityMapper
public boolean isCustomAffinityMapper()
- Returns:
- Whether custom affintiy mapper is used.
-
getDiskSpaceUsed
public long getDiskSpaceUsed()
- Specified by:
getDiskSpaceUsedin classorg.h2.table.Table
-
rowDescriptor
public GridH2RowDescriptor rowDescriptor()
- Returns:
- Row descriptor.
-
tableDescriptor
public H2TableDescriptor tableDescriptor()
- Returns:
- Table descriptor.
-
cacheName
public String cacheName()
- Returns:
- Cache name.
-
cacheId
public int cacheId()
- Returns:
- Cache ID.
-
cacheInfo
public GridCacheContextInfo cacheInfo()
- Returns:
- Cache context info.
-
tableStatistics
public ObjectStatistics tableStatistics()
Get actual table statistics if exists.- Returns:
- Table statistics or
nullif there is no statistics available.
-
cacheContext
@Nullable public @Nullable GridCacheContext cacheContext()
- Returns:
- Cache context.
-
lock
public boolean lock(org.h2.engine.Session ses, boolean exclusive, boolean force)- Specified by:
lockin classorg.h2.table.Table
-
unlock
public void unlock(org.h2.engine.Session ses)
- Specified by:
unlockin classorg.h2.table.Table
-
identifier
public QueryTable identifier()
- Returns:
- Table identifier.
-
identifierString
public String identifierString()
- Returns:
- Table identifier as string.
-
close
public void close(org.h2.engine.Session ses)
- Specified by:
closein classorg.h2.table.Table
-
removeChildrenAndResources
public void removeChildrenAndResources(org.h2.engine.Session ses)
- Specified by:
removeChildrenAndResourcesin interfaceorg.h2.engine.DbObject- Overrides:
removeChildrenAndResourcesin classorg.h2.table.Table
-
destroy
public void destroy()
Destroy the table.
-
update
public void update(CacheDataRow row, @Nullable @Nullable CacheDataRow prevRow)
Updates table for given key. If value is null then row with given key will be removed from table, otherwise value and expiration time will be updated or new row will be added.- Parameters:
row- Row to be updated.prevRow- Previous row.- Throws:
IgniteCheckedException- If failed.
-
remove
public void remove(CacheDataRow row)
Remove row.- Parameters:
row- Row.
-
markRebuildFromHashInProgress
public void markRebuildFromHashInProgress(boolean value)
Mark or unmark index rebuild state.
-
rebuildFromHashInProgress
public boolean rebuildFromHashInProgress()
-
addIndex
public org.h2.index.Index addIndex(org.h2.engine.Session ses, String idxName, int idxId, org.h2.table.IndexColumn[] cols, org.h2.index.IndexType idxType, boolean create, String idxComment)- Specified by:
addIndexin classorg.h2.table.Table
-
proposeUserIndex
public void proposeUserIndex(org.h2.index.Index idx) throws IgniteCheckedExceptionAdd index that is in an intermediate state and is still being built, thus is not used in queries until it is promoted.- Parameters:
idx- Index to add.- Throws:
IgniteCheckedException- If failed.
-
rollbackUserIndex
public void rollbackUserIndex(String idxName)
Remove user index without promoting it.- Parameters:
idxName- Index name.
-
removeIndex
public void removeIndex(org.h2.index.Index h2Idx)
- Overrides:
removeIndexin classorg.h2.table.Table
-
removeRow
public void removeRow(org.h2.engine.Session ses, org.h2.result.Row row)- Specified by:
removeRowin classorg.h2.table.Table
-
truncate
public void truncate(org.h2.engine.Session ses)
- Specified by:
truncatein classorg.h2.table.Table
-
addRow
public void addRow(org.h2.engine.Session ses, org.h2.result.Row row)- Specified by:
addRowin classorg.h2.table.Table
-
checkSupportAlter
public void checkSupportAlter()
- Specified by:
checkSupportAlterin classorg.h2.table.Table
-
getTableType
public org.h2.table.TableType getTableType()
- Specified by:
getTableTypein classorg.h2.table.Table
-
getScanIndex
public org.h2.index.Index getScanIndex(org.h2.engine.Session ses)
- Specified by:
getScanIndexin classorg.h2.table.Table
-
getUniqueIndex
public org.h2.index.Index getUniqueIndex()
- Specified by:
getUniqueIndexin classorg.h2.table.Table
-
getIndexes
public ArrayList<org.h2.index.Index> getIndexes()
- Specified by:
getIndexesin classorg.h2.table.Table
-
isLockedExclusively
public boolean isLockedExclusively()
- Specified by:
isLockedExclusivelyin classorg.h2.table.Table
-
isLockedExclusivelyBy
public boolean isLockedExclusivelyBy(org.h2.engine.Session ses)
- Overrides:
isLockedExclusivelyByin classorg.h2.table.Table
-
getMaxDataModificationId
public long getMaxDataModificationId()
- Specified by:
getMaxDataModificationIdin classorg.h2.table.Table
-
isDeterministic
public boolean isDeterministic()
- Specified by:
isDeterministicin classorg.h2.table.Table
-
canGetRowCount
public boolean canGetRowCount()
- Specified by:
canGetRowCountin classorg.h2.table.Table
-
canDrop
public boolean canDrop()
- Specified by:
canDropin classorg.h2.table.Table
-
getRowCount
public long getRowCount(@Nullable @Nullable org.h2.engine.Session ses)- Specified by:
getRowCountin classorg.h2.table.Table
-
getRowCountApproximation
public long getRowCountApproximation()
- Specified by:
getRowCountApproximationin classorg.h2.table.Table
-
checkRename
public void checkRename()
- Specified by:
checkRenamein interfaceorg.h2.engine.DbObject- Specified by:
checkRenamein classorg.h2.engine.DbObjectBase
-
indexColumn
public org.h2.table.IndexColumn indexColumn(int col, int sorting)Creates index column for table.- Parameters:
col- Column index.sorting- Sorting orderSortOrder- Returns:
- Created index column.
-
addColumns
public void addColumns(List<QueryField> cols)
Add new columns to this table.- Parameters:
cols- Columns to add.
-
setColumns
protected void setColumns(org.h2.table.Column[] columns)
- Overrides:
setColumnsin classorg.h2.table.Table
-
getColumns
public org.h2.table.Column[] getColumns()
- Overrides:
getColumnsin classorg.h2.table.Table
-
insertHack
public static void insertHack(boolean val)
Set insert hack flag.- Parameters:
val- Value.
-
insertHackRequired
public static boolean insertHackRequired(String sql)
Check whether insert hack is required. This is true in case statement contains "INSERT INTO ... VALUES".- Parameters:
sql- SQL statement.- Returns:
Trueif target combination is found.
-
unlockTables
public static void unlockTables(org.h2.engine.Session s)
- Parameters:
s- H2 session.
-
readLockTables
public static void readLockTables(org.h2.engine.Session s)
- Parameters:
s- H2 session.
-
checkTablesVersions
public static void checkTablesVersions(org.h2.engine.Session s)
- Parameters:
s- H2 session.
-
-