Package de.fuberlin.wiwiss.d2rq.algebra

Examples of de.fuberlin.wiwiss.d2rq.algebra.Attribute


    int i = 0;
    while (it.hasNext()) {
      uriPattern += i == 0 ? "/" : ";";
      i++;
     
      Attribute column = it.next();
      uriPattern += encodeColumnName(column) + "=@@" + column.qualifiedName();
      if (!database.columnType(column).isIRISafe()) {
        uriPattern += "|encode";
      }
      uriPattern += "@@";
    }
View Full Code Here


  protected void writePseudoEntityIdentifier(RelationName tableName) {
    List<Attribute> usedColumns = filter(schema.listColumns(tableName), true, "pseudo identifier column");
    out.print("\td2rq:bNodeIdColumns \"");
    Iterator<Attribute> it = usedColumns.iterator();
    while (it.hasNext()) {
      Attribute column = it.next();
      out.print(column.qualifiedName());
      if (it.hasNext()) {
        out.print(",");
      }
    }
    out.println("\";");
View Full Code Here

 
  private List<Expression> matchPatterns(Pattern p1, Pattern p2) {
    List<Expression> results = new ArrayList<Expression>(p1.attributes().size());
    if (p1.isEquivalentTo(p2)) {
      for (int i = 0; i < p1.attributes().size(); i++) {
        Attribute col1 = p1.attributes().get(i);
        Attribute col2 = p2.attributes().get(i);
        results.add(Equality.createAttributeEquality(col1, col2));
      }
    } else {
      results.add(Equality.create(p1.toExpression(), p2.toExpression()));
      // FIXME: Actually support it
View Full Code Here

        ProjectionSpec projection = (ProjectionSpec) projectionIterator.next();
       
        Set<Attribute> reqAttr = projection.requiredAttributes();
        Iterator<Attribute> j = reqAttr.iterator();
        while (j.hasNext() && !err) {
          Attribute a = (Attribute) j.next();
          if (attributes.relationName == null)
            attributes.relationName = a.relationName();
          else if (!attributes.relationName.equals(a.relationName()))
            err = true;
         
          attributes.attributeNames.add(a.attributeName());
        }
       
//        if (projection instanceof Attribute) {
//          Attribute a = (Attribute) projection;
//          if (attributes.relationName == null)
View Full Code Here

  }
 
  public void testFindsColumns() {
    Expression e = SQLExpression.create("papers.publish = 1 AND papers.url1 != 'http://www.example.com\\'http://www.example.com' AND papers.url2 != 'http://www.example.com\\\\\\\\http://www.example.com' AND papers.rating > 4");
    Set<Attribute> expectedColumns = new HashSet<Attribute>(Arrays.asList(
        new Attribute[]{new Attribute(null, "papers", "publish"),
            new Attribute(null, "papers", "url1"),
            new Attribute(null, "papers", "url2"),
            new Attribute(null, "papers", "rating")}));
    assertEquals(expectedColumns, e.attributes());
  }
View Full Code Here

            new AliasMap(Collections.singleton(a))));
  }
 
  public void testRenameColumnsWithColumnReplacer() {
    Map<Attribute,Attribute> map = new HashMap<Attribute,Attribute>();
    map.put(new Attribute(null, "foo", "col1"), new Attribute(null, "foo", "col2"));
    assertEquals(SQLExpression.create("foo.col2=foo.col3"),
        SQLExpression.create("foo.col1=foo.col3").renameAttributes(new ColumnRenamerMap(map)));
  }
View Full Code Here

  public void testConstantToSQL() {
    assertEquals("'foo'", new Constant("foo").toSQL(new DummyDB(), AliasMap.NO_ALIASES));
  }
 
  public void testConstantToSQLWithType() {
    Attribute attribute = SQL.parseAttribute("table.col1");
    DummyDB db = new DummyDB(Collections.singletonMap("table.col1", GenericType.NUMERIC));
    assertEquals("42", new Constant("42", attribute).toSQL(db, AliasMap.NO_ALIASES));
  }
View Full Code Here

    DummyDB db = new DummyDB(Collections.singletonMap("table.col1", GenericType.NUMERIC));
    assertEquals("42", new Constant("42", attribute).toSQL(db, AliasMap.NO_ALIASES));
  }
 
  public void testConstantToSQLWithTypeAndAlias() {
    Attribute aliasedAttribute = SQL.parseAttribute("alias.col1");
    DummyDB db = new DummyDB(Collections.singletonMap("table.col1", GenericType.NUMERIC));
    assertEquals("42", new Constant("42", aliasedAttribute).toSQL(db, aliases));
  }
View Full Code Here

        SQL.findColumnsInExpression("'must.not.match' = foo.col1 && foo.col2 = 'must.not' && foo.col2"));
  }

  public void testFindColumnsInExpressionWithSchema() {
    assertEquals(new HashSet<Attribute>(Arrays.asList(new Attribute[]{
        new Attribute("s1", "t1", "c1"),
        new Attribute("s2", "t2", "c2")})),
        SQL.findColumnsInExpression("s1.t1.c1 + s2.t2.c2 = 135"));
  }
View Full Code Here

    DummyDB db = new DummyDB(Collections.singletonMap("table.col1", GenericType.NUMERIC));
    assertEquals("42", new Constant("42", aliasedAttribute).toSQL(db, aliases));
  }
 
  public void testConstantTypeAttributeIsRenamed() {
    Attribute attribute = SQL.parseAttribute("table.col1");
    assertEquals("Constant(42@alias.col1)",
        new Constant("42", attribute).renameAttributes(aliases).toString());
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.algebra.Attribute

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.