Search in sources :

Example 16 with DataTableRowInput

use of org.knime.core.node.streamable.DataTableRowInput in project knime-core by knime.

the class NumericOutliersReviser method treatOutliers.

/**
 * Removes/Retains all rows from the input table that contain outliers. Additionally, the outlier and group related
 * counts, and the new domains are calculated.
 *
 * @param exec the execution context
 * @param in the input data table
 * @param outlierModel the model storing the permitted intervals
 * @return returns the data table whose outliers have been treated
 * @throws Exception any exception to indicate an error, cancelation.
 */
public BufferedDataTable treatOutliers(final ExecutionContext exec, final BufferedDataTable in, final NumericOutliersModel outlierModel) throws Exception {
    final BufferedDataTableRowOutput out = new BufferedDataTableRowOutput(exec.createDataContainer(getOutTableSpec(in.getDataTableSpec())));
    // treat the outliers
    treatOutliers(exec, new DataTableRowInput(in), out, outlierModel, in.size(), false);
    // store the result
    final BufferedDataTable outTable;
    // update the domain if necessary. This cannot be done if we are in streaming mode
    if (updateDomain()) {
        outTable = m_domainUpdater.updateDomain(exec, out.getDataTable());
        m_domainUpdater = null;
    } else {
        outTable = out.getDataTable();
    }
    // set empty table message only if not both tables are empty
    if (outTable.size() == 0 && m_summaryTable.size() > 0) {
        warnListeners(EMPTY_TABLE_WARNING);
    }
    // return the table
    return outTable;
}
Also used : DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) BufferedDataTable(org.knime.core.node.BufferedDataTable) BufferedDataTableRowOutput(org.knime.core.node.streamable.BufferedDataTableRowOutput)

Example 17 with DataTableRowInput

use of org.knime.core.node.streamable.DataTableRowInput in project knime-core by knime.

the class DateTimeDifferenceNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected BufferedDataTable[] execute(final BufferedDataTable[] inData, final ExecutionContext exec) throws Exception {
    if (m_modusSelectModel.getStringValue().equals(ModusOptions.UsePreviousRow.name())) {
        final BufferedDataTableRowOutput out = new BufferedDataTableRowOutput(exec.createDataContainer(new DataTableSpecCreator(inData[0].getDataTableSpec()).addColumns(createColumnSpec(inData[0].getDataTableSpec())).createSpec()));
        execute(new DataTableRowInput(inData[0]), out, exec, inData[0].size());
        return new BufferedDataTable[] { out.getDataTable() };
    } else {
        final ColumnRearranger r = createColumnRearranger(inData[0].getDataTableSpec());
        final BufferedDataTable out = exec.createColumnRearrangeTable(inData[0], r, exec);
        return new BufferedDataTable[] { out };
    }
}
Also used : ColumnRearranger(org.knime.core.data.container.ColumnRearranger) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) BufferedDataTable(org.knime.core.node.BufferedDataTable) BufferedDataTableRowOutput(org.knime.core.node.streamable.BufferedDataTableRowOutput)

Example 18 with DataTableRowInput

use of org.knime.core.node.streamable.DataTableRowInput in project knime-core by knime.

the class DBWriterNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    exec.setProgress("Opening database connection to write data...");
    DatabaseConnectionSettings connSettings;
    if ((inData.length > 1) && (inData[1] instanceof DatabaseConnectionPortObject)) {
        connSettings = ((DatabaseConnectionPortObject) inData[1]).getConnectionSettings(getCredentialsProvider());
    } else {
        connSettings = m_conn;
    }
    DBWriter writer = connSettings.getUtility().getWriter(connSettings);
    BufferedDataTable inputTable = (BufferedDataTable) inData[0];
    DataTableRowInput rowInput = new DataTableRowInput(inputTable);
    // write entire data
    final String error = writer.writeData(m_tableName, rowInput, inputTable.size(), m_append, exec, m_types, getCredentialsProvider(), m_batchSize, m_insertNullForMissingCols, m_failOnError);
    // set error message generated during writing rows
    if (error != null) {
        super.setWarningMessage(error);
    }
    return new BufferedDataTable[0];
}
Also used : DatabaseConnectionPortObject(org.knime.core.node.port.database.DatabaseConnectionPortObject) DatabaseConnectionSettings(org.knime.core.node.port.database.DatabaseConnectionSettings) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) DBWriter(org.knime.core.node.port.database.writer.DBWriter)

