/** ************************************************************************** */ private void insertIndirectionAndPrediction(boolean isPrediction, int position) { int[] newIndirection = new int[indirection.length + 1]; boolean[] newPrediction = new boolean[newIndirection.length]; for (int i = 0; i < position; i++) { newIndirection[i] = indirection[i]; newPrediction[i] = prediction[i]; } if (isPrediction) { if (newTableHackVariable) newIndirection[position] = 0; else newIndirection[position] = predictionColumnsTable.getNumColumns(); } else newIndirection[position] = original.getNumColumns(); newPrediction[position] = isPrediction; for (int i = position + 1; i < newIndirection.length; i++) { newIndirection[i] = indirection[i - 1]; newPrediction[i] = prediction[i - 1]; } indirection = newIndirection; prediction = newPrediction; // also might need to modify predictionSet if (isPrediction) { int[] newPredictionSet = new int[predictionSet.length + 1]; for (int i = 0; i < predictionSet.length; i++) newPredictionSet[i] = predictionSet[i]; newPredictionSet[predictionSet.length] = getNumColumns(); predictionSet = newPredictionSet; } for (int i = 0; i < predictionSet.length; i++) if (predictionSet[i] > position) predictionSet[i]++; // Arrays.sort(predictionSet); }
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 getNumColumns() { if (newTableHackVariable) return original.getNumColumns(); return (original.getNumColumns() + predictionColumnsTable.getNumColumns()); }