Top Description Inners Fields Constructors Methods
org.h2.table

public abstract Class QueryExpressionTable

extends Table
Class Inheritance
Known Direct Subclasses
org.h2.table.TableView, org.h2.table.CTE, org.h2.table.DerivedTable
Imports
java.util.ArrayList, .Arrays, .HashSet, .List, .Map, org.h2.command.QueryScope, org.h2.command.query.AllColumnsForPlan, .Query, org.h2.engine.DbObject, .SessionLocal, org.h2.expression.Expression, .ExpressionVisitor, .Parameter, org.h2.index.Index, .IndexType, .QueryExpressionIndex, org.h2.message.DbException, org.h2.result.Row, .SortOrder, org.h2.schema.Schema, org.h2.value.TypeInfo, .Value

A derived table or view.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
QueryExpressionTable.CacheKey

The key of the index cache for views.

Field Summary

Modifier and TypeField and Description
private long
private long
private static final long
pack-priv ArrayList<Table>
pack-priv Query
Inherited from org.h2.table.Table:
columnscompareModeEXCLUSIVE_LOCKREAD_LOCKTYPE_CACHEDTYPE_MEMORYWRITE_LOCK

Constructor Summary

AccessConstructor and Description
pack-priv
QueryExpressionTable(Schema schema, int id, String name)

Method Summary

Modifier and TypeMethod and Description
public final void
addDependencies(HashSet<DbObject>
the current set of dependencies
dependencies
)

Overrides org.h2.table.Table.addDependencies.

Add all objects that this table depends on to the hash set.

public final Index
addIndex(SessionLocal
the session
session
,
String
the name of the index
indexName
,
int
the id
indexId
,
IndexColumn[]
the index columns
cols
,
int
the count of unique columns
uniqueColumnCount
,
IndexType
the index type
indexType
,
boolean
whether this is a new index
create
,
String
the comment
indexComment
)

Implements abstract org.h2.table.Table.addIndex.

Create an index for this table

