@Test public void testBindings() throws Exception { String query = "SELECT ?a ?b WHERE {}"; ParsedQuery pq = QueryParserUtil.parseQuery(QueryLanguage.SPARQL, query, null); final ValueFactory vf = SimpleValueFactory.getInstance(); QueryBindingSet constants = new QueryBindingSet(); constants.addBinding("a", vf.createLiteral("foo")); constants.addBinding("b", vf.createLiteral("bar")); constants.addBinding("x", vf.createLiteral("X")); constants.addBinding("y", vf.createLiteral("Y")); CloseableIteration<BindingSet, QueryEvaluationException> result = strategy.evaluate(pq.getTupleExpr(), constants); assertNotNull(result); assertTrue(result.hasNext()); BindingSet bs = result.next(); assertTrue(bs.hasBinding("a")); assertTrue(bs.hasBinding("b")); assertFalse(bs.hasBinding("x")); assertFalse(bs.hasBinding("y")); }
@Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException { if (expr instanceof StatementPattern) { return evaluate((StatementPattern) expr, bindings); } else if (expr instanceof UnaryTupleOperator) { return evaluate((UnaryTupleOperator) expr, bindings); } else if (expr instanceof BinaryTupleOperator) { return evaluate((BinaryTupleOperator) expr, bindings); } else if (expr instanceof SingletonSet) { return evaluate((SingletonSet) expr, bindings); } else if (expr instanceof EmptySet) { return evaluate((EmptySet) expr, bindings); } else if (expr instanceof ExternalSet) { return evaluate((ExternalSet) expr, bindings); } else if (expr instanceof ZeroLengthPath) { return evaluate((ZeroLengthPath) expr, bindings); } else if (expr instanceof ArbitraryLengthPath) { return evaluate((ArbitraryLengthPath) expr, bindings); } else if (expr instanceof BindingSetAssignment) { return evaluate((BindingSetAssignment) expr, bindings); } else if (expr == null) { throw new IllegalArgumentException("expr must not be null"); } else { throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()); } }
StrictEvaluationStrategy implements EvaluationStrategy, FederatedServiceResolverClient, UUIDable { @Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException { if (expr instanceof StatementPattern) { return evaluate((StatementPattern) expr, bindings); } else if (expr instanceof UnaryTupleOperator) { return evaluate((UnaryTupleOperator) expr, bindings); } else if (expr instanceof BinaryTupleOperator) { return evaluate((BinaryTupleOperator) expr, bindings); } else if (expr instanceof SingletonSet) { return evaluate((SingletonSet) expr, bindings); } else if (expr instanceof EmptySet) { return evaluate((EmptySet) expr, bindings); } else if (expr instanceof ExternalSet) { return evaluate((ExternalSet) expr, bindings); } else if (expr instanceof ZeroLengthPath) { return evaluate((ZeroLengthPath) expr, bindings); } else if (expr instanceof ArbitraryLengthPath) { return evaluate((ArbitraryLengthPath) expr, bindings); } else if (expr instanceof BindingSetAssignment) { return evaluate((BindingSetAssignment) expr, bindings); } else if (expr == null) { throw new IllegalArgumentException("expr must not be null"); } else { throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()); } } }
StrictEvaluationStrategy implements EvaluationStrategy, FederatedServiceResolverClient, UUIDable { @Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException { if (expr instanceof StatementPattern) { return evaluate((StatementPattern) expr, bindings); } else if (expr instanceof UnaryTupleOperator) { return evaluate((UnaryTupleOperator) expr, bindings); } else if (expr instanceof BinaryTupleOperator) { return evaluate((BinaryTupleOperator) expr, bindings); } else if (expr instanceof SingletonSet) { return evaluate((SingletonSet) expr, bindings); } else if (expr instanceof EmptySet) { return evaluate((EmptySet) expr, bindings); } else if (expr instanceof ExternalSet) { return evaluate((ExternalSet) expr, bindings); } else if (expr instanceof ZeroLengthPath) { return evaluate((ZeroLengthPath) expr, bindings); } else if (expr instanceof ArbitraryLengthPath) { return evaluate((ArbitraryLengthPath) expr, bindings); } else if (expr instanceof BindingSetAssignment) { return evaluate((BindingSetAssignment) expr, bindings); } else if (expr == null) { throw new IllegalArgumentException("expr must not be null"); } else { throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()); } } StrictEvaluationStrategy(TripleSource tripleSource, FederatedServiceResolver serviceResolver);  StrictEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
			FederatedServiceResolver serviceResolver);  StrictEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
			FederatedServiceResolver serviceResolver, long iterationCacheSyncTreshold,
			EvaluationStatistics evaluationStatistics); }
