Top Description Fields Constructors Methods
org.h2.index

public Class IndexCondition

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .List, .TreeSet, org.h2.command.query.Query, org.h2.engine.SessionLocal, org.h2.expression.Expression, .ExpressionColumn, .ExpressionList, .ExpressionVisitor, .ValueExpression, org.h2.expression.condition.Comparison, org.h2.message.DbException, org.h2.result.ResultInterface, org.h2.table.Column, .IndexColumn, .TableType, org.h2.value.Value, .ValueArray, .ValueRow

An 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.
Authors
Thomas Mueller, Noel Grandin, Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888

Field Summary

Modifier and TypeField and Description
public static final int
ALWAYS_FALSE

A bit of a search mask meaning 'the condition is always false'.

private final Column
private final Column[]
private final int
compareType

see constants in Comparison

private final boolean
public static final int
END

A bit of a search mask meaning 'smaller or equal'.

public static final int
EQUALITY

A bit of a search mask meaning 'equal'.

private final Expression
private final List<Expression>
private final Query
public static final int
RANGE

A search mask meaning 'between'.

public static final int
SPATIAL_INTERSECTS

A bit of a search mask meaning 'spatial intersection'.

public static final int
START

A bit of a search mask meaning 'larger or equal'.

Constructor Summary

AccessConstructor and Description
private
IndexCondition(int
the comparison type, see constants in Comparison
compareType
,
ExpressionColumn column, Column[] columns, Expression expression, List<Expression> list, Query query)

Method Summary

Modifier and TypeMethod and Description
private StringBuilder
buildSql(int sqlFlags, StringBuilder builder)

private StringBuilder
buildSql(int sqlFlags, Column column, StringBuilder builder)

public IndexCondition

Returns:

a new IndexCondition with the specified columns, or null if the index does not match with this condition.
cloneWithIndexColumns
(Index
a non-null Index
index
)

Creates a copy of this index condition but using the columns of the index.

private static StringBuilder
public static IndexCondition

Returns:

the index condition
get
(int
the comparison type, see constants in Comparison
compareType
,
ExpressionColumn
the column
column
,
Expression
the expression
expression
)

Create an index condition with the given parameters.

public Column

Returns:

the column
getColumn
()

Get the referenced column.

public Column[]

Returns:

the column array
getColumns
()

Get the referenced columns.

public int
public static IndexCondition

Returns:

the index condition
getCompoundInList
(ExpressionList
the columns
columns
,
List<Expression>
the expression list
list
)

Create a compound index condition with the compare type IN_LIST and with the given parameters.

public ResultInterface

Returns:

the result
getCurrentResult
()

Get the current result of the expression.

public Value

Returns:

the value
getCurrentValue
(SessionLocal
the session
session
)

Get the current value of the expression.

public Value[]

Returns:

the value list
getCurrentValueList
(SessionLocal
the session
session
)

Get the current value list of the expression.

public Expression

Returns:

Expression.
getExpression
()

Get expression.

public List<Expression>

Returns:

Expression list.
getExpressionList
()

Get expression list.

public Query

Returns:

Expression query.
getExpressionQuery
()

Get expression query.

public static IndexCondition

Returns:

the index condition
getInArray
(ExpressionColumn
the column
column
,
Expression
the array
array
)

Create an index condition with the compare type IN_ARRAY and with the given parameters.

public static IndexCondition

Returns:

the index condition
getInList
(ExpressionColumn
the column
column
,
List<Expression>
the expression list
list
)

Create an index condition with the compare type IN_LIST and with the given parameters.

public static IndexCondition

Returns:

the index condition
getInQuery
(ExpressionColumn
the column
column
,
Query
the select statement
query
)

Create an index condition with the compare type IN_QUERY and with the given parameters.

public int

Returns:

the mask
getMask
(ArrayList<IndexCondition>
all index conditions
indexConditions
)

Get the comparison bit mask.

public String

Returns:

the SQL snippet
getSQL
(int
formatting flags
sqlFlags
)

Get the SQL snippet of this comparison.

public boolean

Returns:

true if the result will always be false
isAlwaysFalse
()

Check if the result is always false.

public boolean

Returns:

true if it contains multiple columns
isCompoundColumns
()

Check if the expression contains multiple columns

public boolean

Returns:

true if this is an end condition
isEnd
()

Check if this index condition is of the type column smaller or equal to value.

public boolean

Returns:

true if it can be evaluated
isEvaluatable
()

Check if the expression can be evaluated.

public boolean

Returns:

true if this is a spatial intersects condition
isSpatialIntersects
()

Check if this index condition is of the type spatial column intersects value.

public boolean

Returns:

true if this is a start condition
isStart
()

Check if this index condition is of the type column larger or equal to value.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ALWAYS_FALSEback to summary
public static final int ALWAYS_FALSE

A bit of a search mask meaning 'the condition is always false'.

columnback to summary
private final Column column
columnsback to summary
private final Column[] columns
compareTypeback to summary
private final int compareType

see constants in Comparison

compoundColumnsback to summary
private final boolean compoundColumns
ENDback to summary
public static final int END

A bit of a search mask meaning 'smaller or equal'.

EQUALITYback to summary
public static final int EQUALITY

