Search in sources :

Example 6 with AppendedColumnRow

use of org.knime.base.data.append.column.AppendedColumnRow in project knime-core by knime.

the class RecursiveLoopEndNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    validateLoopStart();
    // in port 0: collects the data provided at the output port
    // in port 1: is fed back to loop start node
    BufferedDataContainer loopData = exec.createDataContainer(inData[resultingIn].getDataTableSpec());
    for (DataRow row : inData[resultingIn]) {
        exec.checkCanceled();
        exec.setMessage("Copy input table 1");
        loopData.addRowToTable(createNewRow(row, row.getKey()));
    }
    loopData.close();
    m_inData = loopData.getTable();
    boolean endLoop = checkDataTableSize(m_minNumberOfRows.getIntValue()) || (m_iterationnr + 1) >= m_maxIterations.getIntValue() || m_endLoop.getStringValue().equalsIgnoreCase("true");
    if (m_onlyLastResult.getBooleanValue()) {
        if (endLoop) {
            return new BufferedDataTable[] { inData[collectingIn] };
        }
    } else {
        if (m_outcontainer == null) {
            DataTableSpec dts = createSpec(inData[collectingIn].getDataTableSpec());
            m_outcontainer = exec.createDataContainer(dts);
        }
        if (m_addIterationNr.getBooleanValue()) {
            IntCell currIterCell = new IntCell(m_iterationnr);
            for (DataRow row : inData[collectingIn]) {
                exec.checkCanceled();
                exec.setMessage("Collect data for output");
                RowKey newKey = new RowKey(row.getKey() + "#" + m_iterationnr);
                AppendedColumnRow newRow = new AppendedColumnRow(createNewRow(row, newKey), currIterCell);
                m_outcontainer.addRowToTable(newRow);
            }
        } else {
            for (DataRow row : inData[collectingIn]) {
                exec.checkCanceled();
                exec.setMessage("Collect data for output");
                RowKey newKey = new RowKey(row.getKey() + "#" + m_iterationnr);
                m_outcontainer.addRowToTable(createNewRow(row, newKey));
            }
        }
        // or the max number of iterations is reached
        if (endLoop) {
            m_outcontainer.close();
            return new BufferedDataTable[] { m_outcontainer.getTable() };
        }
    }
    m_iterationnr++;
    // go on with loop
    super.continueLoop();
    return new BufferedDataTable[1];
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) RowKey(org.knime.core.data.RowKey) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataRow(org.knime.core.data.DataRow) IntCell(org.knime.core.data.def.IntCell) AppendedColumnRow(org.knime.base.data.append.column.AppendedColumnRow)

Example 7 with AppendedColumnRow

use of org.knime.base.data.append.column.AppendedColumnRow in project knime-core by knime.

the class BasisFunctionPredictorRowIterator method next.

/**
 * {@inheritDoc}
 */
@Override
public DataRow next() {
    DataRow row = m_rowIt.next();
    DataCell classInfo = m_map.get(row.getKey());
    return new AppendedColumnRow(row, classInfo);
}
Also used : DataCell(org.knime.core.data.DataCell) DataRow(org.knime.core.data.DataRow) AppendedColumnRow(org.knime.base.data.append.column.AppendedColumnRow)

Aggregations

AppendedColumnRow (org.knime.base.data.append.column.AppendedColumnRow)7 DataRow (org.knime.core.data.DataRow)7 RowKey (org.knime.core.data.RowKey)6 DataCell (org.knime.core.data.DataCell)5 DataTableSpec (org.knime.core.data.DataTableSpec)5 DefaultRow (org.knime.core.data.def.DefaultRow)5 BufferedDataTable (org.knime.core.node.BufferedDataTable)5 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)4 IntCell (org.knime.core.data.def.IntCell)3 StringCell (org.knime.core.data.def.StringCell)3 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 FilterColumnRow (org.knime.base.data.filter.column.FilterColumnRow)2 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 DoubleCell (org.knime.core.data.def.DoubleCell)2 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)2 DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)2 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1