org.basex.query.ft
Class FTExpr

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.expr.ParseExpr
              extended by org.basex.query.ft.FTExpr
Direct Known Subclasses:
FTAnd, FTExtensionSelection, FTFilter, FTMildNot, FTNot, FTOptions, FTOr, FTWeight, FTWords

public abstract class FTExpr
extends ParseExpr

This class defines is an abstract class for full-text expressions.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
 FTExpr[] expr
          Expression list.
 
Fields inherited from class org.basex.query.expr.ParseExpr
info, size, type
 
Method Summary
 boolean accept(ASTVisitor visitor)
          Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.
 void checkUp()
          Checks if all updating expressions are correctly placed.
 FTExpr compile(QueryContext ctx, VarScope scp)
          Compiles and optimizes the expression, assigns data types and cardinalities.
abstract  FTExpr copy(QueryContext ctx, VarScope scp, IntObjMap<Var> vs)
          Copies an expression.
 VarUsage count(Var v)
          Checks how often a variable is used in this expression.
 int exprSize()
          Counts the number of expressions in this expression's sub-tree.
 boolean has(Expr.Flag flag)
          Indicates if an expression has the specified compiler property.
 FTExpr indexEquivalent(IndexCosts ic)
          Returns an equivalent expression which accesses an index structure.
 FTExpr inline(QueryContext ctx, VarScope scp, Var v, Expr e)
          Inlines an expression into this one, replacing all references to the given variable.
abstract  FTNode item(QueryContext ctx, InputInfo ii)
          This method is called by the sequential full-text evaluation.
abstract  FTIter iter(QueryContext ctx)
          This method is called by the index-based full-text evaluation.
 FTExpr optimize(QueryContext ctx, VarScope scp)
          Optimizes an already compiled expression without recompiling its sub-expressions.
 void plan(FElem plan)
          Creates an expression tree.
 boolean removable(Var v)
          Checks if the specified variable is replaceable by a context item.
 
Methods inherited from class org.basex.query.expr.ParseExpr
checkAdmin, checkAllUp, checkBinary, checkBln, checkColl, checkCreate, checkCtx, checkDbl, checkDBNode, checkEStr, checkEStr, checkFunc, checkItem, checkItr, checkItr, checkMap, checkNode, checkNode, checkNode, checkNoEmpty, checkNoneUp, checkNoUp, checkQNm, checkStr, checkStr, checkStrBin, checkType, checkWrite, compBln, copyType, ebv, optPre, preEval, size, test, type, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, inlineAll, isEmpty, isFunction, isItem, isVacuous, isValue, iterable, markTailCalls, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, description, info, planAttr, planElem, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

expr

public final FTExpr[] expr
Expression list.

Method Detail

checkUp

public void checkUp()
             throws QueryException
Description copied from class: Expr
Checks if all updating expressions are correctly placed. This function is only called if any updating expression was found in the query.

Specified by:
checkUp in class Expr
Throws:
QueryException - query exception

compile

public FTExpr compile(QueryContext ctx,
                      VarScope scp)
               throws QueryException
Description copied from class: Expr
Compiles and optimizes the expression, assigns data types and cardinalities.

Specified by:
compile in class Expr
Parameters:
ctx - query context
scp - variable scope
Returns:
optimized expression
Throws:
QueryException - query exception

optimize

public FTExpr optimize(QueryContext ctx,
                       VarScope scp)
                throws QueryException
Description copied from class: Expr
Optimizes an already compiled expression without recompiling its sub-expressions.

Overrides:
optimize in class Expr
Parameters:
ctx - query context
scp - variable scope
Returns:
optimized expression
Throws:
QueryException - query exception

item

public abstract FTNode item(QueryContext ctx,
                            InputInfo ii)
                     throws QueryException
This method is called by the sequential full-text evaluation.

Overrides:
item in class ParseExpr
Parameters:
ctx - query context
ii - input info
Returns:
resulting item
Throws:
QueryException - query exception

iter

public abstract FTIter iter(QueryContext ctx)
                     throws QueryException
This method is called by the index-based full-text evaluation.

Overrides:
iter in class ParseExpr
Parameters:
ctx - query context
Returns:
resulting item
Throws:
QueryException - query exception

has

public boolean has(Expr.Flag flag)
Description copied from class: Expr
Indicates if an expression has the specified compiler property. This method is called by numerous Expr.compile(org.basex.query.QueryContext, org.basex.query.var.VarScope) methods to test properties of sub-expressions. It returns true if at least one test is successful.

Specified by:
has in class Expr
Parameters:
flag - flag to be found
Returns:
result of check

removable

public boolean removable(Var v)
Description copied from class: Expr
Checks if the specified variable is replaceable by a context item. The following tests might return false: This method is called by GFLWOR.compile(org.basex.query.QueryContext, org.basex.query.var.VarScope) to rewrite where clauses into predicates.

Specified by:
removable in class Expr
Parameters:
v - variable to be replaced
Returns:
result of check

count

public VarUsage count(Var v)
Description copied from class: Expr
Checks how often a variable is used in this expression.

Specified by:
count in class Expr
Parameters:
v - variable to look for
Returns:
how often the variable is used, see VarUsage

inline

public FTExpr inline(QueryContext ctx,
                     VarScope scp,
                     Var v,
                     Expr e)
              throws QueryException
Description copied from class: Expr
Inlines an expression into this one, replacing all references to the given variable.

Specified by:
inline in class Expr
Parameters:
ctx - query context for recompilation
scp - variable scope for recompilation
v - variable to replace
e - expression to inline
Returns:
resulting expression in something changed, null otherwise
Throws:
QueryException - query exception

copy

public abstract FTExpr copy(QueryContext ctx,
                            VarScope scp,
                            IntObjMap<Var> vs)
Description copied from class: Expr
Copies an expression. Will be useful for inlining functions, or for copying static queries.

Specified by:
copy in class Expr
Parameters:
ctx - query context
scp - variable scope for creating new variables
vs - mapping from old variable IDs to new variable copies
Returns:
copied expression

indexEquivalent

public FTExpr indexEquivalent(IndexCosts ic)
                       throws QueryException
Description copied from class: Expr
Returns an equivalent expression which accesses an index structure. Will be called if Expr.indexAccessible(org.basex.query.util.IndexCosts) is returns true for an expression.

Overrides:
indexEquivalent in class Expr
Parameters:
ic - index costs analyzer
Returns:
equivalent index-expression
Throws:
QueryException - query exception

plan

public void plan(FElem plan)
Description copied from class: ExprInfo
Creates an expression tree.

Specified by:
plan in class ExprInfo
Parameters:
plan - root element

accept

public boolean accept(ASTVisitor visitor)
Description copied from class: Expr
Traverses this expression, notifying the visitor of declared and used variables, and checking the tree for other recursive properties.

Specified by:
accept in class Expr
Parameters:
visitor - visitor
Returns:
if the walk should be continued

exprSize

public int exprSize()
Description copied from class: Expr
Counts the number of expressions in this expression's sub-tree.

Specified by:
exprSize in class Expr
Returns:
number of expressions