Search in sources :

Example 1 with RangeValue

use of org.apache.rya.api.domain.RangeValue in project incubator-rya by apache.

the class FilterRangeVisitor method meet.

@Override
public void meet(final Filter node) throws Exception {
    super.meet(node);
    final ValueExpr arg = node.getCondition();
    if (arg instanceof FunctionCall) {
        final FunctionCall fc = (FunctionCall) arg;
        if (RANGE.stringValue().equals(fc.getURI())) {
            // range(?var, start, end)
            final List<ValueExpr> valueExprs = fc.getArgs();
            if (valueExprs.size() != 3) {
                throw new QueryEvaluationException("org.apache:range must have 3 parameters: variable, start, end");
            }
            final Var var = (Var) valueExprs.get(0);
            final ValueConstant startVc = (ValueConstant) valueExprs.get(1);
            final ValueConstant endVc = (ValueConstant) valueExprs.get(2);
            final Value start = startVc.getValue();
            final Value end = endVc.getValue();
            rangeValues.put(var, new RangeValue(start, end));
            node.setCondition(new ValueConstant(BooleanLiteralImpl.TRUE));
        }
    }
}
Also used : ValueExpr(org.openrdf.query.algebra.ValueExpr) QueryEvaluationException(org.openrdf.query.QueryEvaluationException) Var(org.openrdf.query.algebra.Var) ValueConstant(org.openrdf.query.algebra.ValueConstant) Value(org.openrdf.model.Value) RangeValue(org.apache.rya.api.domain.RangeValue) FunctionCall(org.openrdf.query.algebra.FunctionCall) RangeValue(org.apache.rya.api.domain.RangeValue)

Example 2 with RangeValue

use of org.apache.rya.api.domain.RangeValue in project incubator-rya by apache.

the class FilterRangeVisitor method meet.

@Override
public void meet(final StatementPattern node) throws Exception {
    super.meet(node);
    final Var subjectVar = node.getSubjectVar();
    final RangeValue subjRange = rangeValues.get(subjectVar);
    final Var predVar = node.getPredicateVar();
    final RangeValue predRange = rangeValues.get(predVar);
    final Var objVar = node.getObjectVar();
    final RangeValue objRange = rangeValues.get(objVar);
    if (subjRange != null) {
        // Assumes no blank nodes can be ranges
        subjectVar.setValue(new RangeURI(subjRange));
    }
    if (predRange != null) {
        predVar.setValue(new RangeURI(predRange));
    }
    if (objRange != null) {
        objVar.setValue(objRange);
    }
}
Also used : RangeURI(org.apache.rya.api.domain.RangeURI) Var(org.openrdf.query.algebra.Var) RangeValue(org.apache.rya.api.domain.RangeValue)

Aggregations

RangeValue (org.apache.rya.api.domain.RangeValue)2 Var (org.openrdf.query.algebra.Var)2 RangeURI (org.apache.rya.api.domain.RangeURI)1 Value (org.openrdf.model.Value)1 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)1 FunctionCall (org.openrdf.query.algebra.FunctionCall)1 ValueConstant (org.openrdf.query.algebra.ValueConstant)1 ValueExpr (org.openrdf.query.algebra.ValueExpr)1