/* // $Id: //guest/julian_hyde/saffron/src/main/saffron/rel/TableAccess.java#3 $ // Saffron preprocessor and data engine // Copyright (C) 2002 Julian Hyde <julian.hyde@mail.com> // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // // You should have received a copy of the GNU Library General Public // License along with this library; if not, write to the // Free Software Foundation, Inc., 59 Temple Place - Suite 330, // Boston, MA 02111-1307, USA. // // See the COPYING file located in the top-level-directory of // the archive of this library for complete text of license. */ package saffron.rel; import openjava.mop.OJClass; import openjava.ptree.Expression; import saffron.ImplementableTable; import saffron.Planner; import saffron.Table; import saffron.opt.CallingConvention; import saffron.opt.Cluster; import saffron.opt.Cost; import saffron.rel.java.JavaTableAccess; /** * A <code>TableAccess</code> reads all the rows from a {@link saffron.Table}. * * <p> If the table is a {@link saffron.ext.JdbcTable}, then this is literally * possible. But for other kinds of tables, there may be many ways to read the * data from the table. For some kinds of table, it may not even be possible to * read all of the rows unless some narrowing constraint is applied. In the * example of the {@link sales.Reflect} schema, <blockquote> * * <pre>select from fields</pre> * </blockquote>cannot be implemented, but <blockquote> * * <pre>select from fields as f * where f.getClass().getName().equals("java.lang.String")</pre> * * </blockquote>can. It is the optimizer's responsibility to find these ways, * by applying transformation rules. * * @author jhyde * @since 10 November, 2001 * @version $Id: //guest/julian_hyde/saffron/src/main/saffron/rel/TableAccess.java#3 $ **/ public class TableAccess extends Rel { protected Table table; public Expression getConnectionExp() { return connectionExp; } protected Expression connectionExp; public TableAccess(Cluster cluster, Table table, Expression connectionExp) { super(cluster); this.table = table; this.connectionExp = connectionExp; cluster.planner.registerSchema(table.getSchema()); } public Object clone() { return this; } // override Rel public Expression[] getChildExps() { return new Expression[] {connectionExp}; } // override Rel public Rel changeConvention(Planner planner, int convention) { switch (convention) { case CallingConvention.JAVA: if (table instanceof ImplementableTable) { return new JavaTableAccess( cluster, (ImplementableTable) table, connectionExp); } else { return null; } default: return null; } } public Cost computeSelfCost(Planner planner) { double dRows = table.getRowCount(), dCpu = dRows, dIo = 0; return planner.makeCost(dRows, dCpu, dIo); } // implement Rel public OJClass deriveRowType() { return table.getRowType(); } protected Table getTable() { return table; } } // End TableAccess.java
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 1801 | Julian Hyde |
saffron: add ObjectSchema; rules can now be matched more than once; started to implement correlations in queries in from list. |
||
#2 | 1474 | Julian Hyde |
saffron: Aggregations are working. Renamed 'aggregator' to 'aggregation'. |
||
#1 | 1467 | Julian Hyde |
saffron: First saffron check-in; incorporate my changes to openjava. |