Creating a table with just one cell


with the help of dill, i created a node the last week, now i am trying to adapt the scorer node for what i need, and i have asked him for some help, but i´s better that i post it here, because it is possible than helps others.

I need to create a output with a table, this table has only one cell. And i need to put a "float" in the cell. So i have the float and i have a buffered data container, can i put the float into the cell of the container?? Because these tables are only-read, aren´t?

Best regards!


The DataTableSpec must fit the structure of you output table which consists of one column and this is of type double and with the name "accuracy":

        // double accuracy = your accuracy
        DataColumnSpecCreator creator = new DataColumnSpecCreator(
                "accuracy", DoubleCell.TYPE);
        DataTableSpec ts = new DataTableSpec(creator.createSpec());
        DataContainer cont = exec.createDataContainer(ts);
        cont.addRowToTable(new DefaultRow(
        new StringCell("Row1"), new DoubleCell(accuracy)));
// now return the original table (oldTable) of the scorer node and the new one
    return new BufferedDataTable[]{oldTable, cont.getTable()};

Please note: in order to have your node properly configured, you also have to return two DataTableSpecs in the configure method. So I recommend to put the creation of the additional data table spec in a private method which returns the DataTableSpec and call it from the configure and from the execute method.