|
19 | 19 | import java.util.concurrent.TimeUnit; |
20 | 20 | import java.util.function.BiFunction; |
21 | 21 | import java.util.function.Consumer; |
| 22 | +import java.util.function.Predicate; |
22 | 23 | import java.util.function.Supplier; |
23 | 24 |
|
24 | 25 | import org.eclipse.rdf4j.collection.factory.api.CollectionFactory; |
@@ -633,24 +634,8 @@ protected QueryEvaluationStep prepare(Service service, QueryEvaluationContext co |
633 | 634 |
|
634 | 635 | protected QueryEvaluationStep prepare(Filter node, QueryEvaluationContext context) throws QueryEvaluationException { |
635 | 636 |
|
636 | | - QueryEvaluationStep arg = precompile(node.getArg(), context); |
637 | | - QueryValueEvaluationStep ves; |
638 | | - try { |
639 | | - final FilterIterator.RetainedVariableFilteredQueryEvaluationContext context2 = new FilterIterator.RetainedVariableFilteredQueryEvaluationContext( |
640 | | - node, context); |
641 | | - ves = precompile(node.getCondition(), context2); |
642 | | - } catch (QueryEvaluationException e) { |
643 | | - // If we have a failed compilation we always return false. |
644 | | - // Which means empty. so let's short circuit that. |
645 | | - return QueryEvaluationStep.EMPTY; |
646 | | - } |
647 | | - return new QueryEvaluationStep() { |
| 637 | + return FilterIterator.supply(node, DefaultEvaluationStrategy.this, context); |
648 | 638 |
|
649 | | - @Override |
650 | | - public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BindingSet bs) { |
651 | | - return new FilterIterator(node, arg.evaluate(bs), ves, DefaultEvaluationStrategy.this); |
652 | | - } |
653 | | - }; |
654 | 639 | } |
655 | 640 |
|
656 | 641 | protected QueryEvaluationStep prepare(Order node, QueryEvaluationContext context) throws QueryEvaluationException { |
@@ -1157,16 +1142,18 @@ protected QueryValueEvaluationStep prepare(Var var, QueryEvaluationContext conte |
1157 | 1142 | return new ConstantQueryValueEvaluationStep(value); |
1158 | 1143 | } else { |
1159 | 1144 | java.util.function.Function<BindingSet, Value> getValue = context.getValue(var.getName()); |
| 1145 | + Predicate<BindingSet> hasValue = context.hasBinding(var.getName()); |
1160 | 1146 | return new QueryValueEvaluationStep() { |
1161 | 1147 |
|
1162 | 1148 | @Override |
1163 | 1149 | public Value evaluate(BindingSet bindings) |
1164 | 1150 | throws QueryEvaluationException { |
1165 | | - Value value = getValue.apply(bindings); |
1166 | | - if (value == null) { |
| 1151 | + if (hasValue.test(bindings)) { |
| 1152 | + Value value = getValue.apply(bindings); |
| 1153 | + return value; |
| 1154 | + } else { |
1167 | 1155 | throw new ValueExprEvaluationException(); |
1168 | 1156 | } |
1169 | | - return value; |
1170 | 1157 | } |
1171 | 1158 | }; |
1172 | 1159 | } |
|
0 commit comments