LocalDBPredictionTable(DBExampleTable pet, DBDataSource dataSource, DBConnection conn) { super(pet, dataSource, conn); original = pet; newTableHackVariable = false; // subset = pet.subset; num_original_columns = original.getNumColumns(); predictionSet = new int[outputColumns.length]; for (int j = 0; j < predictionSet.length; j++) predictionSet[j] = j + original.getNumColumns(); // handle indirection and prediction indirection = new int[original.getNumColumns() + predictionSet.length]; prediction = new boolean[indirection.length]; for (int j = 0; j < original.getNumColumns(); j++) { // indirection[j] = j; prediction[j] = false; } for (int j = 0; j < predictionSet.length; j++) { indirection[original.getNumColumns() + j] = j; prediction[original.getNumColumns() + j] = true; } predictionColumns = new Column[outputColumns.length]; // this will make sure that the prediction columns are as long // as the redular columns and subsetted. int numRows = dataSource.getNumRows(); for (int i = 0; i < outputColumns.length; i++) { int type = original.getColumnType(outputColumns[i]); switch (type) { case ColumnTypes.BOOLEAN: predictionColumns[i] = new BooleanColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.BYTE: predictionColumns[i] = new ByteColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.BYTE_ARRAY: predictionColumns[i] = new ContinuousByteArrayColumn(numRows, true); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.CHAR: predictionColumns[i] = new CharColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.CHAR_ARRAY: predictionColumns[i] = new ContinuousCharArrayColumn(numRows, true); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.DOUBLE: predictionColumns[i] = new DoubleColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.FLOAT: predictionColumns[i] = new FloatColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.INTEGER: predictionColumns[i] = new IntColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.LONG: predictionColumns[i] = new LongColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.OBJECT: predictionColumns[i] = new ObjectColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.SHORT: predictionColumns[i] = new ShortColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; case ColumnTypes.STRING: predictionColumns[i] = new StringColumn(numRows); predictionColumns[i].setLabel(original.getColumnLabel(outputColumns[i]) + " Predictions"); break; default: break; } predictionColumnsTable = new SubsetTableImpl(predictionColumns, subset); // (MutableTableImpl)DefaultTableFactory.getInstance().createTable(c); } }
public int getColumnType(int position) { if (prediction[position]) return predictionColumnsTable.getColumnType(indirection[position]); else return original.getColumnType(position); }