Search in sources :

Example 1 with CountOperator

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;
}
Also used : OperatorColumnSettings(org.knime.base.data.aggregation.OperatorColumnSettings) GlobalSettings(org.knime.base.data.aggregation.GlobalSettings) ColumnNamePolicy(org.knime.base.node.preproc.groupby.ColumnNamePolicy) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) BigGroupByTable(org.knime.base.node.preproc.groupby.BigGroupByTable) GroupByTable(org.knime.base.node.preproc.groupby.GroupByTable) BigGroupByTable(org.knime.base.node.preproc.groupby.BigGroupByTable) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) CountOperator(org.knime.base.data.aggregation.general.CountOperator)

Example 2 with CountOperator

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));
}
Also used : LastOperator(org.knime.base.data.aggregation.general.LastOperator) FirstOperator(org.knime.base.data.aggregation.general.FirstOperator) OrElementCountOperator(org.knime.base.data.aggregation.collection.OrElementCountOperator) MissingValueCountOperator(org.knime.base.data.aggregation.general.MissingValueCountOperator) TrueCountOperator(org.knime.base.data.aggregation.booleancell.TrueCountOperator) BitVectorSetCountOperator(org.knime.base.data.aggregation.bitvector.BitVectorSetCountOperator) ElementCountOperator(org.knime.base.data.aggregation.collection.ElementCountOperator) AndElementCountOperator(org.knime.base.data.aggregation.collection.AndElementCountOperator) XORElementCountOperator(org.knime.base.data.aggregation.collection.XORElementCountOperator) FalseCountOperator(org.knime.base.data.aggregation.booleancell.FalseCountOperator) UniqueConcatenateWithCountOperator(org.knime.base.data.aggregation.general.UniqueConcatenateWithCountOperator) CountOperator(org.knime.base.data.aggregation.general.CountOperator) BitVectorNotSetCountOperator(org.knime.base.data.aggregation.bitvector.BitVectorNotSetCountOperator) OrElementCountOperator(org.knime.base.data.aggregation.collection.OrElementCountOperator) UniqueCountOperator(org.knime.base.data.aggregation.general.UniqueCountOperator)

Aggregations

CountOperator (org.knime.base.data.aggregation.general.CountOperator)2 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)1 GlobalSettings (org.knime.base.data.aggregation.GlobalSettings)1 OperatorColumnSettings (org.knime.base.data.aggregation.OperatorColumnSettings)1 BitVectorNotSetCountOperator (org.knime.base.data.aggregation.bitvector.BitVectorNotSetCountOperator)1 BitVectorSetCountOperator (org.knime.base.data.aggregation.bitvector.BitVectorSetCountOperator)1 FalseCountOperator (org.knime.base.data.aggregation.booleancell.FalseCountOperator)1 TrueCountOperator (org.knime.base.data.aggregation.booleancell.TrueCountOperator)1 AndElementCountOperator (org.knime.base.data.aggregation.collection.AndElementCountOperator)1 ElementCountOperator (org.knime.base.data.aggregation.collection.ElementCountOperator)1 OrElementCountOperator (org.knime.base.data.aggregation.collection.OrElementCountOperator)1 XORElementCountOperator (org.knime.base.data.aggregation.collection.XORElementCountOperator)1 FirstOperator (org.knime.base.data.aggregation.general.FirstOperator)1 LastOperator (org.knime.base.data.aggregation.general.LastOperator)1 MissingValueCountOperator (org.knime.base.data.aggregation.general.MissingValueCountOperator)1 UniqueConcatenateWithCountOperator (org.knime.base.data.aggregation.general.UniqueConcatenateWithCountOperator)1 UniqueCountOperator (org.knime.base.data.aggregation.general.UniqueCountOperator)1 BigGroupByTable (org.knime.base.node.preproc.groupby.BigGroupByTable)1 ColumnNamePolicy (org.knime.base.node.preproc.groupby.ColumnNamePolicy)1 GroupByTable (org.knime.base.node.preproc.groupby.GroupByTable)1