Package org.h2.index
Class IndexCondition
- java.lang.Object
-
- org.h2.index.IndexCondition
-
public class IndexCondition extends java.lang.ObjectAn index condition object is made for each condition that can potentially use an index. This class does not extend expression, but in general there is one expression that maps to each index condition.
-
-
Field Summary
Fields Modifier and Type Field Description static intALWAYS_FALSEA bit of a search mask meaning 'the condition is always false'.static intENDA bit of a search mask meaning 'smaller or equal'.static intEQUALITYA bit of a search mask meaning 'equal'.static intRANGEA search mask meaning 'between'.static intSPATIAL_INTERSECTSA bit of a search mask meaning 'spatial intersection'.static intSTARTA bit of a search mask meaning 'larger or equal'.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexConditioncloneWithIndexColumns(Index index)Creates a copy of this index condition but using thecolumnsof theindex.static IndexConditionget(int compareType, ExpressionColumn column, Expression expression)Create an index condition with the given parameters.ColumngetColumn()Get the referenced column.Column[]getColumns()Get the referenced columns.intgetCompareType()static IndexConditiongetCompoundInList(Column[] columns, java.util.List<Expression> list)Create a compound index condition with the compare type IN_LIST and with the given parameters.ResultInterfacegetCurrentResult(SessionLocal session, int[] sortTypes)Get the current result of the expression.ValuegetCurrentValue(SessionLocal session)Get the current value of the expression.Value[]getCurrentValueList(SessionLocal session, int[] sortTypes)Get the current value list of the expression.ExpressiongetExpression()Get expression.java.util.List<Expression>getExpressionList()Get expression list.QuerygetExpressionQuery()Get expression query.static IndexConditiongetInArray(ExpressionColumn column, Expression array)Create an index condition with the compare type IN_ARRAY and with the given parameters.static IndexConditiongetInList(ExpressionColumn column, java.util.List<Expression> list)Create an index condition with the compare type IN_LIST and with the given parameters.static IndexConditiongetInQuery(ExpressionColumn column, Query query)Create an index condition with the compare type IN_QUERY and with the given parameters.intgetMask(java.util.ArrayList<IndexCondition> indexConditions)Get the comparison bit mask.java.lang.StringgetSQL(int sqlFlags)Get the SQL snippet of this comparison.booleanisAlwaysFalse()Check if the result is always false.booleanisCompoundColumns()Check if the expression contains multiple columnsbooleanisEnd()Check if this index condition is of the type column smaller or equal to value.booleanisEvaluatable()Check if the expression can be evaluated.booleanisSpatialIntersects()Check if this index condition is of the type spatial column intersects value.booleanisStart()Check if this index condition is of the type column larger or equal to value.java.lang.StringtoString()
-
-
-
Field Detail
-
EQUALITY
public static final int EQUALITY
A bit of a search mask meaning 'equal'.- See Also:
- Constant Field Values
-
START
public static final int START
A bit of a search mask meaning 'larger or equal'.- See Also:
- Constant Field Values
-
END
public static final int END
A bit of a search mask meaning 'smaller or equal'.- See Also:
- Constant Field Values
-
RANGE
public static final int RANGE
A search mask meaning 'between'.- See Also:
- Constant Field Values
-
ALWAYS_FALSE
public static final int ALWAYS_FALSE
A bit of a search mask meaning 'the condition is always false'.- See Also:
- Constant Field Values
-
SPATIAL_INTERSECTS
public static final int SPATIAL_INTERSECTS
A bit of a search mask meaning 'spatial intersection'.- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static IndexCondition get(int compareType, ExpressionColumn column, Expression expression)
Create an index condition with the given parameters.- Parameters:
compareType- the comparison type, see constants inComparisoncolumn- the columnexpression- the expression- Returns:
- the index condition
-
getInList
public static IndexCondition getInList(ExpressionColumn column, java.util.List<Expression> list)
Create an index condition with the compare type IN_LIST and with the given parameters.- Parameters:
column- the columnlist- the expression list- Returns:
- the index condition
-
getCompoundInList
public static IndexCondition getCompoundInList(Column[] columns, java.util.List<Expression> list)
Create a compound index condition with the compare type IN_LIST and with the given parameters.- Parameters:
columns- the columnslist- the expression list- Returns:
- the index condition
-
getInArray
public static IndexCondition getInArray(ExpressionColumn column, Expression array)
Create an index condition with the compare type IN_ARRAY and with the given parameters.- Parameters:
column- the columnarray- the array- Returns:
- the index condition
-
getInQuery
public static IndexCondition getInQuery(ExpressionColumn column, Query query)
Create an index condition with the compare type IN_QUERY and with the given parameters.- Parameters:
column- the columnquery- the select statement- Returns:
- the index condition
-
getCurrentValue
public Value getCurrentValue(SessionLocal session)
Get the current value of the expression.- Parameters:
session- the session- Returns:
- the value
-
getCurrentValueList
public Value[] getCurrentValueList(SessionLocal session, int[] sortTypes)
Get the current value list of the expression. The value list is of the same type as the column, distinct, and sorted.- Parameters:
session- the sessionsortTypes- sort types- Returns:
- the value list
-
getCurrentResult
public ResultInterface getCurrentResult(SessionLocal session, int[] sortTypes)
Get the current result of the expression. The rows may not be of the same type, therefore the rows may not be unique.- Parameters:
session- the sessionsortTypes- sort types- Returns:
- the result
-
getSQL
public java.lang.String getSQL(int sqlFlags)
Get the SQL snippet of this comparison.- Parameters:
sqlFlags- formatting flags- Returns:
- the SQL snippet
-
getMask
public int getMask(java.util.ArrayList<IndexCondition> indexConditions)
Get the comparison bit mask.- Parameters:
indexConditions- all index conditions- Returns:
- the mask
-
isAlwaysFalse
public boolean isAlwaysFalse()
Check if the result is always false.- Returns:
- true if the result will always be false
-
isStart
public boolean isStart()
Check if this index condition is of the type column larger or equal to value.- Returns:
- true if this is a start condition
-
isEnd
public boolean isEnd()
Check if this index condition is of the type column smaller or equal to value.- Returns:
- true if this is an end condition
-
isSpatialIntersects
public boolean isSpatialIntersects()
Check if this index condition is of the type spatial column intersects value.- Returns:
- true if this is a spatial intersects condition
-
getCompareType
public int getCompareType()
-
getColumn
public Column getColumn()
Get the referenced column.- Returns:
- the column
- Throws:
DbException- ifisCompoundColumns()istrue
-
getColumns
public Column[] getColumns()
Get the referenced columns.- Returns:
- the column array
- Throws:
DbException- ifisCompoundColumns()isfalse
-
isCompoundColumns
public boolean isCompoundColumns()
Check if the expression contains multiple columns- Returns:
- true if it contains multiple columns
-
getExpression
public Expression getExpression()
Get expression.- Returns:
- Expression.
-
getExpressionList
public java.util.List<Expression> getExpressionList()
Get expression list.- Returns:
- Expression list.
-
getExpressionQuery
public Query getExpressionQuery()
Get expression query.- Returns:
- Expression query.
-
isEvaluatable
public boolean isEvaluatable()
Check if the expression can be evaluated.- Returns:
- true if it can be evaluated
-
cloneWithIndexColumns
public IndexCondition cloneWithIndexColumns(Index index)
Creates a copy of this index condition but using thecolumnsof theindex.- Parameters:
index- a non-null Index- Returns:
- a new IndexCondition with the specified columns, or
nullif the index does not match with this condition.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-