Example #1
0
 @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();
 }
Example #2
0
  @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;
  }
Example #3
0
  @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;
  }
Example #4
0
 @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;
 }
Example #5
0
 @Override
 public boolean accept(final ASTVisitor visitor) {
   return super.accept(visitor)
       && query.accept(visitor)
       && (occ == null || visitAll(visitor, occ));
 }
Example #6
0
 @Override
 public VarUsage count(final Var var) {
   return occ != null ? VarUsage.sum(var, occ).plus(query.count(var)) : query.count(var);
 }
Example #7
0
 @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);
 }
Example #8
0
 @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);
 }