本文整理汇总了Java中de.fuberlin.wiwiss.d2rq.expr.Expression类的典型用法代码示例。如果您正苦于以下问题:Java Expression类的具体用法?Java Expression怎么用?Java Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于de.fuberlin.wiwiss.d2rq.expr包,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectNode
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
public NodeMaker selectNode(Node node, RelationalOperators sideEffects) {
if (node.equals(Node.ANY) || node.isVariable()) {
return this;
}
if (!this.nodeType.matches(node)) {
return NodeMaker.EMPTY;
}
String value = this.nodeType.extractValue(node);
if (value == null) {
return NodeMaker.EMPTY;
}
Expression expr = valueMaker.valueExpression(value);
if (expr.isFalse()) {
sideEffects.select(Expression.FALSE);
return NodeMaker.EMPTY;
}
sideEffects.select(expr);
return new FixedNodeMaker(node, isUnique());
}
示例2: matchPatterns
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
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
if (p1.usesColumnFunctions() || p2.usesColumnFunctions()) {
log.warn("Joining multiple d2rq:[uri]Patterns with different @@|[email protected]@ is not supported");
unsupported = true;
}
}
return results;
}
示例3: valueExpression
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
public Expression valueExpression(String value) {
if (value == null) {
return Expression.FALSE;
}
Matcher match = this.regex.matcher(value);
if (!match.matches()) {
return Expression.FALSE;
}
Collection<Expression> expressions = new ArrayList<Expression>(columns.size());
for (int i = 0; i < this.columns.size(); i++) {
Attribute attribute = columns.get(i);
ColumnFunction function = columnFunctions.get(i);
String attributeValue = function.decode(match.group(i + 1));
if (attributeValue == null) {
return Expression.FALSE;
}
expressions.add(Equality.createAttributeValue(attribute, attributeValue));
}
return Conjunction.create(expressions);
}
示例4: valueExpression
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
public Expression valueExpression(String value) {
if (value == null) {
return Expression.FALSE;
}
String[] parts = value.split(DELIMITER);
// Check if given bNode was created by this class map
if (parts.length != this.attributes.size() + 1
|| !this.classMapID.equals(parts[0])) {
return Expression.FALSE;
}
int i = 1; // parts[0] is classMap identifier
Collection<Expression> expressions = new ArrayList<Expression>(attributes.size());
for (Attribute attribute: attributes) {
expressions.add(Equality.createAttributeValue(attribute, parts[i]));
i++;
}
return Conjunction.create(expressions);
}
示例5: visit
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
public void visit(ExprVar var)
{
logger.debug("visit ExprVar " + var);
if (!convertable) {
expression.push(Expression.FALSE); // prevent stack empty exceptions when conversion
return; // fails in the middle of a multi-arg operator conversion
}
String varName = var.getVarName();
// if expression contains a blank node, no conversion to sql can be done
if (Var.isBlankNodeVarName(varName)) {
conversionFailed("blank nodes not supported", var);
return;
}
List<Expression> expressions = toExpression(var);
if (expressions.size() == 1) {
expression.push(expressions.get(0));
} else {
// no single sql-column for sparql-var does exist break up conversion
// (the case for Pattern ValueMakers)
conversionFailed("multi column pattern valuemakers not supported", var);
}
}
示例6: visitExprFunction
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
private void visitExprFunction(ExprFunction function)
{
logger.debug("visit ExprFunction " + function);
if (!convertable) {
expression.push(Expression.FALSE); // prevent stack empty exceptions when conversion
return; // fails in the middle of a multi-arg operator conversion
}
if (!extensionSupports(function)) {
conversionFailed(function);
return;
}
for (int i = 0; i < function.numArgs(); i++)
function.getArg(i + 1).visit(this);
List<Expression> args = new ArrayList<Expression>(function.numArgs());
for (int i = 0; i < function.numArgs(); i++)
args.add(expression.pop());
Collections.reverse(args);
extensionConvert(function, args);
}
示例7: convertIsIRI
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
private void convertIsIRI(E_IsIRI expr)
{
logger.debug("convertIsIRI " + expr.toString());
expr.getArg().visit(this);
Expression arg = expression.pop();
if (arg instanceof AttributeExprEx) {
AttributeExprEx variable = (AttributeExprEx) arg;
NodeMaker nm = variable.getNodeMaker();
DetermineNodeType filter = new DetermineNodeType();
nm.describeSelf(filter);
expression.push(filter.isLimittedToURIs() ? Expression.TRUE : Expression.FALSE);
} else if (arg instanceof ConstantEx) {
ConstantEx constant = (ConstantEx) arg;
Node node = constant.getNode();
expression.push(node.isURI() ? Expression.TRUE : Expression.FALSE);
} else {
conversionFailed(expr);
}
}
示例8: convertIsBlank
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
private void convertIsBlank(E_IsBlank expr)
{
logger.debug("convertIsBlank " + expr.toString());
expr.getArg().visit(this);
Expression arg = expression.pop();
if (arg instanceof AttributeExprEx) {
AttributeExprEx variable = (AttributeExprEx) arg;
NodeMaker nm = variable.getNodeMaker();
DetermineNodeType filter = new DetermineNodeType();
nm.describeSelf(filter);
expression.push(filter.isLimittedToBlankNodes() ? Expression.TRUE : Expression.FALSE);
} else if (arg instanceof ConstantEx) {
ConstantEx constant = (ConstantEx) arg;
Node node = constant.getNode();
expression.push(node.isBlank() ? Expression.TRUE : Expression.FALSE);
} else {
conversionFailed(expr);
}
}
示例9: testDataType
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的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));
}
示例10: convertLangMatches
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
private void convertLangMatches(E_LangMatches expr)
{
logger.debug("convertLangMatches " + expr.toString());
expr.getArg1().visit(this);
expr.getArg2().visit(this);
Expression e2 = expression.pop();
Expression e1 = expression.pop();
if (e1 instanceof ConstantEx && e2 instanceof ConstantEx) {
ConstantEx lang1 = (ConstantEx) e1;
ConstantEx lang2 = (ConstantEx) e2;
NodeValue nv1 = NodeValue.makeString(lang1.getNode().getLiteral().getLexicalForm());
NodeValue nv2 = NodeValue.makeString(lang2.getNode().getLiteral().getLexicalForm());
NodeValue match = NodeFunctions.langMatches(nv1, nv2);
expression.push(match.equals(NodeValue.TRUE) ? Expression.TRUE : Expression.FALSE);
} else {
expression.push(Expression.FALSE);
}
}
示例11: testLang
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的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));
}
示例12: joinedBaseRelation
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
private Relation joinedBaseRelation() {
List<Relation> relations = new ArrayList<Relation>();
for (NodeRelation tripleRelation: joinedTripleRelations) {
relations.add(tripleRelation.baseRelation());
}
return joinRelations(relations, Expression.TRUE);
}
示例13: joinRelations
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
/**
* Static convenience function that joins several {@link Relation}s into one. Exposed here
* because it can be used in the old FastPath engine.
*
* @param relations A set of {@link Relation}s
* @param additionalCondition An additional expression, e.g. join condition
* @return A relation that is the join of the inputs
*/
private Relation joinRelations(Collection<Relation> relations, Expression additionalCondition) {
if (relations.isEmpty()) {
return Relation.TRUE;
}
ConnectedDB connectedDB = ((Relation) relations.iterator().next()).database();
AliasMap joinedAliases = AliasMap.NO_ALIASES;
Collection<Expression> expressions = new HashSet<Expression>();
expressions.add(additionalCondition);
Collection<Expression> softConditions = new HashSet<Expression>();
Set<Join> joins = new HashSet<Join>();
Set<ProjectionSpec> projections = new HashSet<ProjectionSpec>();
int limit = Relation.NO_LIMIT;
int limitInverse = Relation.NO_LIMIT;
List<OrderSpec> orderSpecs = null;
for (Relation relation: relations) {
joinedAliases = joinedAliases.applyTo(relation.aliases());
expressions.add(relation.condition());
softConditions.add(relation.softCondition());
joins.addAll(relation.joinConditions());
projections.addAll(relation.projections());
orderSpecs = orderSpecs == null ? relation.orderSpecs() : orderSpecs;
limit = Relation.combineLimits(limit, relation.limit());
limitInverse = Relation.combineLimits(limitInverse, relation.limitInverse());
}
// TODO: Determine correct uniqueness instead of just false.
// The new relation is unique if it is joined only on unique node sets.
// A node set is unique if it is constrained by only unique node makers.
// In the meantime, copy the uniqueness from the relation if there's just one
boolean isUnique = relations.size() == 1 && (relations.iterator().next()).isUnique();
return new RelationImpl(connectedDB, joinedAliases, Conjunction.create(expressions),
Conjunction.create(softConditions),
joins, projections, isUnique, orderSpecs, limit, limitInverse);
}
示例14: applyFilter
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的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;
}
示例15: createSimpleRelation
import de.fuberlin.wiwiss.d2rq.expr.Expression; //导入依赖的package包/类
public static Relation createSimpleRelation(
ConnectedDB database, Attribute[] attributes) {
return new RelationImpl(database, AliasMap.NO_ALIASES, Expression.TRUE, Expression.TRUE,
Collections.<Join>emptySet(),
new HashSet<ProjectionSpec>(Arrays.asList(attributes)),
false, Collections.<OrderSpec>emptyList(), -1, -1);
}