/* // $Id: //guest/julian_hyde/saffron/src/main/saffron/PlanWriter.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; import openjava.ptree.Expression; import saffron.rel.Rel; /** * Callback for an expression to dump itself to. **/ public class PlanWriter extends java.io.PrintWriter { boolean brief; int level; public PlanWriter(java.io.PrintWriter pw) { this(pw, false); } public PlanWriter(java.io.PrintWriter pw, boolean brief) { super(pw); this.level = 0; this.brief = brief; } // public void explainTree(Plan plan) // { // this.level = 0; // plan.explain(this); // } public void explainTree(Rel exp) { this.level = 0; exp.explain(this); } private void explainBrief(String s, Rel rel) { print(s); Rel[] inputs = rel.getInputs(); Expression[] children = rel.getChildExps(); if (inputs.length > 0 || children.length > 0) { level++; print("("); int j = 0; for (int i = 0; i < inputs.length; i++) { if (j++ > 0) { print(", "); } Rel input = inputs[i]; input.explain(this); } for (int i = 0; i < children.length; i++) { if (j++ > 0) { print(", "); } Expression child = children[i]; print(child.toString()); } print(")"); level--; } } public void explain(Rel rel, String[] terms) { explain(rel); } public void explain(Rel rel) { String s = rel.getId() + ":" + rel.getRelTypeName(); if (brief) { explainBrief(s, rel); return; } for (int i = 0; i < level; i++) { print(" "); } println(s); level++; Rel[] inputs = rel.getInputs(); for (int i = 0; i < inputs.length; i++) { Rel child = inputs[i]; child.explain(this); } Expression[] children = rel.getChildExps(); for (int i = 0; i < children.length; i++) { Expression child = children[i]; print(child.toString()); } level--; } /** Special form used by {@link saffron.opt.RelSubset}. **/ public void explainSubset(String s, Rel child) { print(s); level++; child.explain(this); level--; } } // End PlanWriter.java
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#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. |