| Modifier and Type | Class and Description |
|---|---|
static class |
Expr.Use
Flags that influence query compilation.
|
| Constructor and Description |
|---|
Expr() |
| Modifier and Type | Method and Description |
|---|---|
Expr |
addText(QueryContext ctx)
Optionally adds a text node to an expression for potential index rewriting.
|
abstract Expr |
comp(QueryContext ctx)
Compiles and optimizes the expression, assigns data types and
cardinalities.
|
Expr |
compEbv(QueryContext ctx)
This method is called at compile time by expressions that perform
effective boolean value tests (e.g.
|
abstract int |
count(Var v)
Counts how often the specified variable is used by an expression.
|
abstract Item |
ebv(QueryContext ctx,
InputInfo ii)
Checks if the iterator can be dissolved into an effective boolean value.
|
boolean |
hasFreeVars(QueryContext ctx)
Checks if this expression has free variables.
|
boolean |
indexAccessible(IndexContext ic)
Checks if an expression can be rewritten to an index access.
|
Expr |
indexEquivalent(IndexContext ic)
Returns an equivalent expression which accesses an index structure.
|
boolean |
isEmpty()
Tests if this is an empty sequence.
|
boolean |
isFunction(Function f)
Checks if this expression is a certain function.
|
boolean |
isItem()
Tests if this is an item.
|
boolean |
isVacuous()
Tests if this is a vacuous expression (empty sequence or error function).
|
boolean |
isValue()
Tests if this is a value.
|
abstract Item |
item(QueryContext ctx,
InputInfo ii)
Evaluates the expression and returns the resulting item or
a
null reference, if the expression yields an empty sequence. |
abstract Iter |
iter(QueryContext ctx)
Evaluates the expression and returns an iterator on the resulting items.
|
boolean |
iterable()
Returns true if the expression is iterable, i.e., if it does not contain
any duplicates and if all results are sorted.
|
Expr |
markTailCalls()
Finds and marks tail calls, enabling TCO.
|
abstract boolean |
removable(Var v)
Checks if the specified variable is replaceable by a context item.
|
abstract Expr |
remove(Var v)
|
boolean |
sameAs(Expr cmp)
Compares the current and specified expression for equality.
|
abstract long |
size()
Returns the sequence size or 1.
|
abstract Item |
test(QueryContext ctx,
InputInfo ii)
Performs a predicate test and returns the item if test was successful.
|
abstract SeqType |
type()
Returns the sequence type of the evaluated value.
|
abstract boolean |
uses(Expr.Use u)
Indicates if an expression uses the specified type or operation.
|
abstract Value |
value(QueryContext ctx)
Evaluates the expression and returns the resulting value.
|
description, info, plan, toStringpublic abstract Expr comp(QueryContext ctx) throws QueryException
ctx - query contextQueryException - query exceptionpublic abstract Iter iter(QueryContext ctx) throws QueryException
item(org.basex.query.QueryContext, org.basex.util.InputInfo) must be implemented
by an expression, as it may be called by this method.ctx - query contextQueryException - query exceptionpublic abstract Item item(QueryContext ctx, InputInfo ii) throws QueryException
null reference, if the expression yields an empty sequence.
If this method is not overwritten, iter(org.basex.query.QueryContext) must be implemented
by an expression, as it may be called by this method.ctx - query contextii - input infoQueryException - query exceptionpublic abstract Value value(QueryContext ctx) throws QueryException
ctx - query contextQueryException - query exceptionpublic abstract Item ebv(QueryContext ctx, InputInfo ii) throws QueryException
ctx - query contextii - input infoQueryException - query exceptionpublic abstract Item test(QueryContext ctx, InputInfo ii) throws QueryException
ctx - query contextii - input infoQueryException - query exceptionpublic boolean isEmpty()
Empty class, which represents the empty sequence.public boolean isVacuous()
public boolean isValue()
public boolean isItem()
public abstract long size()
public abstract boolean uses(Expr.Use u)
comp(org.basex.query.QueryContext) methods to test the properties of sub-expressions.
It will return true as soon as at least one test is successful.u - type/operation to be foundpublic abstract int count(Var v)
GFLWOR.comp(org.basex.query.QueryContext) to rewrite where clauses as predicates and
remove statically bound or unused clausesGFLWOR.compHoist(org.basex.query.QueryContext) to hoist independent variablesv - variable to be checkedpublic abstract boolean removable(Var v)
Preds.removable(org.basex.query.util.Var), if one of the variables is used within
a predicate.MixedPath.removable(org.basex.query.util.Var), if the variable occurs within
the path.Group.removable(org.basex.query.util.Var), as the group by expression depends on
variable references.GFLWOR.comp(org.basex.query.QueryContext) to rewrite where clauses
into predicates.v - variable to be replacedpublic abstract Expr remove(Var v)
VarRef expressions for the given variable
by a Context reference. This method is called by
GFLWOR.comp(org.basex.query.QueryContext) to rewrite where clauses as predicates.v - variable to be replacedpublic Expr compEbv(QueryContext ctx)
This method is called at compile time by expressions that perform
effective boolean value tests (e.g. If or Preds).
If the arguments of the called expression return a boolean anyway,
the expression will be simplified.
Example in CmpV:
if($x eq true()) is rewritten to if($x), if $x
will always yield a single boolean.
ctx - query contextpublic abstract SeqType type()
public boolean iterable()
AxisPath.public boolean indexAccessible(IndexContext ic) throws QueryException
indexEquivalent(org.basex.query.util.IndexContext) must be
implemented as well.ic - index contextQueryException - query exceptionpublic Expr indexEquivalent(IndexContext ic) throws QueryException
indexAccessible(org.basex.query.util.IndexContext) is returns true for an
expression.ic - index contextQueryException - query exceptionpublic boolean sameAs(Expr cmp)
cmp - expression to be comparedpublic boolean isFunction(Function f)
f - function definitionpublic Expr addText(QueryContext ctx)
ctx - query contextpublic boolean hasFreeVars(QueryContext ctx)
ctx - query context on the level of this expressiontrue if there are variables which are used but not declared
in this expression, false otherwisepublic Expr markTailCalls()