org.knime.base.data.aggregation
Class AggregationOperator

java.lang.Object
  extended by org.knime.base.data.aggregation.AggregationOperator
All Implemented Interfaces:
Comparable<AggregationMethod>, AggregationMethod
Direct Known Subclasses:
AndElementOperator, ConcatenateOperator, ConcatenateOperator, CountOperator, DateMeanOperator, ElementCountOperator, FalseCountOperator, FirstOperator, GeometricMeanOperator, LastOperator, ListCellOperator, MaxOperator, MeanOperator, MedianDateOperator, MillisRangeOperator, MinOperator, MissingValueCountOperator, ModeOperator, OrElementOperator, ProductOperator, RangeOperator, SetCellOperator, SumOperator, SumOperator, TrueCountOperator, UniqueConcatenateOperator, UniqueConcatenateWithCountOperator, UniqueConcatenateWithCountOperator, VarianceOperator, XORElementOperator

public abstract class AggregationOperator
extends Object
implements AggregationMethod

Abstract class which has to be extended by all aggregation method operators that can be registered using the AggregationOperator extension point. The extending classes have to provide an empty constructor that can call the AggregationOperator(OperatorData) constructor with the operator specific OperatorData implementation. The OperatorData class holds all operator specific information such as the name of the operator and if the operator supports missing values. The GlobalSettings class holds global informations such as the column delimiter to use or the maximum number of unique values per group. Implementations can use the GlobalSettings.DEFAULT object in the constructor which is a dummy object which gets replaced when the operator is created using the createInstance(GlobalSettings, OperatorColumnSettings) method. The OperatorColumnSettings contain column specific information for the operator such as the DataColumnSpec of the column and if missing values should be considered when aggregating the column. The class also provides two default instances OperatorColumnSettings.DEFAULT_INCL_MISSING and OperatorColumnSettings.DEFAULT_EXCL_MISSING which can be used in the constructor. These get like the GlobalSettings replaced by the actual settings from the node dialog in the createInstance(GlobalSettings, OperatorColumnSettings) method. All registered classes can be used in the nodes that use the aggregation operators such as the group by or pivoting node. AggregationMethods are sorted first by the supported data type and then by the label.

Author:
Tobias Koetter, University of Konstanz
See Also:
OperatorData, GlobalSettings, OperatorColumnSettings

Constructor Summary
AggregationOperator(OperatorData operatorData)
          Constructor for class AggregationOperator.
AggregationOperator(OperatorData operatorData, GlobalSettings globalSettings, OperatorColumnSettings opColSettings)
          Constructor for class AggregationOperator.
 
Method Summary
 int compareTo(AggregationMethod o)
          
 void compute(DataCell cell)
           
protected abstract  boolean computeInternal(DataCell cell)
           
 DataColumnSpec createColumnSpec(String colName, DataColumnSpec origSpec)
          
abstract  AggregationOperator createInstance(GlobalSettings globalSettings, OperatorColumnSettings opColSettings)
          Creates a new instance of this operator.
 AggregationOperator createOperator(GlobalSettings globalSettings, OperatorColumnSettings opColSettings)
          Creates a new instance of this operator and returns it.
 String getColumnLabel()
          
protected abstract  DataType getDataType(DataType origType)
           
 GlobalSettings getGlobalSettings()
           
 String getId()
          The unique identifier of the method that is used for registration and identification of the aggregation method.
 String getLabel()
          
 int getMaxUniqueValues()
           
 OperatorData getOperatorData()
           
 DataCell getResult()
           
protected abstract  DataCell getResultInternal()
           
 String getSkipMessage()
           
 Class<? extends DataValue> getSupportedType()
          
 String getSupportedTypeLabel()
          
 String getValueDelimiter()
           
 boolean inclMissingCells()
          
 boolean isCompatible(DataColumnSpec origColSpec)
          
 boolean isCompatible(DataType type)
           
 boolean isSkipped()
           
 boolean isUsesLimit()
           
 boolean keepColumnSpec()
           
 void reset()
          Should reset the operator to the start values.
protected abstract  void resetInternal()
          Should reset the operator to the start values.
(package private)  void setInclMissing(boolean inclMissingCells)
           
protected  void setSkipMessage(String msg)
           
protected  void setSkipped(boolean skipped)
          This method can be used to mark this group explicitly as skipped.
 boolean supportsMissingValueOption()
          
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.knime.base.data.aggregation.AggregationMethod
getDescription
 

Constructor Detail

AggregationOperator

public AggregationOperator(OperatorData operatorData)
Constructor for class AggregationOperator. Uses GlobalSettings.DEFAULT and OperatorColumnSettings.DEFAULT_INCL_MISSING and calls the AggregationOperator(OperatorData, GlobalSettings, OperatorColumnSettings) constructor.

Parameters:
operatorData - the operator specific data

AggregationOperator

public AggregationOperator(OperatorData operatorData,
                           GlobalSettings globalSettings,
                           OperatorColumnSettings opColSettings)
Constructor for class AggregationOperator.

Parameters:
operatorData - the operator specific data
globalSettings - the global settings
opColSettings - the operator column specific settings
Method Detail