public final void
addRow(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.table.Table.addRow.

Add a row to the table and all indexes.

public final boolean
canGetRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.canGetRowCount.

Check if the row count can be retrieved quickly.

public final boolean
canReference()

Overrides org.h2.table.Table.canReference.

Check if this table can be referenced.

public final void
checkSupportAlter()

Implements abstract org.h2.table.Table.checkSupportAlter.

Check if this table supports ALTER TABLE.

public final void
close(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.close.

Close the table object and flush changes.

pack-priv abstract QueryExpressionIndex
createIndex(SessionLocal session, int[] masks)

public static List<Column>

Returns:

a list of column object returned by withQuery
createQueryColumnTemplateList
(String[]
- an optional list of column names (can be specified by WITH clause overriding usual select names)
cols
,
Query
- the query object we want the column list for
theQuery
)

Creates a list of column templates from a query (usually from WITH query, but could be any query)

public final PlanItem
getBestPlanItem(SessionLocal
the session
session
,
int[]
per-column comparison bit masks, null means 'always false', see constants in IndexCondition
masks
,
TableFilter[]
all joined table filters
filters
,
int
the current table filter index
filter
,
SortOrder
the sort order
sortOrder
,
AllColumnsForPlan
the set of all columns
allColumnsSet
)

Overrides org.h2.table.Table.getBestPlanItem.

Get the best plan for the given search mask.

public final ArrayList<Index>
getIndexes()

Implements abstract org.h2.table.Table.getIndexes.

Get all indexes for this table.

public long
getMaxDataModificationId()

Implements abstract org.h2.table.Table.getMaxDataModificationId.

Get the last data modification id.

public final int

Returns:

the index of the first parameter
getParameterOffset
(ArrayList<Parameter>
additional parameters
additionalParameters
)

Get the index of the first parameter.

public final Query
public abstract QueryScope

Returns:

the scope of this table
getQueryScope
()

Returns the scope of this table

public final long
getRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getRowCount.

Get the row count for this table.

public final long
getRowCountApproximation(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getRowCountApproximation.

Get the approximated row count for this table.

public final Index
getScanIndex(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getScanIndex.

Get the scan index to iterate through all rows.

public Index
getScanIndex(SessionLocal
the session
session
,
int[]
the search mask
masks
,
TableFilter[]
the table filters
filters
,
int
the filter index
filter
,
SortOrder
the sort order
sortOrder
,
AllColumnsForPlan
all columns
allColumnsSet
)

Overrides org.h2.table.Table.getScanIndex.

Get the scan index for this table.

public abstract Query
pack-priv Column[]
initColumns(SessionLocal session, Column[] columnTemplates, Query query, boolean isDerivedTable)

public boolean
isDeterministic()

Implements abstract org.h2.table.Table.isDeterministic.

Check if the table is deterministic.

public final boolean
isInsertable()

Overrides org.h2.table.Table.isInsertable.

Returns whether this table is insertable.

public boolean
isQueryComparable()

Overrides org.h2.table.Table.isQueryComparable.

Check whether the table (or view) contains no columns that prevent index conditions to be used.

public final boolean
public final void
removeRow(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.table.Table.removeRow.

Remove a row from the table and all indexes.

public final long
truncate(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.truncate.

Remove all rows from the table and indexes.

Inherited from org.h2.table.Table:
addConstraintaddDependentMaterializedViewaddDependentViewaddSequenceaddSynonymaddTriggercanDropcanTruncatecheckDeadlockcheckWritingAllowedcompareValuesconvertInsertRowconvertUpdateRowcreateRowdoesColumnExistdropMultipleColumnsConstraintsAndIndexesfindColumnfindPrimaryKeyfirefireAfterRowfireBeforeRowfireRowgetCheckForeignKeyConstraintsgetChildrengetColumngetColumngetColumngetColumnsgetCompareModegetConstraintsgetDependentMaterializedViewsgetDependentViewsgetDiskSpaceUsedgetIdentityColumngetIndexgetIndexForColumngetMainIndexColumngetNullRowgetOnCommitDropgetOnCommitTruncategetPrimaryKeygetRowgetRowFactorygetRowIdColumngetSQLTableTypegetTableTypegetTemplateRowgetTemplateSimpleRowgetTriggersgetTypegetVisibleColumnshasSelectTriggerisGlobalTemporaryisLockedExclusivelyisLockedExclusivelyByisPersistDataisPersistIndexesisRowLockablelocklockRowremoveChildrenAndResourcesremoveColumnExpressionsDependenciesremoveConstraintremoveDependentMaterializedViewremoveDependentViewremoveIndexremoveIndexOrTransferOwnershipremoveSequenceremoveSynonymremoveTriggerrenamerenameColumnsetCheckForeignKeyConstraintssetColumnssetOnCommitDropsetOnCommitTruncateunlockupdateRowupdateRows

Field Detail

lastModificationCheckback to summary
private long lastModificationCheck
maxDataModificationIdback to summary
private long maxDataModificationId
ROW_COUNT_APPROXIMATIONback to summary
private static final long ROW_COUNT_APPROXIMATION
tablesback to summary
pack-priv ArrayList<Table> tables
viewQueryback to summary
pack-priv Query viewQuery

Constructor Detail

QueryExpressionTableback to summary
pack-priv QueryExpressionTable(Schema schema, int id, String name)

Method Detail

addDependenciesback to summary
public final void addDependencies(HashSet<DbObject> dependencies)

Overrides org.h2.table.Table.addDependencies.

Doc from org.h2.table.Table.addDependencies.

Add all objects that this table depends on to the hash set.

Parameters
dependencies:HashSet<DbObject>

the current set of dependencies

Annotations
@Override
addIndexback to summary
public final Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)

Implements abstract org.h2.table.Table.addIndex.

Doc from org.h2.table.Table.addIndex.

Create an index for this table

Parameters
session:SessionLocal

the session

indexName:String

the name of the index

indexId:int

the id

cols:IndexColumn[]

the index columns

uniqueColumnCount:int

the count of unique columns

indexType:IndexType

the index type

create:boolean

whether this is a new index

indexComment:String

the comment

Returns:Index

the index

Annotations
@Override
addRowback to summary
public final void addRow(SessionLocal session, Row row)

Implements abstract org.h2.table.Table.addRow.

Doc from org.h2.table.Table.addRow.

Add a row to the table and all indexes.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
canGetRowCountback to summary
public final boolean canGetRowCount(SessionLocal session)

Implements abstract org.h2.table.Table.canGetRowCount.

Doc from org.h2.table.Table.canGetRowCount.

Check if the row count can be retrieved quickly.

Parameters
session:SessionLocal

the session

Returns:boolean

true if it can

Annotations
@Override
canReferenceback to summary
public final boolean canReference()

Overrides org.h2.table.Table.canReference.

Doc from org.h2.table.Table.canReference.

Check if this table can be referenced.

Returns:boolean

true if it can

Annotations
@Override
checkSupportAlterback to summary
public final void checkSupportAlter()

Implements abstract org.h2.table.Table.checkSupportAlter.

Doc from org.h2.table.Table.checkSupportAlter.

Check if this table supports ALTER TABLE.

Annotations
@Override
closeback to summary
public final void close(SessionLocal session)

Implements abstract org.h2.table.Table.close.

Doc from org.h2.table.Table.close.

Close the table object and flush changes.

Parameters
session:SessionLocal

the session

Annotations
@Override
createIndexback to summary
pack-priv abstract QueryExpressionIndex createIndex(SessionLocal session, int[] masks)
createQueryColumnTemplateListback to summary
public static List<Column> createQueryColumnTemplateList(String[] cols, Query theQuery)

Creates a list of column templates from a query (usually from WITH query, but could be any query)

Parameters
cols:String[]

- an optional list of column names (can be specified by WITH clause overriding usual select names)

theQuery:Query

- the query object we want the column list for

Returns:List<Column>

a list of column object returned by withQuery

getBestPlanItemback to summary
public final PlanItem getBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)

Overrides org.h2.table.Table.getBestPlanItem.

Doc from org.h2.table.Table.getBestPlanItem.

Get the best plan for the given search mask.

Parameters
session:SessionLocal

the session

masks:int[]

per-column comparison bit masks, null means 'always false', see constants in IndexCondition

filters:TableFilter[]

all joined table filters

filter:int

the current table filter index

sortOrder:SortOrder

the sort order

allColumnsSet:AllColumnsForPlan

the set of all columns

Returns:PlanItem

the plan item

Annotations
@Override
getIndexesback to summary
public final ArrayList<Index> getIndexes()

Implements abstract org.h2.table.Table.getIndexes.

Doc from org.h2.table.Table.getIndexes.

Get all indexes for this table.

Returns:ArrayList<Index>

the list of indexes

Annotations
@Override
getMaxDataModificationIdback to summary
public long getMaxDataModificationId()

Implements abstract org.h2.table.Table.getMaxDataModificationId.

Doc from org.h2.table.Table.getMaxDataModificationId.

Get the last data modification id.

Returns:long

the modification id

Annotations
@Override
getParameterOffsetback to summary
public final int getParameterOffset(ArrayList<Parameter> additionalParameters)

Get the index of the first parameter.

Parameters
additionalParameters:ArrayList<Parameter>

additional parameters

Returns:int

the index of the first parameter

getQueryback to summary
public final Query getQuery()
getQueryScopeback to summary
public abstract QueryScope getQueryScope()

Returns the scope of this table

Returns:QueryScope

the scope of this table

getRowCountback to summary
public final long getRowCount(SessionLocal session)

Implements abstract org.h2.table.Table.getRowCount.

Doc from org.h2.table.Table.getRowCount.

Get the row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the row count

Annotations
@Override
getRowCountApproximationback to summary
public final long getRowCountApproximation(SessionLocal session)

Implements abstract org.h2.table.Table.getRowCountApproximation.

Doc from org.h2.table.Table.getRowCountApproximation.

Get the approximated row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the approximated row count

Annotations
@Override
getScanIndexback to summary
public final Index getScanIndex(SessionLocal session)

Implements abstract org.h2.table.Table.getScanIndex.

Doc from org.h2.table.Table.getScanIndex.

Get the scan index to iterate through all rows.

Parameters
session:SessionLocal

the session

Returns:Index

the index

Annotations
@Override
getScanIndexback to summary
public Index getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)

Overrides org.h2.table.Table.getScanIndex.

Doc from org.h2.table.Table.getScanIndex.

Get the scan index for this table.

Parameters
session:SessionLocal

the session

masks:int[]

the search mask

filters:TableFilter[]

the table filters

filter:int

the filter index

sortOrder:SortOrder

the sort order

allColumnsSet:AllColumnsForPlan

all columns

Returns:Index

the scan index

Annotations
@Override
getTopQueryback to summary
public abstract Query getTopQuery()
initColumnsback to summary
pack-priv Column[] initColumns(SessionLocal session, Column[] columnTemplates, Query query, boolean isDerivedTable)
isDeterministicback to summary
public boolean isDeterministic()

Implements abstract org.h2.table.Table.isDeterministic.

Doc from org.h2.table.Table.isDeterministic.

Check if the table is deterministic.

Returns:boolean

true if it is

Annotations
@Override
isInsertableback to summary
public final boolean isInsertable()

Overrides org.h2.table.Table.isInsertable.

Doc from org.h2.table.Table.isInsertable.

Returns whether this table is insertable.

Returns:boolean

whether this table is insertable

Annotations
@Override
isQueryComparableback to summary
public boolean isQueryComparable()

Overrides org.h2.table.Table.isQueryComparable.

Doc from org.h2.table.Table.isQueryComparable.

Check whether the table (or view) contains no columns that prevent index conditions to be used. For example, a view that contains the ROWNUM() pseudo-column prevents this.

Returns:boolean

true if the table contains no query-comparable column

Annotations
@Override
isViewback to summary
public final boolean isView()

Overrides org.h2.table.Table.isView.

Annotations
@Override
removeRowback to summary
public final void removeRow(SessionLocal session, Row row)

Implements abstract org.h2.table.Table.removeRow.

Doc from org.h2.table.Table.removeRow.

Remove a row from the table and all indexes.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
truncateback to summary
public final long truncate(SessionLocal session)

Implements abstract org.h2.table.Table.truncate.

Doc from org.h2.table.Table.truncate.

Remove all rows from the table and indexes.

Parameters
session:SessionLocal

the session

Returns:long

number of removed rows, possibly including uncommitted rows

Annotations
@Override
org.h2.table back to summary

pack-priv final Class QueryExpressionTable.CacheKey

extends Object
Class Inheritance

The key of the index cache for views.

Field Summary

Modifier and TypeField and Description
private final int[]
private final QueryExpressionTable

Constructor Summary

AccessConstructor and Description
pack-priv
CacheKey(int[] masks, QueryExpressionTable queryExpressionTable)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

masksback to summary
private final int[] masks
queryExpressionTableback to summary
private final QueryExpressionTable queryExpressionTable

Constructor Detail

CacheKeyback to summary
pack-priv CacheKey(int[] masks, QueryExpressionTable queryExpressionTable)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override