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;
}
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 };
}
}
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];
}
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 };
}
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();
}
Aggregations