Example 19 with DataTableRowInput

use of org.knime.core.node.streamable.DataTableRowInput in project knime-core by knime.

the class ParameterizedDBQueryNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    final BufferedDataTable inTable = (BufferedDataTable) inData[0];
    final DatabasePortObject dbObject = (DatabasePortObject) inData[1];
    DatabaseQueryConnectionSettings conn = dbObject.getConnectionSettings(getCredentialsProvider());
    final String newQuery = parseSQLStatement(inTable.getDataTableSpec(), conn.getQuery());
    conn = createDBQueryConnection(dbObject.getSpec(), newQuery);
    final DBReader reader = conn.getUtility().getReader(conn);
    final DataTableRowInput data = new DataTableRowInput(inTable);
    final BufferedDataTable outTable = reader.loopTable(exec, getCredentialsProvider(), data, inTable.size(), m_failIfExceptionModel.getBooleanValue(), m_appendInputColumnsModel.getBooleanValue(), m_includeEmptyResultsModel.getBooleanValue(), m_retainAllColumnsModel.getBooleanValue(), m_dataColumns.toArray(new String[m_dataColumns.size()])).getDataTable();
    final BufferedDataTable errorTable = reader.getErrorDataTable();
    return new BufferedDataTable[] { outTable, errorTable };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DBReader(org.knime.core.node.port.database.reader.DBReader) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput)

Example 20 with DataTableRowInput

use of org.knime.core.node.streamable.DataTableRowInput in project knime-core by knime.

the class UngroupOperation2 method compute.

/**
 * Performs the ungroup operation on the given data table.
 *
 * @param exec the execution context
 * @param table table to perform the ungroup operation on
 * @param trans the hilite translater, will be modified directly. Must be non-null if hiliting is enabled, can be
 *            <code>null</code> otherwise
 * @return the table with the ungrouped collections
 * @throws CanceledExecutionException if the execution has been canceled
 * @throws InterruptedException if the execution has been interrupted
 * @throws InvalidSettingsException thrown if the table doesn't contain a collection column at one of the column
 *             indices to be ungrouped
 * @throws IllegalArgumentException if hiliting is enabled and no hilite translater is given
 */
public BufferedDataTable compute(final ExecutionContext exec, final BufferedDataTable table, final HiLiteTranslator trans) throws CanceledExecutionException, InterruptedException, InvalidSettingsException {
    final BufferedDataContainer dc = exec.createDataContainer(createTableSpec(table.getDataTableSpec(), m_removeCollectionCol, m_colIndices));
    if (table.size() == 0) {
        dc.close();
        return dc.getTable();
    }
    DataTableRowInput in = new DataTableRowInput(table);
    BufferedDataTableRowOutput out = new BufferedDataTableRowOutput(dc);
    try {
        compute(in, out, exec, table.size(), trans);
    } finally {
        in.close();
        out.close();
    }
    return out.getDataTable();
}
Also used : BufferedDataContainer(org.knime.core.node.BufferedDataContainer) DataTableRowInput(org.knime.core.node.streamable.DataTableRowInput) BufferedDataTableRowOutput(org.knime.core.node.streamable.BufferedDataTableRowOutput)

Aggregations

DataTableRowInput (org.knime.core.node.streamable.DataTableRowInput)24 BufferedDataTableRowOutput (org.knime.core.node.streamable.BufferedDataTableRowOutput)16 BufferedDataTable (org.knime.core.node.BufferedDataTable)15 DataTableSpec (org.knime.core.data.DataTableSpec)9 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)9 RowInput (org.knime.core.node.streamable.RowInput)7 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)6 RowOutput (org.knime.core.node.streamable.RowOutput)6 StreamableOperator (org.knime.core.node.streamable.StreamableOperator)4 DataRow (org.knime.core.data.DataRow)3 ExecutionContext (org.knime.core.node.ExecutionContext)3 PortObject (org.knime.core.node.port.PortObject)3 PortInput (org.knime.core.node.streamable.PortInput)3 DataCell (org.knime.core.data.DataCell)2 PartitionInfo (org.knime.core.node.streamable.PartitionInfo)2 PortObjectInput (org.knime.core.node.streamable.PortObjectInput)2 PortOutput (org.knime.core.node.streamable.PortOutput)2 SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)2 File (java.io.File)1 IOException (java.io.IOException)1