use of org.knime.core.data.append.AppendedRowsIterator.PairSupplier in project knime-core by knime.
the class AppendedRowsRowInput method create.
/**
* Concatenates a set of Inputs. Duplicates are handled according to the policy argument. Columns present in one
* input but not the others or conflicting column tables are handled as described in {@link AppendedRowsTable}.
*
* @param ins all inputs to be appended (non-null and no null values allowed)
* @param duplPolicy How to deal with duplicate keys. Non-null.
* @param suffix suffix to append to duplicate keys (must not be null if policy is
* {@link DuplicatePolicy#AppendSuffix})
* @param exec (optional) execution monitor that is used to report progress and check for cancelation. Can be null.
* @param totalRowCount The number of rows to expect (sum over all row counts in the inputs). Only be used for
* progress -- can be negative to have no progress.
* @return a new row input whose iteration scans all argument inputs.
*/
public static AppendedRowsRowInput create(final RowInput[] ins, final DuplicatePolicy duplPolicy, final String suffix, final ExecutionMonitor exec, final long totalRowCount) {
DataTableSpec[] specs = new DataTableSpec[ins.length];
for (int i = 0; i < specs.length; i++) {
specs[i] = ins[i].getDataTableSpec();
}
DataTableSpec spec = AppendedRowsTable.generateDataTableSpec(specs);
CheckUtils.checkArgumentNotNull(duplPolicy, "Arg must not be null");
if (DuplicatePolicy.AppendSuffix.equals(duplPolicy)) {
CheckUtils.checkArgument(StringUtils.isNotEmpty(suffix), "Suffix must not be an empty string.");
}
PairSupplier[] suppliers = new PairSupplier[ins.length];
for (int i = 0; i < suppliers.length; i++) {
suppliers[i] = new PairSupplier(new Pair<RowIterator, DataTableSpec>(new RowInputIterator(ins[i]), ins[i].getDataTableSpec()));
}
AppendedRowsIterator it = new AppendedRowsIterator(suppliers, duplPolicy, suffix, spec, exec, totalRowCount);
return new AppendedRowsRowInput(spec, it);
}
Aggregations