use of org.knime.core.data.DataRow in project knime-core by knime.
the class RearrangeColumnsTable method calcNewColsSynchronously.
/**
* Processes input sequentially in the caller thread.
*/
private static void calcNewColsSynchronously(final BufferedDataTable table, final ExecutionMonitor subProgress, final NewColumnsProducerMapping newColsProducerMapping, final DataContainer container) throws CanceledExecutionException {
long finalRowCount = table.size();
Set<CellFactory> newColsFactories = newColsProducerMapping.getUniqueCellFactoryMap().keySet();
final int factoryCount = newColsFactories.size();
int r = 0;
CellFactory facForProgress = factoryCount > 0 ? newColsFactories.iterator().next() : null;
for (RowIterator it = table.iterator(); it.hasNext(); r++) {
DataRow row = it.next();
DataRow append = calcNewCellsForRow(row, newColsProducerMapping);
container.addRowToTable(append);
if (facForProgress == null) {
// no factory added means at least one columns gets type converted.
assert !newColsProducerMapping.getConverterToIndexMap().isEmpty();
} else {
facForProgress.setProgress(r + 1, finalRowCount, row.getKey(), subProgress);
}
subProgress.checkCanceled();
}
}
use of org.knime.core.data.DataRow in project knime-core by knime.
the class AbstractColumnTableSorter method sort.
/**
* @param dataTable the table to sort
* @param exec the execution context
* @param resultListener the result listener
* @throws CanceledExecutionException if the user cancels the execution
*/
void sort(final DataTable dataTable, final ExecutionMonitor exec, final SortingConsumer resultListener) throws CanceledExecutionException {
if (m_sortDescriptions.length <= 0) {
for (DataRow r : dataTable) {
resultListener.consume(new DefaultRow(r.getKey(), new DataCell[0]));
}
} else {
clearBuffer();
sortOnDisk(dataTable, exec, resultListener);
}
}
use of org.knime.core.data.DataRow in project knime-core by knime.
the class AbstractColumnTableSorter method fillBuffer.
/**
* @param m_buffer
* @param iterator
* @param checkMemory
* @param exec
* @throws CanceledExecutionException
*/
private long fillBuffer(final RowIterator iterator, final ExecutionMonitor readExec) throws CanceledExecutionException {
long count = 0;
while (iterator.hasNext()) {
count += 1;
readExec.checkCanceled();
DataRow r = iterator.next();
for (Entry<SortingDescription, List<DataRow>> descr : m_buffer.entrySet()) {
descr.getValue().add(descr.getKey().createSubRow(r));
}
// read at least two rows, otherwise we won't make any progress
if ((count >= 2) && m_memActionIndicator.lowMemoryActionRequired()) {
break;
}
}
return count;
}
use of org.knime.core.data.DataRow in project knime-core by knime.
the class AbstractColumnTableSorter method toSortDescriptions.
private static SortingDescription[] toSortDescriptions(final DataTableSpec dataTableSpec, final String[] toSort) throws InvalidSettingsException {
checkArgument(!ArrayUtils.contains(toSort, null), "Null values are not permitted.");
SortingDescription[] toReturn = new SortingDescription[toSort.length];
int index = 0;
for (String so : toSort) {
DataColumnSpec columnSpec = checkSettingNotNull(dataTableSpec.getColumnSpec(so), "Column: '%s' does not exist in input table.", so);
final DataValueComparator comparator = columnSpec.getType().getComparator();
toReturn[index++] = new SortingDescription(so) {
@Override
public int compare(final DataRow o1, final DataRow o2) {
return comparator.compare(o1.getCell(0), o2.getCell(0));
}
};
}
return toReturn;
}
use of org.knime.core.data.DataRow in project knime-core by knime.
the class TableContentModel method getValueAt.
// getRowCount()
/**
* Get the DataCell at a specific location. If the requested row is in the
* cache, it will be returned. Otherwise the ring buffer is updated
* (iterator pushed forward or reset) until the row is in the cache.
*
* @param row the row index
* @param column the column index
* @return the <code>DataCell</code> in the underlying
* <code>DataTable</code> at position [<code>row, column</code>]
* @throws IndexOutOfBoundsException if either argument violates its range
*/
@Override
public DataCell getValueAt(final int row, final int column) {
boundColumn(column);
DataRow result = getRow(row);
return result.getCell(column);
}
Aggregations