use of org.knime.core.node.BufferedDataTable.KnowsRowCountTable in project knime-core by knime.
the class ExecutionContext method createJoinedTable.
/**
* Creates a new {@link BufferedDataTable} that is a column based join of
* the argument tables. The <code>left</code> table argument contributes
* the first set of columns and the <code>right</code> table argument the
* second set of columns. The tables must not contain duplicate columns
* (i.e. columns with the same name). They do need to contain the same set
* of rows though, i.e. the same row count and equal row keys in identical
* order. If any of these constraints is not met, this method throws and
* <code>IllegalArgumentException</code>.
*
* <p>
* This method will traverse both tables once to ensure that the row keys
* are identical and are returned in the same order. It reports progress for
* this sanity check to the <code>exec</code> argument.
*
* <p>
* The returned table is only a view on both argument tables, i.e. any
* subsequent iteration is carried out on the argument tables. This also
* means that the returned table does only acquire little main memory and no
* disc memory at all.
*
* @param left The table contributing the first set of columns.
* @param right The table contributing the second set of columns.
* @param exec For progress information and cancel checks, consider to use a
* {@link ExecutionMonitor#createSubProgress(double) sub
* execution monitor} when joining two tables is only part of the
* whole work.
* @return A buffered data table as join of the two argument tables.
* @throws CanceledExecutionException If progress has been canceled.
* @throws NullPointerException If any argument is <code>null</code>.
* @throws IllegalArgumentException If the tables contain duplicate columns
* or non-matching rows.
* @see DataTableSpec#DataTableSpec(DataTableSpec, DataTableSpec)
*/
public BufferedDataTable createJoinedTable(final BufferedDataTable left, final BufferedDataTable right, final ExecutionMonitor exec) throws CanceledExecutionException {
KnowsRowCountTable jt = getTableBackend().append(exec, m_dataRepository::generateNewID, left, right);
registerAsLocalTableIfContainerTable(jt);
var out = BufferedDataTable.wrapTableFromTableBackend(jt, getDataRepository());
out.setOwnerRecursively(m_node);
return out;
}
use of org.knime.core.node.BufferedDataTable.KnowsRowCountTable in project knime-core by knime.
the class ExecutionContext method createConcatenateTable.
/**
* Creates a new {@link BufferedDataTable}, which is row-wise
* concatenation of the argument tables. The order of the rows in the
* returned table is defined through the order of the argument array
* <code>tables</code> (the <code>BufferedDataTable</code> at index 0
* provides the first set of rows.
*
* <p> The column domains (min, max and possible values) will be
* merged.
*
* <p>Property handlers (such as
* {@link org.knime.core.data.property.ColorHandler Color},
* {@link org.knime.core.data.property.ShapeHandler Shape}, and
* {@link org.knime.core.data.property.SizeHandler}) are taken from the
* first table in the given array.
*
* <p>
* If tables don't match structurally, e.g. a column is present in one table but not the other,
* missing values are inserted accordingly.
*
* <p>The {@link org.knime.core.data.RowKey RowKeys} must be unique, other
* wise this method throws an exception.
* @param exec For cancel checks (this method iterates all rows to
* ensure uniqueness) and progress.
* @param tables An array of tables to concatenate,
* must not be <code>null</code> or empty.
* @return The concatenated table.
* @throws CanceledExecutionException If canceled.
* @throws IllegalArgumentException If the table specs violate any
* constraint mentioned above, the row keys are not unique, or the array
* is empty.
* @throws NullPointerException If any argument is <code>null</code>.
*/
public BufferedDataTable createConcatenateTable(final ExecutionMonitor exec, final BufferedDataTable... tables) throws CanceledExecutionException {
final KnowsRowCountTable table = getTableBackend().concatenate(exec, m_dataRepository::generateNewID, null, true, tables);
registerAsLocalTableIfContainerTable(table);
final var out = BufferedDataTable.wrapTableFromTableBackend(table, getDataRepository());
out.setOwnerRecursively(m_node);
return out;
}
use of org.knime.core.node.BufferedDataTable.KnowsRowCountTable in project knime-core by knime.
the class ExecutionContext method createConcatenateTable.
/**
* Creates a new {@link BufferedDataTable}, which is row-wise concatenation of the argument tables. The order of the
* rows in the returned table is defined through the order of the argument array <code>tables</code> (the
* <code>BufferedDataTable</code> at index 0 provides the first set of rows.
*
* <p>
* The column domains (min, max and possible values) will be merged.
*
* <p>
* Property handlers (such as {@link org.knime.core.data.property.ColorHandler Color},
* {@link org.knime.core.data.property.ShapeHandler Shape}, and {@link org.knime.core.data.property.SizeHandler})
* are taken from the first table in the given array.
* <p>
* If tables don't match structurally, e.g. a column is present in one table but not the other, missing values are
* inserted accordingly.
*
* <p>
* If the pre-check for duplicates is NOT desired, the {@link org.knime.core.data.RowKey RowKeys} must either be
* unique or a suffix needs to be appended. Otherwise this method throws an exception
*
* @param exec For cancel checks (this method iterates all rows to ensure uniqueness) and progress.
* @param rowKeyDuplicateSuffix if set, the given suffix will be appended to row key duplicates.
* @param duplicatesPreCheck if for duplicates should be checked BEFORE creating the result table. If
* <code>false</code> the row keys of the input tables MUST either be unique over all tables or
* a suffix appended.
* @param tables An array of tables to concatenate, must not be <code>null</code> or empty.
* @return The concatenated table.
* @throws CanceledExecutionException If canceled.
* @throws IllegalArgumentException If the table specs violate any constraint mentioned above, the row keys are not
* unique, or the array is empty.
* @throws NullPointerException If any argument is <code>null</code>.
* @since 3.1
*/
public BufferedDataTable createConcatenateTable(final ExecutionMonitor exec, final Optional<String> rowKeyDuplicateSuffix, final boolean duplicatesPreCheck, final BufferedDataTable... tables) throws CanceledExecutionException {
final KnowsRowCountTable concatenated = getTableBackend().concatenate(exec, m_dataRepository::generateNewID, rowKeyDuplicateSuffix.orElse(null), duplicatesPreCheck, tables);
registerAsLocalTableIfContainerTable(concatenated);
var out = BufferedDataTable.wrapTableFromTableBackend(concatenated, m_dataRepository);
out.setOwnerRecursively(m_node);
return out;
}
Aggregations