Package de.fuberlin.wiwiss.d2rq.algebra

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


  public void testConstraintInTripleNoMatch() {
    assertNull(translate1("?x rdf:type ?x", "engine/type-bridge.n3"));
  }
 
  public void testConstraintInTripleMatch() {
    NodeRelation nodeRel = translate1("?x rdf:type ?x", "engine/object-uricolumn.n3");
    Relation r = nodeRel.baseRelation();
    assertEquals(Collections.singleton(table1), r.tables());
    assertTrue(r.condition() instanceof Equality)// Too lazy to check both sides
    assertEquals(AliasMap.NO_ALIASES, r.aliases());
    assertEquals(Collections.singleton(x), nodeRel.variables());
  }
View Full Code Here


  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation label_fr_be = search("table1", "label_fr_be", rels);
    NodeRelation label_en = search("table1", "label_en", rels);
    NodeRelation label = search("table1", "label", rels);
   
    Expr filterFR    = new E_LangMatches(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr"));
    Expr filterEN    = new E_LangMatches(new E_Lang(new ExprVar("o")), NodeValue.makeString("en"));
    Expr filterFR_BE = new E_LangMatches(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr-BE"));
    Expr filterALL   = new E_LangMatches(new E_Lang(new ExprVar("o")), NodeValue.makeString("*"));
 
View Full Code Here

  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
       
    NodeRelation label = search("table1", "label", rels);
    NodeRelation label_en = search("table1", "label_en", rels);
   
    pattern.clear();
    pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
    rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation intvalue = search("table2", "intvalue", rels);
   
    Expr subject = new E_IsLiteral(new ExprVar("s"));
    Expr object  = new E_IsLiteral(new ExprVar("o"));
   
    assertEquals("ISLITERAL(literal) should be TRUE",      Expression.TRUE,  TransformExprToSQLApplyer.convert(object, label));
View Full Code Here

  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
       
    NodeRelation label = search("table1", "label", rels);
    NodeRelation label_en = search("table1", "label_en", rels);
   
    pattern.clear();
    pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
    rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation intvalue = search("table2", "intvalue", rels);
   
    Expr subject = new E_IsIRI(new ExprVar("s"));
    Expr object  = new E_IsIRI(new ExprVar("o"));
   
    assertEquals("ISIRI(literal) should be FALSE",      Expression.FALSE, TransformExprToSQLApplyer.convert(object, label));
View Full Code Here

    NodeRelation[] rels = translate("?s ?p ?o", "engine/simple.n3");
    assertEquals(2, rels.length);
  }

  public void testMatchOneOfTwoPropertyBridges() {
    NodeRelation nodeRel = translate1(
        "ex:res1 rdf:type ex:Class1",
        "engine/simple.n3");
    Relation r = nodeRel.baseRelation();
    assertEquals(Collections.EMPTY_SET, r.projections());
    assertEquals(Equality.createAttributeValue(table1id, "1"), r.condition());
  }
View Full Code Here

  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
       
    NodeRelation label = search("table1", "label", rels);
    NodeRelation label_en = search("table1", "label_en", rels);
   
    pattern.clear();
    pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
    rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation intvalue = search("table2", "intvalue", rels);
   
    Expr subject = new E_IsBlank(new ExprVar("s"));
    Expr object  = new E_IsBlank(new ExprVar("o"));
   
    assertEquals("ISBLANK(literal) should be FALSE",      Expression.FALSE, TransformExprToSQLApplyer.convert(object, label));
View Full Code Here

  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation intvalue = search("table2", "intvalue", rels);
    NodeRelation value = search("table2", "value", rels);
   
    pattern.clear();
    pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
    rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation langliteral = search("table1", "label_en", rels);
   
    Expr filterint    = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDint.getURI())));
    Expr filterstring = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDstring.getURI())));
   
    assertEquals("DATATYPE(intliteral) = xsd:int should be TRUE",       Expression.TRUE, TransformExprToSQLApplyer.convert(filterint, intvalue));
View Full Code Here

        "ex:res1 rdf:type ex:Class1 . ex:res1 rdf:type ex:Class2",
        "engine/simple.n3"));
  }
 
  public void testAskTwoTriplePatternsMatch() {
    NodeRelation nodeRel = translate1(
        "ex:res1 rdf:type ex:Class1 . ex:res1 ex:foo ?foo",
        "engine/simple.n3");
    assertEquals(Collections.singleton(foo), nodeRel.variables());
    assertEquals("Literal(Column(T2_table1.foo))", nodeRel.nodeMaker(foo).toString());
    Relation r = nodeRel.baseRelation();
    assertEquals("Conjunction(" +
        "Equality(" +
            "AttributeExpr(@@T1_table1.id@@), " +
            "Constant(1@T1_table1.id)), " +
        "Equality(" +
View Full Code Here

  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation intvalue = search("table2", "intvalue", rels);
 
    Expr disjunction = new E_LogicalOr(new E_Equals(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDint)), new E_Equals(new ExprVar("o"), NodeValue.makeNode("2", XSDDatatype.XSDint)));
   
    Expression result = TransformExprToSQLApplyer.convert(disjunction, intvalue);
    TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
    Expression e1 = nm.valueMaker().valueExpression("1");
    Expression e2 = nm.valueMaker().valueExpression("2");
    Expression expected = e1.or(e2);
   
    assertEquals("?o = \"1\"^^xsd:int || ?o = \"2\"^^xsd:int", expected, result);
View Full Code Here

  {
    List<Triple> pattern = new ArrayList<Triple>();
    pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
    NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
   
    NodeRelation intvalue = search("table2", "intvalue", rels);
 
    Expr sameTerm = new E_SameTerm(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDint));
   
    Expression result = TransformExprToSQLApplyer.convert(sameTerm, intvalue);
    TypedNodeMaker nm = (TypedNodeMaker) intvalue.nodeMaker(Var.alloc("o"));
    Expression expected = nm.valueMaker().valueExpression("1");
   
    assertEquals("sameTerm(?o, \"1\"^^xsd:int)", expected, result);
   
    sameTerm = new E_SameTerm(new ExprVar("o"),  NodeValue.makeNode("1", XSDDatatype.XSDdecimal));
View Full Code Here

TOP

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

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.