use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.
the class BigGroupByTable method createTableRows.
/**
* Creates and adds the result rows for the members of a data chunk to the
* given data container. It also handles the row key mapping if hilite
* translation is enabled.
*
* @param dc the {@link DataContainer} to use
* @param chunkMembers the members of the current data chunk
* @param groupCounter the number of groups that have been created
* so fare
*/
private void createTableRows(final BufferedDataContainer dc, final Map<GroupKey, Pair<ColumnAggregator[], Set<RowKey>>> chunkMembers, final MutableInteger groupCounter) {
if (chunkMembers == null || chunkMembers.isEmpty()) {
return;
}
for (final Entry<GroupKey, Pair<ColumnAggregator[], Set<RowKey>>> e : chunkMembers.entrySet()) {
final DataCell[] groupVals = e.getKey().getGroupVals();
final ColumnAggregator[] colAggregators = e.getValue().getFirst();
final RowKey rowKey = RowKey.createRowKey(groupCounter.intValue());
groupCounter.inc();
final DataCell[] rowVals = new DataCell[groupVals.length + colAggregators.length];
// add the group values first
int valIdx = 0;
for (final DataCell groupCell : groupVals) {
rowVals[valIdx++] = groupCell;
}
// add the aggregation values
for (final ColumnAggregator colAggr : colAggregators) {
final AggregationOperator operator = colAggr.getOperator(getGlobalSettings());
rowVals[valIdx++] = operator.getResult();
if (operator.isSkipped()) {
// add skipped groups and the column that causes the
// skipping into the skipped groups map
addSkippedGroup(colAggr.getOriginalColName(), operator.getSkipMessage(), groupVals);
}
m_missingValuesMap.get(colAggr.getOriginalColName()).add(operator.getMissingValuesCount());
}
final DataRow newRow = new DefaultRow(rowKey, rowVals);
dc.addRowToTable(newRow);
if (isEnableHilite()) {
final Set<RowKey> oldKeys = e.getValue().getSecond();
addHiliteMapping(rowKey, oldKeys);
}
}
}
use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.
the class AggregationCellFactory method getColumnSpecs.
/**
* {@inheritDoc}
*/
@Override
public DataColumnSpec[] getColumnSpecs() {
final DataColumnSpec[] specs = new DataColumnSpec[m_operators.length];
for (int i = 0; i < m_operators.length; i++) {
final AggregationOperator operator = m_operators[i];
specs[i] = operator.createColumnSpec(m_colNames[i], m_dummyOrigSpec);
}
return specs;
}
use of org.knime.base.data.aggregation.AggregationOperator in project knime-core by knime.
the class MovingAggregationTableFactory method getCumulativeTable.
private BufferedDataTable getCumulativeTable(final ExecutionContext exec, final BufferedDataTable table, final BufferedDataContainer dc) throws CanceledExecutionException {
final int rowCount = table.getRowCount();
int rowIdx = 0;
for (final DataRow row : table) {
exec.setProgress(rowIdx / (double) rowCount, "Processing row " + rowIdx + " of " + rowCount);
exec.checkCanceled();
final DataCell[] cells = new DataCell[m_ops.length + m_cols2KeepIdxs.length];
int idx = 0;
// handle the retained columns
for (final int colIdx : m_cols2KeepIdxs) {
cells[idx++] = row.getCell(colIdx);
}
for (int i = 0, length = m_ops.length; i < length; i++) {
final int colIdx = m_aggrColIdxs[i];
final AggregationOperator op = m_ops[i];
op.compute(row, colIdx);
cells[idx++] = op.getResult();
}
dc.addRowToTable(new DefaultRow(row.getKey(), cells));
}
dc.close();
return dc.getTable();
}
Aggregations