Examples of SQLExpr


Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

    throws UnsupportedRdbmsOperatorException
  {
    SqlRegexBuilder regex = filter.regex();
    dispatch(expr.getArg(), regex.value());
    dispatch(expr.getPatternArg(), regex.pattern());
    SqlExpr flags = expr.getFlagsArg();
    if (flags != null) {
      dispatch(flags, regex.flags());
    }
    regex.close();
  }
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  @Override
  public void meet(SqlCompare node)
    throws RuntimeException
  {
    super.meet(node);
    SqlExpr left = node.getLeftArg();
    SqlExpr right = node.getRightArg();
    if (left instanceof SqlNull || right instanceof SqlNull) {
      replace(node, new SqlNull());
    }
  }
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  @Override
  public void meet(SqlConcat node)
    throws RuntimeException
  {
    super.meet(node);
    SqlExpr left = node.getLeftArg();
    SqlExpr right = node.getRightArg();
    if (left instanceof StringValue && right instanceof StringValue) {
      StringValue l = (StringValue)left;
      StringValue r = (StringValue)right;
      replace(node, new StringValue(l.getValue() + r.getValue()));
    }
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  @Override
  public void meet(SqlEq node)
    throws RuntimeException
  {
    super.meet(node);
    SqlExpr left = node.getLeftArg();
    SqlExpr right = node.getRightArg();
    if (left instanceof SqlNull || right instanceof SqlNull) {
      replace(node, new SqlNull());
    }
    else if (left instanceof SqlConstant<?> && right instanceof SqlConstant<?>) {
      SqlConstant<?> l = (SqlConstant<?>)left;
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  @Override
  public void meet(SqlIsNull node)
    throws RuntimeException
  {
    super.meet(node);
    SqlExpr arg = node.getArg();
    if (arg instanceof SqlNull) {
      replace(node, new TrueValue());
    }
    else if (arg instanceof SqlConstant<?>) {
      replace(node, new FalseValue());
    }
    else if (arg instanceof SqlCase) {
      SqlExpr rep = null;
      SqlExpr prev = null;
      SqlCase scase = (SqlCase)arg;
      for (Entry entry : scase.getEntries()) {
        SqlExpr condition = entry.getCondition();
        if (rep == null) {
          rep = and(condition.clone(), isNull(entry.getResult().clone()));
          prev = not(condition.clone());
        }
        else {
          rep = or(rep, and(and(prev.clone(), condition.clone()), isNull(entry.getResult().clone())));
          prev = and(prev, not(condition.clone()));
        }
      }
      replace(node, or(rep, prev.clone()));
    }
  }
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  @Override
  public void meet(SqlNot node)
    throws RuntimeException
  {
    super.meet(node);
    SqlExpr arg = node.getArg();
    if (arg instanceof TrueValue) {
      replace(node, new FalseValue());
    }
    else if (arg instanceof FalseValue) {
      replace(node, new TrueValue());
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  public void meet(SqlOr node)
    throws RuntimeException
  {
    super.meet(node);
    boolean top = andAllTheWay(node);
    SqlExpr sqlNull = null;
    for (SqlExpr arg : node.getArgs()) {
      if (arg instanceof TrueValue) {
        replace(node, new TrueValue());
        return;
      }
      else if (arg instanceof FalseValue) {
        node.removeChildNode(arg);
      }
      else if (top && arg instanceof SqlNull) {
        node.removeChildNode(arg);
      }
      else if (sqlNull != null && arg instanceof SqlNull) {
        node.removeChildNode(arg);
      }
      else if (arg instanceof SqlNull) {
        sqlNull = arg;
      }
    }
    if (node.getNumberOfArguments() == 0) {
      replace(node, new FalseValue());
    }
    else if (node.getNumberOfArguments() == 1) {
      replace(node, node.getArg(0));
    }
    else if (sqlNull != null) {
      for (SqlExpr arg : node.getArgs()) {
        if (arg instanceof SqlOr) {
          SqlOr nestedOr = (SqlOr)arg;
          for (SqlExpr nestedArg : nestedOr.getArgs()) {
            if (nestedArg instanceof SqlNull) {
              nestedOr.removeChildNode(nestedArg);
            }
          }
          if (nestedOr.getNumberOfArguments() == 0) {
            replace(nestedOr, new SqlNull());
          }
          else if (nestedOr.getNumberOfArguments() == 1) {
            replace(nestedOr, nestedOr.getArg(0));
          }
        }
        else if (arg instanceof SqlAnd) {
          // value IS NOT NULL AND value = ? OR NULL
          // -> value = ?
          SqlAnd and = (SqlAnd)arg;
          // search for the value IS NOT NULL expression
          for (SqlExpr isNotNull : and.getArgs()) {
            SqlExpr variable = arg(arg(isNotNull, SqlNot.class), SqlIsNull.class);
            if (variable == null) {
              continue;
            }
            // search for the value = ? expression
            for (SqlExpr eq : and.getArgs()) {
              SqlExpr constant = other(eq, variable, SqlEq.class);
              if (constant == null) {
                continue;
              }
              if (constant instanceof SqlConstant) {
                node.removeChildNode(sqlNull);
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  }

  private SqlExpr other(SqlExpr node, SqlExpr compare, Class<? extends BinarySqlOperator> type) {
    if (type.isInstance(node)) {
      BinarySqlOperator cast = type.cast(node);
      SqlExpr left = cast.getLeftArg();
      SqlExpr right = cast.getRightArg();
      if (left.equals(compare)) {
        return right;
      }
      if (right.equals(compare)) {
        return left;
      }
    }
    return null;
  }
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  @Override
  public void meet(SqlRegex node)
    throws RuntimeException
  {
    super.meet(node);
    SqlExpr flags = node.getFlagsArg();
    if (!(flags instanceof SqlNull)) {
      SqlExpr pattern = node.getPatternArg();
      SqlExpr prefix = concat(str("(?"), flags, str(")"));
      pattern.replaceWith(concat(prefix, pattern.clone()));
      node.setFlagsArg(null);
    }
  }
View Full Code Here

Examples of org.openrdf.sail.rdbms.algebra.base.SqlExpr

  private SqlExpr str(String string) {
    return new StringValue(string);
  }

  private SqlExpr concat(SqlExpr... exprs) {
    SqlExpr concat = null;
    for (SqlExpr expr : exprs) {
      if (concat == null) {
        concat = expr;
      }
      else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.