当前位置: 首页>>代码示例>>Java>>正文


Java TransformExprToSQLApplyer类代码示例

本文整理汇总了Java中de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer的典型用法代码示例。如果您正苦于以下问题:Java TransformExprToSQLApplyer类的具体用法?Java TransformExprToSQLApplyer怎么用?Java TransformExprToSQLApplyer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransformExprToSQLApplyer类属于de.fuberlin.wiwiss.d2rq.optimizer.expr包,在下文中一共展示了TransformExprToSQLApplyer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLang

import de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer; //导入依赖的package包/类
public void testLang()
{
	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_noLang = search("table1", "label", rels);
	
	Expr filterFR    = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr"));
	Expr filterEN_TAG_EN = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeNode("en", "en", (String) null));
	Expr filterFR_BE = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr-BE"));
	Expr filter      = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString(""));
	
	assertEquals("LANG(label_fr_be) = \"fr\" should be FALSE",   Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_fr_be));
	assertEquals("LANG(label_en) = \"fr\" should be FALSE",      Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_en));
	assertEquals("LANG(label_fr_be) = \"fr_be\" should be TRUE", Expression.TRUE,  TransformExprToSQLApplyer.convert(filterFR_BE, label_fr_be));
	assertEquals("LANG(label_en) = \"en\"@en should be FALSE",   Expression.FALSE, TransformExprToSQLApplyer.convert(filterEN_TAG_EN, label_en));
	assertEquals("LANG(label_noLang) = \"\" should be TRUE",     Expression.TRUE,  TransformExprToSQLApplyer.convert(filter, label_noLang));
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:22,代码来源:ExprTransformTest2.java

示例2: testDataType

import de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer; //导入依赖的package包/类
public void testDataType()
{
	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));
	assertEquals("DATATYPE(simpleliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, value));
	assertEquals("DATATYPE(langliteral) = xsd:string should be TRUE",   Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, langliteral));
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:23,代码来源:ExprTransformTest2.java

示例3: testDisjunction

import de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer; //导入依赖的package包/类
public void testDisjunction()
{
	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);
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:19,代码来源:ExprTransformTest2.java

示例4: applyFilter

import de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer; //导入依赖的package包/类
private List<NodeRelation> applyFilter(
		List<NodeRelation> nodeRelations, Expr filter, ExprList allFilters) {
    List<NodeRelation> result = new ArrayList<NodeRelation>();
    boolean convertable = true;
    for (NodeRelation nodeRelation: nodeRelations) {
    	// TODO: The transformation from Expr to Expression should happen in NodeRelation.select()
        Expression expression = TransformExprToSQLApplyer.convert(filter, nodeRelation);
        if (expression == null) {
        	// the expression cannot be transformed to SQL
            convertable = false;
        } else if (expression.isTrue()) {
        	// keep as is
        } else if (expression.isFalse()) {
            continue;	// skip
        } else {
        	nodeRelation = nodeRelation.select(expression);
        	if (nodeRelation.baseRelation().condition().isFalse()) continue;
        }
        result.add(nodeRelation);
    }
    if (convertable) {
    	log.debug("Removing converted filter: " + filter);
        allFilters.getList().remove(filter);
    } else {
    	log.debug("Filter could not be fully converted and is kept: " + filter);
    }
    return result;
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:29,代码来源:TransformOpBGP.java

示例5: testSameTerm

import de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer; //导入依赖的package包/类
public void testSameTerm()
{
	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));
	
	result = TransformExprToSQLApplyer.convert(sameTerm, intvalue);
	
	assertEquals("sameTerm(?o, \"1\"^^xsd:decimal)", Expression.FALSE, result);
}
 
开发者ID:aitoralmeida,项目名称:c4a_data_repository,代码行数:23,代码来源:ExprTransformTest2.java


注:本文中的de.fuberlin.wiwiss.d2rq.optimizer.expr.TransformExprToSQLApplyer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。