Search in sources :

Example 1 with FilterColumnRowInput

use of org.knime.base.data.filter.column.FilterColumnRowInput in project knime-core by knime.

the class AppendedRowsNodeModel method run.

void run(final RowInput[] inputs, final RowOutput output, final ExecutionMonitor exec, final long totalRowCount) throws Exception {
    RowInput[] corrected;
    if (m_isIntersection) {
        final RowInput[] noNullArray = noNullArray(inputs);
        corrected = new RowInput[noNullArray.length];
        DataTableSpec[] inSpecs = new DataTableSpec[noNullArray.length];
        for (int i = 0; i < noNullArray.length; i++) {
            inSpecs[i] = noNullArray[i].getDataTableSpec();
        }
        String[] intersection = getIntersection(inSpecs);
        for (int i = 0; i < noNullArray.length; i++) {
            corrected[i] = new FilterColumnRowInput(noNullArray[i], intersection);
        }
    } else {
        corrected = inputs;
    }
    AppendedRowsTable.DuplicatePolicy duplPolicy;
    if (m_isFailOnDuplicate) {
        duplPolicy = AppendedRowsTable.DuplicatePolicy.Fail;
    } else if (m_isAppendSuffix) {
        duplPolicy = AppendedRowsTable.DuplicatePolicy.AppendSuffix;
    } else {
        duplPolicy = AppendedRowsTable.DuplicatePolicy.Skip;
    }
    AppendedRowsRowInput appendedInput = AppendedRowsRowInput.create(corrected, duplPolicy, m_suffix, exec, totalRowCount);
    try {
        DataRow next;
        // note, this iterator throws runtime exceptions when canceled.
        while ((next = appendedInput.poll()) != null) {
            // may throw exception, also sets progress
            output.push(next);
        }
    } catch (AppendedRowsIterator.RuntimeCanceledExecutionException rcee) {
        throw rcee.getCause();
    } finally {
        output.close();
    }
    if (appendedInput.getNrRowsSkipped() > 0) {
        setWarningMessage("Filtered out " + appendedInput.getNrRowsSkipped() + " duplicate row(s).");
    }
    if (m_enableHiliting) {
        Map<RowKey, Set<RowKey>> map = createHiliteTranslationMap(appendedInput.getDuplicateNameMap());
        m_hiliteTranslator.setMapper(new DefaultHiLiteMapper(map));
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) RowKey(org.knime.core.data.RowKey) FilterColumnRowInput(org.knime.base.data.filter.column.FilterColumnRowInput) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) RowInput(org.knime.core.node.streamable.RowInput) AppendedRowsRowInput(org.knime.core.data.append.AppendedRowsRowInput) DataRow(org.knime.core.data.DataRow) DuplicatePolicy(org.knime.core.data.append.AppendedRowsTable.DuplicatePolicy) AppendedRowsIterator(org.knime.core.data.append.AppendedRowsIterator) AppendedRowsTable(org.knime.core.data.append.AppendedRowsTable) AppendedRowsRowInput(org.knime.core.data.append.AppendedRowsRowInput) FilterColumnRowInput(org.knime.base.data.filter.column.FilterColumnRowInput) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 FilterColumnRowInput (org.knime.base.data.filter.column.FilterColumnRowInput)1 DataRow (org.knime.core.data.DataRow)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 RowKey (org.knime.core.data.RowKey)1 AppendedRowsIterator (org.knime.core.data.append.AppendedRowsIterator)1 AppendedRowsRowInput (org.knime.core.data.append.AppendedRowsRowInput)1 AppendedRowsTable (org.knime.core.data.append.AppendedRowsTable)1 DuplicatePolicy (org.knime.core.data.append.AppendedRowsTable.DuplicatePolicy)1 DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)1 DataTableRowInput (org.knime.core.node.streamable.DataTableRowInput)1 RowInput (org.knime.core.node.streamable.RowInput)1