use of org.knime.base.data.aggregation.general.CountOperator in project knime-core by knime.
the class CrosstabNodeModel method createGroupByTable.
/**
* Create group-by table.
* @param exec execution context
* @param table input table to group
* @param groupByCols column selected for group-by operation
* @return table with group and aggregation columns
* @throws CanceledExecutionException if the group-by table generation was
* canceled externally
*/
private final GroupByTable createGroupByTable(final ExecutionContext exec, final BufferedDataTable table, final List<String> groupByCols) throws CanceledExecutionException {
final int maxUniqueVals = Integer.MAX_VALUE;
final boolean enableHilite = m_settings.getEnableHiliting();
final boolean retainOrder = false;
final ColumnNamePolicy colNamePolicy = ColumnNamePolicy.AGGREGATION_METHOD_COLUMN_NAME;
final GlobalSettings globalSettings = GlobalSettings.builder().setFileStoreFactory(FileStoreFactory.createWorkflowFileStoreFactory(exec)).setGroupColNames(groupByCols).setMaxUniqueValues(maxUniqueVals).setValueDelimiter(GlobalSettings.STANDARD_DELIMITER).setDataTableSpec(table.getDataTableSpec()).setNoOfRows(table.size()).setAggregationContext(AggregationContext.ROW_AGGREGATION).build();
ColumnAggregator collAggregator = null;
if (null != m_settings.getWeightColumn()) {
final String weightColumn = m_settings.getWeightColumn();
// the column aggregator for the weighting column
final boolean inclMissing = false;
final DataColumnSpec originalColSpec = table.getDataTableSpec().getColumnSpec(weightColumn);
final OperatorColumnSettings opColSettings = new OperatorColumnSettings(inclMissing, originalColSpec);
collAggregator = new ColumnAggregator(originalColSpec, new NonNegativeSumOperator(globalSettings, opColSettings), inclMissing);
} else {
// use any column, does not matter as long as it exists and
// include missing is true;
final boolean inclMissing = true;
final DataColumnSpec originalColSpec = table.getDataTableSpec().getColumnSpec(groupByCols.get(0));
final OperatorColumnSettings opColSettings = new OperatorColumnSettings(inclMissing, originalColSpec);
collAggregator = new ColumnAggregator(originalColSpec, new CountOperator(globalSettings, opColSettings), inclMissing);
}
final GroupByTable resultTable = new BigGroupByTable(exec, table, groupByCols, new ColumnAggregator[] { collAggregator }, globalSettings, enableHilite, colNamePolicy, retainOrder);
if (enableHilite) {
setHiliteMapping(new DefaultHiLiteMapper(resultTable.getHiliteMapping()));
}
// check for skipped columns
final String warningMsg = resultTable.getSkippedGroupsMessage(3, 3);
if (warningMsg != null) {
setWarningMessage(warningMsg);
}
return resultTable;
}
use of org.knime.base.data.aggregation.general.CountOperator in project knime-core by knime.
the class AggregationMethods method registerDeprecatedOperators.
/**
* This method registers previous methods which are deprecated in order to
* be backward compatible. The methods are stored separate from the
* methods to use.
*
* @throws DuplicateOperatorException if one of the methods already exists
*/
@SuppressWarnings("deprecation")
private void registerDeprecatedOperators() throws DuplicateOperatorException {
addDeprecatedOperator(new OrElementCountOperator(new OperatorData("Unique element count", true, false, CollectionDataValue.class, false), GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_INCL_MISSING));
addDeprecatedOperator(new FirstOperator(new OperatorData("First value", false, true, DataValue.class, false), GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
addDeprecatedOperator(new LastOperator(new OperatorData("Last value", false, true, DataValue.class, false), GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
addDeprecatedOperator(new CountOperator(new OperatorData("Value count", false, true, DataValue.class, false), GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
// methods changed in KNIME version 2.4
/**
* Concatenates all cell values.
*/
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.ConcatenateOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_INCL_MISSING));
/**
* Concatenates all distinct cell values.
*/
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.UniqueConcatenateOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
/**
* Concatenates all distinct cell values and counts the members.
*/
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.UniqueConcatenateWithCountOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
// methods changed in KNIME version 2.5.2
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.SumOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
// methods changed in KNIME version 2.12.0
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.AndElementOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.AndElementCountOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
// methods changed in KNIME version 3.4
addDeprecatedOperator(new org.knime.base.data.aggregation.deprecated.MedianOperator(GlobalSettings.DEFAULT, OperatorColumnSettings.DEFAULT_EXCL_MISSING));
}
Aggregations