StrictEvaluationStrategy implements EvaluationStrategy, FederatedServiceResolverClient, UUIDable { @Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException { if (expr instanceof StatementPattern) { return evaluate((StatementPattern) expr, bindings); } else if (expr instanceof UnaryTupleOperator) { return evaluate((UnaryTupleOperator) expr, bindings); } else if (expr instanceof BinaryTupleOperator) { return evaluate((BinaryTupleOperator) expr, bindings); } else if (expr instanceof SingletonSet) { return evaluate((SingletonSet) expr, bindings); } else if (expr instanceof EmptySet) { return evaluate((EmptySet) expr, bindings); } else if (expr instanceof ExternalSet) { return evaluate((ExternalSet) expr, bindings); } else if (expr instanceof ZeroLengthPath) { return evaluate((ZeroLengthPath) expr, bindings); } else if (expr instanceof ArbitraryLengthPath) { return evaluate((ArbitraryLengthPath) expr, bindings); } else if (expr instanceof BindingSetAssignment) { return evaluate((BindingSetAssignment) expr, bindings); } else if (expr == null) { throw new IllegalArgumentException("expr must not be null"); } else { throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()); } } StrictEvaluationStrategy(TripleSource tripleSource, FederatedServiceResolver serviceResolver);  StrictEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
			FederatedServiceResolver serviceResolver);  StrictEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
			FederatedServiceResolver serviceResolver, long iterationCacheSyncTreshold,
			EvaluationStatistics evaluationStatistics); @Override UUID getUUID(); @Override void setFederatedServiceResolver(FederatedServiceResolver resolver); @Override FederatedService getService(String serviceUrl); @Override void setOptimizerPipeline(QueryOptimizerPipeline pipeline); @Override TupleExpr optimize(TupleExpr expr, EvaluationStatistics evaluationStatistics, BindingSet bindings); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(ArbitraryLengthPath alp,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(ZeroLengthPath zlp,
			final BindingSet bindings); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Service service, String serviceUri,
			CloseableIteration<BindingSet, QueryEvaluationException> bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Service service, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(DescribeOperator operator,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(StatementPattern sp,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(UnaryTupleOperator expr,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BindingSetAssignment bsa,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Projection projection, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(MultiProjection multiProjection,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Filter filter, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Slice slice, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Extension extension, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Distinct distinct, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Reduced reduced, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Group node, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Order node, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BinaryTupleOperator expr,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Join join, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(LeftJoin leftJoin,
			final BindingSet bindings); @SuppressWarnings("unchecked") CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Union union,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Intersection intersection,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Difference difference,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(SingletonSet singletonSet,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(EmptySet emptySet, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(ExternalSet external, BindingSet bindings); @Override Value evaluate(ValueExpr expr, BindingSet bindings); Value evaluate(Var var, BindingSet bindings); Value evaluate(ValueConstant valueConstant, BindingSet bindings); Value evaluate(BNodeGenerator node, BindingSet bindings); Value evaluate(Bound node, BindingSet bindings); Value evaluate(Str node, BindingSet bindings); Value evaluate(Label node, BindingSet bindings); Value evaluate(Lang node, BindingSet bindings); Value evaluate(Datatype node, BindingSet bindings); Value evaluate(Namespace node, BindingSet bindings); Value evaluate(LocalName node, BindingSet bindings); Value evaluate(IsResource node, BindingSet bindings); Value evaluate(IsURI node, BindingSet bindings); Value evaluate(IsBNode node, BindingSet bindings); Value evaluate(IsLiteral node, BindingSet bindings); Value evaluate(IsNumeric node, BindingSet bindings); IRI evaluate(IRIFunction node, BindingSet bindings); Value evaluate(Regex node, BindingSet bindings); Value evaluate(LangMatches node, BindingSet bindings); Value evaluate(Like node, BindingSet bindings); Value evaluate(FunctionCall node, BindingSet bindings); Value evaluate(And node, BindingSet bindings); Value evaluate(Or node, BindingSet bindings); Value evaluate(Not node, BindingSet bindings); Value evaluate(Now node, BindingSet bindings); Value evaluate(SameTerm node, BindingSet bindings); Value evaluate(Coalesce node, BindingSet bindings); Value evaluate(Compare node, BindingSet bindings); Value evaluate(MathExpr node, BindingSet bindings); Value evaluate(If node, BindingSet bindings); Value evaluate(In node, BindingSet bindings); Value evaluate(ListMemberOperator node, BindingSet bindings); Value evaluate(CompareAny node, BindingSet bindings); Value evaluate(CompareAll node, BindingSet bindings); Value evaluate(Exists node, BindingSet bindings); @Override boolean isTrue(ValueExpr expr, BindingSet bindings); }
StrictEvaluationStrategy implements EvaluationStrategy, FederatedServiceResolverClient, UUIDable { @Override public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings) throws QueryEvaluationException { if (expr instanceof StatementPattern) { return evaluate((StatementPattern) expr, bindings); } else if (expr instanceof UnaryTupleOperator) { return evaluate((UnaryTupleOperator) expr, bindings); } else if (expr instanceof BinaryTupleOperator) { return evaluate((BinaryTupleOperator) expr, bindings); } else if (expr instanceof SingletonSet) { return evaluate((SingletonSet) expr, bindings); } else if (expr instanceof EmptySet) { return evaluate((EmptySet) expr, bindings); } else if (expr instanceof ExternalSet) { return evaluate((ExternalSet) expr, bindings); } else if (expr instanceof ZeroLengthPath) { return evaluate((ZeroLengthPath) expr, bindings); } else if (expr instanceof ArbitraryLengthPath) { return evaluate((ArbitraryLengthPath) expr, bindings); } else if (expr instanceof BindingSetAssignment) { return evaluate((BindingSetAssignment) expr, bindings); } else if (expr == null) { throw new IllegalArgumentException("expr must not be null"); } else { throw new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()); } } StrictEvaluationStrategy(TripleSource tripleSource, FederatedServiceResolver serviceResolver);  StrictEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
			FederatedServiceResolver serviceResolver);  StrictEvaluationStrategy(TripleSource tripleSource, Dataset dataset,
			FederatedServiceResolver serviceResolver, long iterationCacheSyncTreshold,
			EvaluationStatistics evaluationStatistics); @Override UUID getUUID(); @Override void setFederatedServiceResolver(FederatedServiceResolver resolver); @Override FederatedService getService(String serviceUrl); @Override void setOptimizerPipeline(QueryOptimizerPipeline pipeline); @Override TupleExpr optimize(TupleExpr expr, EvaluationStatistics evaluationStatistics, BindingSet bindings); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(TupleExpr expr, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(ArbitraryLengthPath alp,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(ZeroLengthPath zlp,
			final BindingSet bindings); @Override CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Service service, String serviceUri,
			CloseableIteration<BindingSet, QueryEvaluationException> bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Service service, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(DescribeOperator operator,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(StatementPattern sp,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(UnaryTupleOperator expr,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BindingSetAssignment bsa,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Projection projection, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(MultiProjection multiProjection,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Filter filter, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Slice slice, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Extension extension, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Distinct distinct, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Reduced reduced, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Group node, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Order node, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(BinaryTupleOperator expr,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Join join, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(LeftJoin leftJoin,
			final BindingSet bindings); @SuppressWarnings("unchecked") CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Union union,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Intersection intersection,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(final Difference difference,
			final BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(SingletonSet singletonSet,
			BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(EmptySet emptySet, BindingSet bindings); CloseableIteration<BindingSet, QueryEvaluationException> evaluate(ExternalSet external, BindingSet bindings); @Override Value evaluate(ValueExpr expr, BindingSet bindings); Value evaluate(Var var, BindingSet bindings); Value evaluate(ValueConstant valueConstant, BindingSet bindings); Value evaluate(BNodeGenerator node, BindingSet bindings); Value evaluate(Bound node, BindingSet bindings); Value evaluate(Str node, BindingSet bindings); Value evaluate(Label node, BindingSet bindings); Value evaluate(Lang node, BindingSet bindings); Value evaluate(Datatype node, BindingSet bindings); Value evaluate(Namespace node, BindingSet bindings); Value evaluate(LocalName node, BindingSet bindings); Value evaluate(IsResource node, BindingSet bindings); Value evaluate(IsURI node, BindingSet bindings); Value evaluate(IsBNode node, BindingSet bindings); Value evaluate(IsLiteral node, BindingSet bindings); Value evaluate(IsNumeric node, BindingSet bindings); IRI evaluate(IRIFunction node, BindingSet bindings); Value evaluate(Regex node, BindingSet bindings); Value evaluate(LangMatches node, BindingSet bindings); Value evaluate(Like node, BindingSet bindings); Value evaluate(FunctionCall node, BindingSet bindings); Value evaluate(And node, BindingSet bindings); Value evaluate(Or node, BindingSet bindings); Value evaluate(Not node, BindingSet bindings); Value evaluate(Now node, BindingSet bindings); Value evaluate(SameTerm node, BindingSet bindings); Value evaluate(Coalesce node, BindingSet bindings); Value evaluate(Compare node, BindingSet bindings); Value evaluate(MathExpr node, BindingSet bindings); Value evaluate(If node, BindingSet bindings); Value evaluate(In node, BindingSet bindings); Value evaluate(ListMemberOperator node, BindingSet bindings); Value evaluate(CompareAny node, BindingSet bindings); Value evaluate(CompareAll node, BindingSet bindings); Value evaluate(Exists node, BindingSet bindings); @Override boolean isTrue(ValueExpr expr, BindingSet bindings);  }