01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.optimizers;
07:
08: import org.openrdf.query.BindingSet;
09: import org.openrdf.query.Dataset;
10: import org.openrdf.query.algebra.TupleExpr;
11: import org.openrdf.query.algebra.Var;
12: import org.openrdf.query.algebra.evaluation.QueryOptimizer;
13: import org.openrdf.query.algebra.helpers.QueryModelVisitorBase;
14: import org.openrdf.sail.rdbms.RdbmsValueFactory;
15:
16: /**
17: * Iterates through the query and converting the values into RDBMS values.
18: *
19: * @author James Leigh
20: *
21: */
22: public class ValueIdLookupOptimizer implements QueryOptimizer {
23: RdbmsValueFactory vf;
24:
25: public ValueIdLookupOptimizer(RdbmsValueFactory vf) {
26: super ();
27: this .vf = vf;
28: }
29:
30: public void optimize(TupleExpr tupleExpr, Dataset dataset,
31: BindingSet bindings) {
32: tupleExpr.visit(new VarVisitor());
33: }
34:
35: protected class VarVisitor extends
36: QueryModelVisitorBase<RuntimeException> {
37:
38: @Override
39: public void meet(Var var) {
40: if (var.hasValue()) {
41: var.setValue(vf.asRdbmsValue(var.getValue()));
42: }
43: }
44: }
45: }
|