createInstance

public abstract AggregationOperator createInstance(GlobalSettings globalSettings,
                                                   OperatorColumnSettings opColSettings)
Creates a new instance of this operator. A new instance is created for each column.

Parameters:
globalSettings - the global settings
opColSettings - the operator column specific settings
Returns:
a new instance of this operator

getOperatorData

public OperatorData getOperatorData()
Returns:
the OperatorData of this operator

getSupportedType

public Class<? extends DataValue> getSupportedType()

Specified by:
getSupportedType in interface AggregationMethod
Returns:
the supported DataValue class

getSupportedTypeLabel

public String getSupportedTypeLabel()

Specified by:
getSupportedTypeLabel in interface AggregationMethod
Returns:
the user friendly label of the supported DataValue class

getMaxUniqueValues

public int getMaxUniqueValues()
Returns:
the maxUniqueValues

getValueDelimiter

public String getValueDelimiter()
Returns:
the standard delimiter to use for value separation

getGlobalSettings

public GlobalSettings getGlobalSettings()
Returns:
the GlobalSettings object

supportsMissingValueOption

public boolean supportsMissingValueOption()

Specified by:
supportsMissingValueOption in interface AggregationMethod
Returns:
true if the operator supports the alteration of the missing cell option

setInclMissing

void setInclMissing(boolean inclMissingCells)
Parameters:
inclMissingCells - true if missing cells should be considered during aggregation

inclMissingCells

public boolean inclMissingCells()

Specified by:
inclMissingCells in interface AggregationMethod
Returns:
true if missing cells are considered during aggregation

isSkipped

public boolean isSkipped()
Returns:
true if this operator was skipped
See Also:
getSkipMessage()

setSkipped

protected void setSkipped(boolean skipped)
This method can be used to mark this group explicitly as skipped.

Parameters:
skipped - true if the group should be marked as skipped
See Also:
setSkipMessage(String)

setSkipMessage

protected void setSkipMessage(String msg)
Parameters:
msg - the cause why the group was skipped
See Also:
setSkipped(boolean)

getSkipMessage

public String getSkipMessage()
Returns:
the cause why the group was skipped or an empty string
See Also:
isSkipped()

compute

public final void compute(DataCell cell)
Parameters:
cell - the DataCell to consider during computing

keepColumnSpec

public boolean keepColumnSpec()
Returns:
true if the original DataColumnSpec should be kept.

computeInternal

protected abstract boolean computeInternal(DataCell cell)
Parameters:
cell - the DataCell to consider during computing the cell can't be null but can be a missing cell DataCell.isMissing() if the option is inclMissingCells() option is set to true.
Returns:
true if this column should be skipped in further calculations

createColumnSpec

public DataColumnSpec createColumnSpec(String colName,
                                       DataColumnSpec origSpec)

Specified by:
createColumnSpec in interface AggregationMethod
Parameters:
colName - the unique name of the column
origSpec - the original DataColumnSpec
Returns:
the new DataColumnSpecCreator for the aggregated column

getDataType

protected abstract DataType getDataType(DataType origType)
Parameters:
origType - the DataType of the original column to aggregate
Returns:
the DataType of the aggregation result

getResult

public final DataCell getResult()
Returns:
the result DataCell

getResultInternal

protected abstract DataCell getResultInternal()
Returns:
the result DataCell

reset

public final void reset()
Should reset the operator to the start values.


resetInternal

protected abstract void resetInternal()
Should reset the operator to the start values.


getId

public String getId()
The unique identifier of the method that is used for registration and identification of the aggregation method. The id is an internal used variable that is not displayed to the user.

Specified by:
getId in interface AggregationMethod
Returns:
the unique id of the method that is used to register and identify the method.

getLabel

public String getLabel()

Specified by:
getLabel in interface AggregationMethod
Returns:
the label that is displayed to the user

getColumnLabel

public String getColumnLabel()

Specified by:
getColumnLabel in interface AggregationMethod
Returns:
the label of the aggregation method which is used in the column name

createOperator

public AggregationOperator createOperator(GlobalSettings globalSettings,
                                          OperatorColumnSettings opColSettings)
Creates a new instance of this operator and returns it. A new instance must be created for each column.

Specified by:
createOperator in interface AggregationMethod
Parameters:
globalSettings - the global settings
opColSettings - the operator column specific settings
Returns:
a new instance of this operator

isCompatible

public boolean isCompatible(DataColumnSpec origColSpec)

Specified by:
isCompatible in interface AggregationMethod
Parameters:
origColSpec - the DataColumnSpec of the column to check for compatibility
Returns:
true if the aggregation method is compatible

isCompatible

public boolean isCompatible(DataType type)
Parameters:
type - the DataType to check for compatibility
Returns:
true if this method supports the given DataType

isUsesLimit

public boolean isUsesLimit()
Returns:
true if this method checks the maximum unique values limit.

compareTo

public int compareTo(AggregationMethod o)

Specified by:
compareTo in interface Comparable<AggregationMethod>

toString

public String toString()

Overrides:
toString in class Object


Copyright, 2003 - 2012. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.