/* // $Id: //guest/julian_hyde/saffron/src/main/saffron/rel/Filter.java#2 $ // 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.ptree.Expression; import saffron.PlanWriter; import saffron.Planner; import saffron.opt.CallingConvention; import saffron.opt.Cluster; import saffron.opt.Cost; import saffron.rel.java.JavaFilter; import saffron.rel.plan.PlanFilter; import saffron.util.Util; /** * A <code>Filter</code> is a relational expression which iterates over its * input, and returns elements for which <code>condition</code> evaluates to * <code>true</code>. **/ public class Filter extends SingleRel { public Expression condition; /** * Creates a filter. * * @param cluster {@link Cluster} this relational expression belongs to * @param child input relational expression * @param condition boolean expression which determines whether a row is * allowed to pass * @param translate whether to translate <code>condition</code> from source * code to internal form */ public Filter(Cluster cluster, Rel child, Expression condition) { super(cluster, child); this.condition = condition; } public Object clone() { return new Filter(cluster, (Rel) child.clone(), Util.clone(condition)); } // implement Rel public Expression[] getChildExps() { return new Expression[] {condition}; } public void explain(PlanWriter pw) { pw.explain(this, new String[] {"child", "condition"}); } // override Rel public Rel changeConvention(Planner planner, int convention) { switch (convention) { case CallingConvention.JAVA: Rel convertedChild = planner.convert(child, convention); if (convertedChild == null) { return null; } return new JavaFilter( cluster, convertedChild, condition); case CallingConvention.PLAN: convertedChild = planner.convert(child, convention); if (convertedChild == null) { return null; } return new PlanFilter( cluster, convertedChild, condition); default: return null; } } public Cost computeSelfCost(Planner planner) { double dRows = child.getRows() * Util.getSelectivity(condition), dCpu = child.getRows(), dIo = 0; return planner.makeCost(dRows, dCpu, dIo); } } // End Filter.java
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 1801 | Julian Hyde |
saffron: add ObjectSchema; rules can now be matched more than once; started to implement correlations in queries in from list. |
||
#1 | 1467 | Julian Hyde |
saffron: First saffron check-in; incorporate my changes to openjava. |