本文整理汇总了Java中org.eclipse.rdf4j.query.algebra.And类的典型用法代码示例。如果您正苦于以下问题:Java And类的具体用法?Java And怎么用?Java And使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
And类属于org.eclipse.rdf4j.query.algebra包,在下文中一共展示了And类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFilter
import org.eclipse.rdf4j.query.algebra.And; //导入依赖的package包/类
public static ValueExpr toFilter(ConjunctiveFilterExpr filterExpr) throws FilterConversionException {
List<FilterExpr> expressions = filterExpr.getExpressions();
if (expressions.size()==2) {
return new And(expressions.get(0).getExpression(), expressions.get(0).getExpression());
}
And and = new And();
and.setLeftArg( expressions.get(0).getExpression() );
And tmp = and;
int idx;
for (idx=1; idx<expressions.size()-1; idx++) {
And _a = new And();
_a.setLeftArg( expressions.get(idx).getExpression() );
tmp.setRightArg(_a);
tmp = _a;
}
tmp.setRightArg( expressions.get(idx).getExpression());
return and;
}
示例2: getConjunctiveExpressions
import org.eclipse.rdf4j.query.algebra.And; //导入依赖的package包/类
/**
* add the conjunctive expressions to specified list, has recursive step.
*
* @param expr
* the expr, in the best case in CNF
* @param conjExpr
* the list to which expressions will be added
*/
protected void getConjunctiveExpressions(ValueExpr expr, List<ValueExpr> conjExpr) {
if (expr instanceof And) {
And and = (And)expr;
getConjunctiveExpressions(and.getLeftArg(), conjExpr);
getConjunctiveExpressions(and.getRightArg(), conjExpr);
} else
conjExpr.add(expr);
}
示例3: isCompatibleExpr
import org.eclipse.rdf4j.query.algebra.And; //导入依赖的package包/类
/**
* returns true if this filter can be used for optimization. Currently no
* conjunctive or disjunctive expressions are supported.
*
* @param e
* @return
*/
protected boolean isCompatibleExpr(ValueExpr e) {
if (e instanceof And || e instanceof Or) {
return false;
}
if (e instanceof Not) {
return isCompatibleExpr( ((Not)e).getArg() );
}
return true;
}
示例4: meet
import org.eclipse.rdf4j.query.algebra.And; //导入依赖的package包/类
/**
* @inheritDoc
*/
@Override
public void meet(And theAnd)
throws Exception
{
binaryMeet("&&", theAnd);
}
示例5: meet
import org.eclipse.rdf4j.query.algebra.And; //导入依赖的package包/类
@Override
public void meet(Filter filter) {
if (filter.getArg() instanceof EmptyResult) {
log.debug("Argument of filter expression does not yield results at the provided sources, replacing Filter node.");
filter.replaceWith(filter.getArg());
return;
}
/*
* TODO idea:
* if we have a FILTER such as ?s='a' OR ?s='b' OR ?s='c' handle this appropriately
*/
ValueExpr valueExpr = filter.getCondition();
/*
* TODO transform condition into some normal form, e.g. CNF
*/
// determine conjunctive expressions
List<ValueExpr> conjunctiveExpressions = new ArrayList<ValueExpr>();
getConjunctiveExpressions(valueExpr, conjunctiveExpressions);
FilterExprInsertVisitor filterExprVst = new FilterExprInsertVisitor();
List<ValueExpr> remainingExpr = new ArrayList<ValueExpr>(conjunctiveExpressions.size());
for (ValueExpr cond : conjunctiveExpressions) {
/*
* Determine if this filter is applicable for optimization.
* Currently only leaf expressions are applicable, i.e.
* not combined expressions.
*/
if (isCompatibleExpr(cond)) {
HashSet<String> exprVars = new VarFinder().findVars(cond);
FilterExpr filterExpr = new FilterExpr(cond, exprVars);
filterExprVst.initialize(filterExpr);
filter.getArg().visit(filterExprVst);
// if the filter expr. is handled in the stmt we do not have to keep it
if (filterExprVst.canRemove())
continue;
remainingExpr.add(filterExpr.getExpression());
} else {
remainingExpr.add(cond);
}
}
if (remainingExpr.size()==0) {
filter.replaceWith(filter.getArg()); // remove the filter
}
else if (remainingExpr.size()==1) {
filter.setCondition(remainingExpr.get(0)); // just apply the remaining condition
}
else {
// construct conjunctive value expr
And root = new And();
root.setLeftArg(remainingExpr.get(0));
And tmp = root;
for (int i=1; i<remainingExpr.size()-1; i++) {
And _a = new And();
_a.setLeftArg(remainingExpr.get(i));
tmp.setRightArg(_a);
tmp = _a;
}
tmp.setRightArg(remainingExpr.get(remainingExpr.size()-1));
filter.setCondition(root);
}
}
示例6: evaluate
import org.eclipse.rdf4j.query.algebra.And; //导入依赖的package包/类
/**
* Determines which evaluate method to call based on the type of {@link ValueExpr}
* @param expr the expression to evaluate
* @param bindings the set of named value bindings the set of named value bindings
* @return the {@link Value} resulting from the evaluation
* @throws ValueExprEvaluationException
* @throws QueryEvaluationException
*/
Value evaluate(ValueExpr expr, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
if (expr instanceof Var) {
return evaluate((Var) expr, bindings);
} else if (expr instanceof ValueConstant) {
return evaluate((ValueConstant) expr, bindings);
} else if (expr instanceof BNodeGenerator) {
return evaluate((BNodeGenerator) expr, bindings);
} else if (expr instanceof Bound) {
return evaluate((Bound) expr, bindings);
} else if (expr instanceof Str) {
return evaluate((Str) expr, bindings);
} else if (expr instanceof Label) {
return evaluate((Label) expr, bindings);
} else if (expr instanceof Lang) {
return evaluate((Lang) expr, bindings);
} else if (expr instanceof LangMatches) {
return evaluate((LangMatches) expr, bindings);
} else if (expr instanceof Datatype) {
return evaluate((Datatype) expr, bindings);
} else if (expr instanceof Namespace) {
return evaluate((Namespace) expr, bindings);
} else if (expr instanceof LocalName) {
return evaluate((LocalName) expr, bindings);
} else if (expr instanceof IsResource) {
return evaluate((IsResource) expr, bindings);
} else if (expr instanceof IsURI) {
return evaluate((IsURI) expr, bindings);
} else if (expr instanceof IsBNode) {
return evaluate((IsBNode) expr, bindings);
} else if (expr instanceof IsLiteral) {
return evaluate((IsLiteral) expr, bindings);
} else if (expr instanceof IsNumeric) {
return evaluate((IsNumeric) expr, bindings);
} else if (expr instanceof IRIFunction) {
return evaluate((IRIFunction) expr, bindings);
} else if (expr instanceof Regex) {
return evaluate((Regex) expr, bindings);
} else if (expr instanceof Coalesce) {
return evaluate((Coalesce) expr, bindings);
} else if (expr instanceof Like) {
return evaluate((Like) expr, bindings);
} else if (expr instanceof FunctionCall) {
return evaluate((FunctionCall) expr, bindings);
} else if (expr instanceof And) {
return evaluate((And) expr, bindings);
} else if (expr instanceof Or) {
return evaluate((Or) expr, bindings);
} else if (expr instanceof Not) {
return evaluate((Not) expr, bindings);
} else if (expr instanceof SameTerm) {
return evaluate((SameTerm) expr, bindings);
} else if (expr instanceof Compare) {
return evaluate((Compare) expr, bindings);
} else if (expr instanceof MathExpr) {
return evaluate((MathExpr) expr, bindings);
} else if (expr instanceof In) {
return evaluate((In) expr, bindings);
} else if (expr instanceof CompareAny) {
return evaluate((CompareAny) expr, bindings);
} else if (expr instanceof CompareAll) {
return evaluate((CompareAll) expr, bindings);
} else if (expr instanceof Exists) {
return evaluate((Exists) expr, bindings);
} else if (expr instanceof If) {
return evaluate((If) expr, bindings);
} else if (expr instanceof ListMemberOperator) {
return evaluate((ListMemberOperator) expr, bindings);
} else if (expr == null) {
throw new IllegalArgumentException("expr must not be null");
} else {
throw new QueryEvaluationException("Unsupported value expr type: " + expr.getClass());
}
}