Modifier and Type | Field and Description |
---|---|
Expr |
root
Root expression.
|
Expr[] |
steps
Path steps.
|
Modifier | Constructor and Description |
---|---|
protected |
Path(InputInfo info,
Expr root,
Expr[] steps)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(ASTVisitor visitor)
Traverses this expression, notifying the visitor of declared and used variables,
and checking the tree for other recursive properties.
|
Path |
addPreds(Expr... preds)
Adds predicates to the last step.
|
boolean |
cheap()
Guesses if the evaluation of this axis path is cheap.
|
void |
checkUp()
Checks if all updating expressions are correctly placed.
|
Expr |
compile(QueryContext qc,
VarScope scp)
Compiles and optimizes the expression, assigns types and cardinalities.
|
VarUsage |
count(Var var)
Checks how often a variable is used in this expression.
|
Data |
data()
Returns the data reference bound to this expression.
|
int |
exprSize()
Counts the number of expressions in this expression's sub-tree.
|
static Path |
get(InputInfo info,
Expr root,
Expr... steps)
Returns a new path instance.
|
boolean |
has(Expr.Flag flag)
Indicates if an expression has the specified compiler property.
|
Expr |
index(QueryContext qc,
Value rt)
Returns an equivalent expression which accesses an index.
|
static Value |
initial(QueryContext qc,
Expr root)
Returns a context value for the given root, or
null . |
Expr |
inline(QueryContext qc,
VarScope scp,
Var var,
Expr ex)
Inlines an expression into this one, replacing all references to the given variable.
|
Expr |
optimize(QueryContext qc,
VarScope scp)
Optimizes an already compiled expression without recompiling its sub-expressions.
|
Expr |
optimizeEbv(QueryContext qc,
VarScope scp)
|
ArrayList<PathNode> |
pathNodes(QueryContext qc)
Returns the path nodes that will result from this path.
|
void |
plan(FElem plan)
Creates an expression tree.
|
boolean |
removable(Var var)
Checks if the specified variable is replaceable by a context value.
|
String |
toString() |
atomItem, atomValue, checkAtomic, checkNoEmpty, checkNoEmpty, checkNoneUp, checkNoUp, checkType, compBln, copyType, ctxValue, ebv, item, iter, optPre, optPre, preEval, seqType, seqType, size, test, toArray, toArray, toAtomItem, toB64, toB64, toBin, toBin, toBoolean, toBoolean, toBytes, toBytes, toDouble, toDouble, toElem, toEmptyNode, toEmptyToken, toFloat, toFunc, toItem, toLong, toLong, toMap, toMap, toNode, toNode, toNumber, toQNm, toQNm, toToken, toToken, value
atomIter, copy, hasFreeVars, indexAccessible, inlineAll, isEmpty, isFunction, isVacuous, isValue, iterable, markTailCalls, sameAs, typeCheck, uses, visitAll
addPlan, addPlan, description, planAttr, planElem, toErrorString
public static Path get(InputInfo info, Expr root, Expr... steps)
info
- input inforoot
- root expression, may be null
steps
- stepspublic final void checkUp() throws QueryException
Expr
checkUp
in class Expr
QueryException
- query exceptionpublic final Expr compile(QueryContext qc, VarScope scp) throws QueryException
Expr
QueryContext.compile()
.compile
in class Expr
qc
- query contextscp
- variable scopeQueryException
- query exceptionpublic final Expr optimize(QueryContext qc, VarScope scp) throws QueryException
Expr
optimize
in class Expr
qc
- query contextscp
- variable scopeQueryException
- query exceptionpublic Expr optimizeEbv(QueryContext qc, VarScope scp) throws QueryException
Expr
This method is e.g. overwritten by expressions like CmpG
, CmpV
,
FnBoolean
, FnExists
, Path
or Filter
.
It 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
is known to return a single boolean.
optimizeEbv
in class Expr
qc
- query contextscp
- variable scopeQueryException
- query exceptionpublic final boolean has(Expr.Flag flag)
Expr
true
if at least one test is successful.public final Path addPreds(Expr... preds)
preds
- predicate to be addedpublic final ArrayList<PathNode> pathNodes(QueryContext qc)
qc
- query contextnull
if nodes cannot be evaluatedpublic final boolean cheap()
public static Value initial(QueryContext qc, Expr root)
null
.qc
- query context (may be @code null)root
- root expressionpublic Expr index(QueryContext qc, Value rt) throws QueryException
ValueAccess
instances):
1. A[text() = '...'] -> IA('...', A) 2. A[. = '...'] -> IA('...', A) 3. text()[. = '...'] -> IA('...') 4. A[B = '...'] -> IA('...', B)/parent::A 1. A[B/text() = '...'] -> IA('...')/parent::B/parent::A 2. A[B/C = '...'] -> IA('...', C)/parent::B/parent::A 7. A[@a = '...'] -> IA('...', @a)/parent::A 8. @a[. = '...'] -> IA('...', @a)Queries of type 1, 3, 5 will not yield any results if the string to be compared is empty.
qc
- query contextrt
- root value (can be null
)QueryException
- query exceptionpublic final boolean removable(Var var)
Expr
Preds.removable(org.basex.query.var.Var)
if one of the variables is used within a predicate.removable(org.basex.query.var.Var)
if the variable occurs within the path.GFLWOR.compile(QueryContext, VarScope)
to rewrite where
clauses into predicates.public VarUsage count(Var var)
Expr
SwitchCase.countCases(org.basex.query.var.Var)
or (indirectly)
GFLWOR.inlineLets(org.basex.query.QueryContext, org.basex.query.var.VarScope)
.public final Expr inline(QueryContext qc, VarScope scp, Var var, Expr ex) throws QueryException
Expr
GFLWOR.inlineLets(org.basex.query.QueryContext, org.basex.query.var.VarScope)
and For.toPredicate(org.basex.query.QueryContext, org.basex.query.var.VarScope, org.basex.query.expr.Expr)
,
and the variable reference is replaced in VarRef.inline(org.basex.query.QueryContext, org.basex.query.var.VarScope, org.basex.query.var.Var, org.basex.query.expr.Expr)
.inline
in class Expr
qc
- query context for reoptimizationscp
- variable scope for reoptimizationvar
- variable to replaceex
- expression to inlinenull
otherwiseQueryException
- query exceptionpublic boolean accept(ASTVisitor visitor)
Expr
public final int exprSize()
Expr
StaticFunc.inline(org.basex.query.QueryContext, org.basex.query.util.list.AnnList, org.basex.query.expr.Expr)
to check if an expression
is small enough to be inlined.public final void plan(FElem plan)
ExprInfo
Copyright © 2005–2015 BaseX Team. All rights reserved.