本文整理汇总了Java中org.eclipse.rdf4j.query.algebra.ValueExpr类的典型用法代码示例。如果您正苦于以下问题:Java ValueExpr类的具体用法?Java ValueExpr怎么用?Java ValueExpr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueExpr类属于org.eclipse.rdf4j.query.algebra包,在下文中一共展示了ValueExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toFilter
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的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: evaluate
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
/**
* Evaluates a function.
*/
private Value evaluate(FunctionCall node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
Optional<Function> function = FunctionRegistry.getInstance().get(node.getURI());
if (!function.isPresent()) {
throw new QueryEvaluationException("Unknown function '" + node.getURI() + "'");
}
// the NOW function is a special case as it needs to keep a shared return
// value for the duration of the query.
if (function.get() instanceof Now) {
return evaluate((Now) function.get(), bindings);
}
List<ValueExpr> args = node.getArgs();
Value[] argValues = new Value[args.size()];
for (int i = 0; i < args.size(); i++) {
argValues[i] = evaluate(args.get(i), bindings);
}
return function.get().evaluate(valueFactory, argValues);
}
示例3: meet
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
/**
* @inheritDoc
*/
@Override
public void meet(FunctionCall theOp)
throws Exception
{
mBuffer.append("<").append(theOp.getURI()).append(">(");
boolean aFirst = true;
for (ValueExpr aArg : theOp.getArgs()) {
if (!aFirst) {
mBuffer.append(", ");
}
else {
aFirst = false;
}
aArg.visit(this);
}
mBuffer.append(")");
}
示例4: evaluate
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
public Value evaluate(ValueExpr expr, BindingSet bindings) {
if (expr instanceof FilterExpr)
return evaluate((FilterExpr)expr, bindings);
if (expr instanceof ConjunctiveFilterExpr)
return evaluate((ConjunctiveFilterExpr)expr, bindings);
return super.evaluate(expr, bindings);
}
示例5: append
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
protected static void append(ValueExpr expr, StringBuilder sb) throws FilterConversionException {
if (expr instanceof Compare) {
append((Compare)expr, sb);
} else if (expr instanceof Var) {
append((Var)expr, sb);
} else if (expr instanceof ValueConstant) {
append((ValueConstant)expr, sb);
} else {
// TODO add more!
throw new FilterConversionException("Expression type not supported, fallback to sesame evaluation: " + expr.getClass().getCanonicalName());
}
}
示例6: getConjunctiveExpressions
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的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);
}
示例7: isCompatibleExpr
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的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;
}
示例8: isTrue
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
/**
* Determines the "effective boolean value" of the {@link Value} returned by evaluating the expression.
* See {@link QueryEvaluationUtil#getEffectiveBooleanValue(Value)} for the definition of "effective boolean value.
* @param expr
* @param bindings the set of named value bindings
* @return
* @throws QueryEvaluationException
*/
boolean isTrue(ValueExpr expr, BindingSet bindings) throws QueryEvaluationException {
try {
Value value = evaluate(expr, bindings);
return QueryEvaluationUtil.getEffectiveBooleanValue(value);
} catch (ValueExprEvaluationException e) {
return false;
}
}
示例9: acceptsFilter
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
@Override
public boolean acceptsFilter(Plan p1, ValueExpr cond) {
if (cond instanceof FunctionCall) {
return acceptsFunction((FunctionCall)cond);
}
else
return true;
}
示例10: replaceWith
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
public void replaceWith(Quantifier.Var v1, ValueExpr e) {
theta.visit(new AbstractQueryModelVisitor<RuntimeException>() {
@Override
public void meetNode(QueryModelNode node) throws RuntimeException {
if (node instanceof Quantifier.Var) {
Quantifier.Var v = (Quantifier.Var)node;
if (v.equals(v1))
node.replaceWith(e);
}
super.meetNode(node);
}
});
}
示例11: FilterExpr
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
public FilterExpr(ValueExpr expr, HashSet<String> vars) {
super();
this.expr = expr;
this.vars = vars;
}
示例12: getExpression
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
public ValueExpr getExpression() {
return expr;
}
示例13: meet
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的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);
}
}
示例14: findVars
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
public HashSet<String> findVars(ValueExpr expr) {
vars = new HashSet<String>();
expr.visit(this);
return vars;
}
示例15: evaluate
import org.eclipse.rdf4j.query.algebra.ValueExpr; //导入依赖的package包/类
/**
* Called by RDF4J to evaluate a value expression
*/
@Override
public Value evaluate(ValueExpr expr, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
return valueEval.evaluate(expr, bindings);
}