예제 #1
0
파일: Except.java 프로젝트: CAPDM/basex
  @Override
  public Expr compile(final QueryContext ctx) throws QueryException {
    super.compile(ctx);
    if (expr[0].isEmpty()) return optPre(null, ctx);

    for (int e = 1; e < expr.length; ++e) {
      if (expr[e].isEmpty()) {
        ctx.compInfo(OPTREMOVE, description(), expr[e]);
        expr = Array.delete(expr, e--);
      }
    }
    // results must always be sorted
    return expr.length == 1 && iterable ? expr[0] : this;
  }
예제 #2
0
파일: Except.java 프로젝트: james-jw/basex
  @Override
  public Expr optimize(final QueryContext qc, final VarScope scp) throws QueryException {
    super.optimize(qc, scp);

    final ExprList el = new ExprList(exprs.length);
    for (final Expr ex : exprs) {
      if (ex.isEmpty()) {
        // remove empty operands (return empty sequence if first value is empty)
        if (el.isEmpty()) return optPre(qc);
        qc.compInfo(OPTREMOVE_X_X, this, ex);
      } else {
        el.add(ex);
      }
    }
    // ensure that results are always sorted
    if (el.size() == 1 && iterable) return el.get(0);
    // replace expressions with optimized list
    exprs = el.finish();
    return this;
  }