A bit of a search mask meaning 'equal'.

expressionback to summary
private final Expression expression
expressionListback to summary
private final List<Expression> expressionList
expressionQueryback to summary
private final Query expressionQuery
RANGEback to summary
public static final int RANGE

A search mask meaning 'between'.

SPATIAL_INTERSECTSback to summary
public static final int SPATIAL_INTERSECTS

A bit of a search mask meaning 'spatial intersection'.

STARTback to summary
public static final int START

A bit of a search mask meaning 'larger or equal'.

Constructor Detail

IndexConditionback to summary
private IndexCondition(int compareType, ExpressionColumn column, Column[] columns, Expression expression, List<Expression> list, Query query)
Parameters
compareType:int

the comparison type, see constants in Comparison

Method Detail

buildSqlback to summary
private StringBuilder buildSql(int sqlFlags, StringBuilder builder)
buildSqlback to summary
private StringBuilder buildSql(int sqlFlags, Column column, StringBuilder builder)
cloneWithIndexColumnsback to summary
public IndexCondition cloneWithIndexColumns(Index index)

Creates a copy of this index condition but using the columns of the index.

Parameters
index:Index

a non-null Index

Returns:IndexCondition

a new IndexCondition with the specified columns, or null if the index does not match with this condition.

compareTypeToStringback to summary
private static StringBuilder compareTypeToString(StringBuilder builder, int i)
getback to summary
public static IndexCondition get(int compareType, ExpressionColumn column, Expression expression)

Create an index condition with the given parameters.

Parameters
compareType:int

the comparison type, see constants in Comparison

column:ExpressionColumn

the column

expression:Expression

the expression

Returns:IndexCondition

the index condition

getColumnback to summary
public Column getColumn()

Get the referenced column.

Returns:Column

the column

Exceptions
DbException:
if isCompoundColumns() is true
getColumnsback to summary
public Column[] getColumns()

Get the referenced columns.

Returns:Column[]

the column array

Exceptions
DbException:
if isCompoundColumns() is false
getCompareTypeback to summary
public int getCompareType()
getCompoundInListback to summary
public static IndexCondition getCompoundInList(ExpressionList columns, List<Expression> list)

Create a compound index condition with the compare type IN_LIST and with the given parameters.

Parameters
columns:ExpressionList

the columns

list:List<Expression>

the expression list

Returns:IndexCondition

the index condition

getCurrentResultback to summary
public ResultInterface getCurrentResult()

Get the current result of the expression. The rows may not be of the same type, therefore the rows may not be unique.

Returns:ResultInterface

the result

getCurrentValueback to summary
public Value getCurrentValue(SessionLocal session)

Get the current value of the expression.

Parameters
session:SessionLocal

the session

Returns:Value

the value

getCurrentValueListback to summary
public Value[] getCurrentValueList(SessionLocal session)

Get the current value list of the expression. The value list is of the same type as the column, distinct, and sorted.

Parameters
session:SessionLocal

the session

Returns:Value[]

the value list

getExpressionback to summary
public Expression getExpression()

Get expression.

Returns:Expression

Expression.

getExpressionListback to summary
public List<Expression> getExpressionList()

Get expression list.

Returns:List<Expression>

Expression list.

getExpressionQueryback to summary
public Query getExpressionQuery()

Get expression query.

Returns:Query

Expression query.

getInArrayback to summary
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:ExpressionColumn

the column

array:Expression

the array

Returns:IndexCondition

the index condition

getInListback to summary
public static IndexCondition getInList(ExpressionColumn column, List<Expression> list)

Create an index condition with the compare type IN_LIST and with the given parameters.

Parameters
column:ExpressionColumn

the column

list:List<Expression>

the expression list

Returns:IndexCondition

the index condition

getInQueryback to summary
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:ExpressionColumn

the column

query:Query

the select statement

Returns:IndexCondition

the index condition

getMaskback to summary
public int getMask(ArrayList<IndexCondition> indexConditions)

Get the comparison bit mask.

Parameters
indexConditions:ArrayList<IndexCondition>

all index conditions

Returns:int

the mask

getSQLback to summary
public String getSQL(int sqlFlags)

Get the SQL snippet of this comparison.

Parameters
sqlFlags:int

formatting flags

Returns:String

the SQL snippet

isAlwaysFalseback to summary
public boolean isAlwaysFalse()

Check if the result is always false.

Returns:boolean

true if the result will always be false

isCompoundColumnsback to summary
public boolean isCompoundColumns()

Check if the expression contains multiple columns

Returns:boolean

true if it contains multiple columns

isEndback to summary
public boolean isEnd()

Check if this index condition is of the type column smaller or equal to value.

Returns:boolean

true if this is an end condition

isEvaluatableback to summary
public boolean isEvaluatable()

Check if the expression can be evaluated.

Returns:boolean

true if it can be evaluated

isSpatialIntersectsback to summary
public boolean isSpatialIntersects()

Check if this index condition is of the type spatial column intersects value.

Returns:boolean

true if this is a spatial intersects condition

isStartback to summary
public boolean isStart()

Check if this index condition is of the type column larger or equal to value.

Returns:boolean

true if this is a start condition

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override