Пример #1
0
  @Override
  public final Expr inline(final QueryContext ctx, final VarScope scp, final Var v, final Expr e)
      throws QueryException {

    final Value oldVal = ctx.value;
    try {
      ctx.value = root(ctx);
      final Expr rt = root == null ? null : root.inline(ctx, scp, v, e);
      if (rt != null) {
        setRoot(ctx, rt);
        ctx.value = oldVal;
        ctx.value = root(ctx);
      }

      boolean change = rt != null;
      for (int i = 0; i < steps.length; i++) {
        final Expr nw = steps[i].inline(ctx, scp, v, e);
        if (nw != null) {
          steps[i] = nw;
          change = true;
        }
      }
      return change ? optimize(ctx, scp) : null;
    } finally {
      ctx.value = oldVal;
    }
  }
Пример #2
0
 @Override
 public Expr inline(final QueryContext ctx, final VarScope scp, final Var v, final Expr e)
     throws QueryException {
   final boolean pr = super.inline(ctx, scp, v, e) != null;
   final Expr rt = root == null ? null : root.inline(ctx, scp, v, e);
   if (rt != null) root = rt;
   return pr || rt != null ? optimize(ctx, scp) : null;
 }
Пример #3
0
  @Override
  public Expr inline(final QueryContext qc, final VarScope scp, final Var var, final Expr ex)
      throws QueryException {

    boolean change = inlineAll(qc, scp, cases, var, ex);
    final Expr t = ts.inline(qc, scp, var, ex);
    if (t != null) {
      change = true;
      ts = t;
    }
    return change ? optimize(qc, scp) : null;
  }
Пример #4
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;
  }
Пример #5
0
  @Override
  public final Expr inline(final QueryContext qc, final VarScope scp, final Var var, final Expr ex)
      throws QueryException {

    boolean changed = false;
    if (root != null) {
      final Expr rt = root.inline(qc, scp, var, ex);
      if (rt != null) {
        root = rt;
        changed = true;
      }
    }

    final int sl = steps.length;
    for (int s = 0; s < sl; s++) {
      final Expr nw = steps[s].inline(qc, scp, var, ex);
      if (nw != null) {
        steps[s] = nw;
        changed = true;
      }
    }
    return changed ? optimize(qc, scp) : null;
  }