ExpressionVisitor
The visitor pattern is used to iterate through all expressions of a query
to optimize a statement.
| Methods |
| static HashSet |
allColumnsForTableFilters(TableFilter[] filters)
Get the set of columns of all tables.
|
| static HashSet |
allColumnsForTableFilters(TableFilter[] filters)
Get the set of columns of all tables.
Parameters:
filters - the filters
Returns:
the set of columns
|
| static ExpressionVisitor |
getColumnsVisitor(HashSet columns)
Create a new visitor to get all referenced columns.
|
| static ExpressionVisitor |
getColumnsVisitor(HashSet columns)
Create a new visitor to get all referenced columns.
Parameters:
columns - the columns map
Returns:
the new visitor
|
| static ExpressionVisitor |
getDependenciesVisitor(HashSet dependencies)
Create a new visitor object to collect dependencies.
|
| static ExpressionVisitor |
getDependenciesVisitor(HashSet dependencies)
Create a new visitor object to collect dependencies.
Parameters:
dependencies - the dependencies set
Returns:
the new visitor
|
| static ExpressionVisitor |
getMaxModificationIdVisitor()
|
| static ExpressionVisitor |
getMaxModificationIdVisitor()
|
| static ExpressionVisitor |
getNotFromResolverVisitor(ColumnResolver resolver)
Create a new visitor to check if no expression depends on the given
resolver.
|
| static ExpressionVisitor |
getNotFromResolverVisitor(ColumnResolver resolver)
Create a new visitor to check if no expression depends on the given
resolver.
Parameters:
resolver - the resolver
Returns:
the new visitor
|
| static ExpressionVisitor |
getOptimizableVisitor(Table table)
Create a new visitor to check if all aggregates are for the given table.
|
| static ExpressionVisitor |
getOptimizableVisitor(Table table)
Create a new visitor to check if all aggregates are for the given table.
Parameters:
table - the table
Returns:
the new visitor
|
| void |
addColumn(Column column)
Add a new column to the set of columns.
|
| void |
addColumn(Column column)
Add a new column to the set of columns.
This is used for GET_COLUMNS visitors.
Parameters:
column - the additional column.
|
| void |
addDataModificationId(long value)
Update the field maxDataModificationId if this value is higher
than the current value.
|
| void |
addDataModificationId(long value)
Update the field maxDataModificationId if this value is higher
than the current value.
This is used for SET_MAX_DATA_MODIFICATION_ID visitors.
Parameters:
value - the data modification id
|
| void |
addDependency(DbObject obj)
Add a new dependency to the set of dependencies.
|
| void |
addDependency(DbObject obj)
Add a new dependency to the set of dependencies.
This is used for GET_DEPENDENCIES visitors.
Parameters:
obj - the additional dependency.
|
| HashSet |
getDependencies()
Get the dependency set.
|
| HashSet |
getDependencies()
Get the dependency set.
This is used for GET_DEPENDENCIES visitors.
Returns:
the set
|
| long |
getMaxDataModificationId()
Get the last data modification.
|
| long |
getMaxDataModificationId()
Get the last data modification.
This is used for SET_MAX_DATA_MODIFICATION_ID visitors.
Returns:
the maximum modification id
|
| int |
getQueryLevel()
|
| int |
getQueryLevel()
|
| ColumnResolver |
getResolver()
Get the column resolver.
|
| ColumnResolver |
getResolver()
Get the column resolver.
This is used for NOT_FROM_RESOLVER visitors.
Returns:
the column resolver
|
| Table |
getTable()
Get the table.
|
| Table |
getTable()
Get the table.
This is used for OPTIMIZABLE_MIN_MAX_COUNT_ALL visitors.
Returns:
the table
|
| int |
getType()
Get the visitor type.
|
| int |
getType()
Get the visitor type.
Returns:
the type
|
| ExpressionVisitor |
incrementQueryLevel(int offset)
Increment or decrement the query level.
|
| ExpressionVisitor |
incrementQueryLevel(int offset)
Increment or decrement the query level.
Parameters:
offset - 1 to increment, -1 to decrement
Returns:
a clone of this expression visitor, with the changed query level
|
INDEPENDENT
= 0
Is the value independent on unset parameters or on columns of a higher
level query, or sequence values (that means can it be evaluated right
now)?
OPTIMIZABLE_MIN_MAX_COUNT_ALL
= 1
Are all aggregates MIN(column), MAX(column), or COUNT(*) for the given
table (getTable)?
DETERMINISTIC
= 2
Does the expression return the same results for the same parameters?
EVALUATABLE
= 3
Can the expression be evaluated, that means are all columns set to
'evaluatable'?
SET_MAX_DATA_MODIFICATION_ID
= 4
Request to set the latest modification id (addDataModificationId).
READONLY
= 5
Does the expression have no side effects (change the data)?
NOT_FROM_RESOLVER
= 6
Does an expression have no relation to the given table filter
(getResolver)?
GET_DEPENDENCIES
= 7
Request to get the set of dependencies (addDependency).
QUERY_COMPARABLE
= 8
Can the expression be added to a condition of an outer query. Example:
ROWNUM() can't be added as a condition to the inner query of select id
from (select t.*, rownum as r from test t) where r between 2 and 3; Also
a sequence expression must not be used.
GET_COLUMNS
= 9
Get all referenced columns.
DETERMINISTIC_VISITOR
The visitor singleton for the type DETERMINISTIC.
EVALUATABLE_VISITOR
The visitor singleton for the type EVALUATABLE.
INDEPENDENT_VISITOR
The visitor singleton for the type INDEPENDENT.
QUERY_COMPARABLE_VISITOR
The visitor singleton for the type QUERY_COMPARABLE.
READONLY_VISITOR
The visitor singleton for the type EVALUATABLE.