@Override public int exprSize() { int sz = 1; if (occ != null) for (final Expr o : occ) sz += o.exprSize(); for (final Expr e : exprs) sz += e.exprSize(); return sz + query.exprSize(); }
@Override public FTWords compile(final QueryContext qc, final VarScope scp) throws QueryException { if (occ != null) { final int ol = occ.length; for (int o = 0; o < ol; ++o) occ[o] = occ[o].compile(qc, scp); } // compile only once if (tokens == null) { query = query.compile(qc, scp); if (query.isValue()) tokens = tokens(qc); // choose fast evaluation for default settings fast = mode == FTMode.ANY && tokens != null && occ == null; if (ftt == null) ftt = new FTTokenizer(this, qc); } return this; }
@Override public FTExpr inline(final QueryContext qc, final VarScope scp, final Var var, final Expr ex) throws QueryException { boolean change = occ != null && inlineAll(qc, scp, occ, var, ex); final Expr q = query.inline(qc, scp, var, ex); if (q != null) { query = q; change = true; } return change ? optimize(qc, scp) : null; }
@Override public FTExpr copy(final QueryContext qc, final VarScope scp, final IntObjMap<Var> vs) { final FTWords ftw = new FTWords( info, query.copy(qc, scp, vs), mode, occ == null ? null : Arr.copyAll(qc, scp, vs, occ)); if (ftt != null) ftw.ftt = ftt.copy(ftw); ftw.tokens = tokens; ftw.data = data; ftw.first = first; ftw.pos = pos; ftw.fast = fast; return ftw; }
@Override public boolean accept(final ASTVisitor visitor) { return super.accept(visitor) && query.accept(visitor) && (occ == null || visitAll(visitor, occ)); }
@Override public VarUsage count(final Var var) { return occ != null ? VarUsage.sum(var, occ).plus(query.count(var)) : query.count(var); }
@Override public boolean removable(final Var var) { if (occ != null) for (final Expr o : occ) if (!o.removable(var)) return false; return query.removable(var); }
@Override public boolean has(final Flag flag) { if (occ != null) for (final Expr o : occ) if (o.has(flag)) return true; return query.has(flag); }