// using System; // using System.Collections; // using BCG.Utilities; // using BCG.Evaluator.AddColumnsExpression; // namespace BCG // { // /// // /// Provides methods to add columns to the schema // /// // public class ColumnAdder : IStreamMapper // { // protected IDictionary myNewColumns; // protected IBlueTableSchema mySchema; // static syntax myParser = // new syntax(); // /// // /// string represting the columns to be added to the output table. // /// // /// // public ColumnAdder (string columnDef) // { // AddColumnsExpression ace; // if (DataStreamLoadFileConfig.instance.useStaticParser) // { // lock (myParser) // { // ace = // (AddColumnsExpression)myParser.Parse(columnDef); // } // } // else // { // syntax parser = new syntax(); // ace = // (AddColumnsExpression)parser.Parse(columnDef); // } // if (ace == null) // throw new Exception ("Invalid columnn expression: " + columnDef); // myNewColumns = ace.columns; // } // public virtual IBlueRow map (IBlueRow row) // { // if (mySchema == null) // myConstructSchema (row.schema); // return new AddColumnsRow (mySchema, row); // } // public IBlueTableSchema getOutputSchema (IBlueTableSchema inputSchema) // { // myConstructSchema (inputSchema); // return mySchema; // } // private void myConstructSchema (IBlueTableSchema schema) // { // ColumnInfo[] cis = new ColumnInfo[schema.columnNames.Length + myNewColumns.Count]; // int ciIndex = 0; // foreach (ColumnInfo ci in schema.columnInfo) // cis[ciIndex++] = ci; // foreach (DictionaryEntry de in myNewColumns) // cis[ciIndex] = new ColumnInfo ((string)de.Key, ciIndex ++, // ((AddColumnsExpression.ConstantInfo)de.Value).t, ((AddColumnsExpression.ConstantInfo)de.Value).v); // mySchema = new BlueTableSchema (cis, schema.tableName); // } // } // }