Package org.openrdf.sail.rdbms.algebra

Examples of org.openrdf.sail.rdbms.algebra.SqlEq


  public static SqlExpr concat(SqlExpr left, SqlExpr right) {
    return new SqlConcat(left, right);
  }

  public static SqlExpr eq(SqlExpr left, SqlExpr right) {
    return new SqlEq(left, right);
  }
View Full Code Here


  public static SqlExpr in(SqlExpr compare, SqlExpr... values) {
    SqlExpr expr = null;
    for (SqlExpr value : values) {
      if (expr == null) {
        expr = new SqlEq(compare, value);
      }
      else {
        expr = or(expr, new SqlEq(compare.clone(), value));
      }
    }
    if (expr == null) {
      return new FalseValue();
    }
View Full Code Here

  public static SqlExpr lt(SqlExpr left, SqlExpr right) {
    return new SqlCompare(left, CompareOp.LT, right);
  }

  public static SqlExpr neq(SqlExpr left, SqlExpr right) {
    return new SqlNot(new SqlEq(left, right));
  }
View Full Code Here

  }

  private FromItem valueJoin(String alias, String tableName, ColumnVar using, boolean left) {
    JoinItem j = new JoinItem(alias, tableName);
    j.setLeft(left);
    j.addFilter(new SqlEq(new IdColumn(alias), new RefIdColumn(using)));
    return j;
  }
View Full Code Here

    for (ColumnVar var : new ColumnVar[] { s, p, o, c }) {
      from.addVar(var);
      Value value = var.getValue();
      if (vars.containsKey(var.getName())) {
        IdColumn existing = new IdColumn(vars.get(var.getName()));
        from.addFilter(new SqlEq(new IdColumn(var), existing));
      }
      else if (value != null && !var.isImplied()) {
        try {
          NumberValue vc = new NumberValue(vf.getInternalId(value));
          from.addFilter(new SqlEq(new RefIdColumn(var), vc));
        }
        catch (RdbmsException e) {
          throw new RdbmsException(e);
        }
      }
      else {
        vars.put(var.getName(), var);
      }
      if (!var.isHiddenOrConstant() && value == null) {
        SelectProjection proj = new SelectProjection();
        proj.setVar(var);
        proj.setId(new RefIdColumn(var));
        proj.setStringValue(coalesce(new URIColumn(var), new BNodeColumn(var), new LabelColumn(var),
            new LongLabelColumn(var), new LongURIColumn(var)));
        proj.setDatatype(new DatatypeColumn(var));
        proj.setLanguage(new LanguageColumn(var));
        query.addSqlSelectVar(proj);
      }
    }
    if (contexts.length > 0) {
      RdbmsResource[] ids = vf.asRdbmsResource(contexts);
      RefIdColumn var = new RefIdColumn(c);
      SqlExpr in = null;
      for (RdbmsResource id : ids) {
        NumberValue longValue;
        try {
          longValue = new NumberValue(vf.getInternalId(id));
        }
        catch (RdbmsException e) {
          throw new RdbmsException(e);
        }
        SqlEq eq = new SqlEq(var.clone(), longValue);
        if (in == null) {
          in = eq;
        }
        else {
          in = new SqlOr(in, eq);
View Full Code Here

    for (ColumnVar var : new ColumnVar[] { s, p, o, c }) {
      from.addVar(var);
      Value value = var.getValue();
      if (vars.containsKey(var.getName())) {
        IdColumn existing = new IdColumn(vars.get(var.getName()));
        from.addFilter(new SqlEq(new IdColumn(var), existing));
      }
      else if (value != null && !var.isImplied()) {
        try {
          NumberValue vc = new NumberValue(vf.getInternalId(value));
          from.addFilter(new SqlEq(new RefIdColumn(var), vc));
        }
        catch (RdbmsException e) {
          throw new RdbmsRuntimeException(e);
        }
      }
      else {
        vars.put(var.getName(), var);
      }
      if (!var.isHidden() && value == null) {
        SelectProjection proj = new SelectProjection();
        proj.setVar(var);
        proj.setId(new RefIdColumn(var));
        proj.setStringValue(coalesce(new URIColumn(var), new BNodeColumn(var), new LabelColumn(var),
            new LongLabelColumn(var), new LongURIColumn(var)));
        proj.setDatatype(new DatatypeColumn(var));
        proj.setLanguage(new LanguageColumn(var));
        query.addSqlSelectVar(proj);
      }
    }
    if (contexts.length > 0) {
      RdbmsResource[] ids = vf.asRdbmsResource(contexts);
      RefIdColumn var = new RefIdColumn(c);
      SqlExpr in = null;
      for (RdbmsResource id : ids) {
        NumberValue longValue;
        try {
          longValue = new NumberValue(vf.getInternalId(id));
        }
        catch (RdbmsException e) {
          throw new RdbmsRuntimeException(e);
        }
        SqlEq eq = new SqlEq(var.clone(), longValue);
        if (in == null) {
          in = eq;
        }
        else {
          in = new SqlOr(in, eq);
View Full Code Here

  public static SqlExpr concat(SqlExpr left, SqlExpr right) {
    return new SqlConcat(left, right);
  }

  public static SqlExpr eq(SqlExpr left, SqlExpr right) {
    return new SqlEq(left, right);
  }
View Full Code Here

  public static SqlExpr in(SqlExpr compare, SqlExpr... values) {
    SqlExpr expr = null;
    for (SqlExpr value : values) {
      if (expr == null) {
        expr = new SqlEq(compare, value);
      }
      else {
        expr = or(expr, new SqlEq(compare.clone(), value));
      }
    }
    if (expr == null)
      return new FalseValue();
    return expr;
View Full Code Here

  public static SqlExpr lt(SqlExpr left, SqlExpr right) {
    return new SqlCompare(left, CompareOp.LT, right);
  }

  public static SqlExpr neq(SqlExpr left, SqlExpr right) {
    return new SqlNot(new SqlEq(left, right));
  }
View Full Code Here

  }

  private FromItem valueJoin(String alias, String tableName, ColumnVar using, boolean left) {
    JoinItem j = new JoinItem(alias, tableName);
    j.setLeft(left);
    j.addFilter(new SqlEq(new IdColumn(alias), new RefIdColumn(using)));
    return j;
  }
View Full Code Here

TOP

Related Classes of org.openrdf.sail.rdbms.algebra.SqlEq

Copyright © 2018 www.massapicom. 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.