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.sail.rdbms.RdbmsValueFactory;
09: import org.openrdf.sail.rdbms.algebra.factories.BNodeExprFactory;
10: import org.openrdf.sail.rdbms.algebra.factories.BooleanExprFactory;
11: import org.openrdf.sail.rdbms.algebra.factories.DatatypeExprFactory;
12: import org.openrdf.sail.rdbms.algebra.factories.HashExprFactory;
13: import org.openrdf.sail.rdbms.algebra.factories.LabelExprFactory;
14: import org.openrdf.sail.rdbms.algebra.factories.LanguageExprFactory;
15: import org.openrdf.sail.rdbms.algebra.factories.NumericExprFactory;
16: import org.openrdf.sail.rdbms.algebra.factories.SqlExprFactory;
17: import org.openrdf.sail.rdbms.algebra.factories.TimeExprFactory;
18: import org.openrdf.sail.rdbms.algebra.factories.URIExprFactory;
19: import org.openrdf.sail.rdbms.algebra.factories.ZonedExprFactory;
20: import org.openrdf.sail.rdbms.managers.TransTableManager;
21: import org.openrdf.sail.rdbms.schema.IdSequence;
22:
23: /**
24: * Initialises the {@link SelectQueryOptimizer} with the SQL expression
25: * factories.
26: *
27: * @author James Leigh
28: *
29: */
30: public class SelectQueryOptimizerFactory {
31: private RdbmsValueFactory vf;
32: private TransTableManager tables;
33: private IdSequence ids;
34:
35: public void setValueFactory(RdbmsValueFactory vf) {
36: this .vf = vf;
37: }
38:
39: public void setTransTableManager(TransTableManager tables) {
40: this .tables = tables;
41: }
42:
43: public void setIdSequence(IdSequence ids) {
44: this .ids = ids;
45: }
46:
47: public SelectQueryOptimizer createRdbmsFilterOptimizer() {
48: LabelExprFactory label = new LabelExprFactory();
49: BooleanExprFactory bool = createBooleanExprFactory();
50: URIExprFactory uri = new URIExprFactory();
51: SqlExprFactory sql = new SqlExprFactory();
52: DatatypeExprFactory datatype = new DatatypeExprFactory();
53: LanguageExprFactory language = new LanguageExprFactory();
54: sql.setBNodeExprFactory(new BNodeExprFactory());
55: sql.setBooleanExprFactory(bool);
56: sql.setDatatypeExprFactory(datatype);
57: sql.setLabelExprFactory(label);
58: sql.setLanguageExprFactory(language);
59: sql.setNumericExprFactory(new NumericExprFactory());
60: sql.setTimeExprFactory(new TimeExprFactory());
61: sql.setZonedExprFactory(new ZonedExprFactory(ids));
62: sql.setHashExprFactory(new HashExprFactory(vf));
63: sql.setURIExprFactory(uri);
64: label.setSqlExprFactory(sql);
65: uri.setSqlExprFactory(sql);
66: bool.setSqlExprFactory(sql);
67: SelectQueryOptimizer optimizer = new SelectQueryOptimizer();
68: optimizer.setSqlExprFactory(sql);
69: optimizer.setValueFactory(vf);
70: optimizer.setTransTableManager(tables);
71: optimizer.setIdSequence(ids);
72: return optimizer;
73: }
74:
75: protected BooleanExprFactory createBooleanExprFactory() {
76: return new BooleanExprFactory();
77: }
78: }
|