Package com.nt.udc.aggregator.util
Class AggrCalcFields
java.lang.Object
com.nt.udc.aggregator.AggregatorModule
com.nt.udc.aggregator.util.AggrCalcFields
This class contains all basic aggregator calculation operations.
Currently, the following calculations are supported:
- sum of two fields
- max of two fields
- keep of a field
- growlist of a field
See the appropriate method comments for more details.
-
Field Summary
Fields inherited from class com.nt.udc.aggregator.AggregatorModule
config, logger
-
Constructor Summary
ConstructorsConstructorDescriptionAggrCalcFields
(ConfigIfc config, LoggerIfc logger) Creates an object to handle calculated aggregation fields. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addKeepFields
(int[] fields) Adds more fields that need to be kept at "keep" time.void
calc_growlist
(NAR newRecord, NAR updatedRecord) Appends the values of the new record's List field with the existing list of the updated record.void
Keeps the specified fields from the new record in the updated record.void
Compares the fields in the new record and the updated record, and keep the greater value in the updated record.void
calc_strconcat
(NAR newRecord, NAR updatedRecord) Concatenate the String fields in two records according to the settings of "strconcat", and store the result in the updated record.void
Sum the fields in two records according to the settings of "sum", and store the result in the updated record.protected void
This method should obtain the necessary information from the config class, in order to configure the module.boolean
isSumOverflow
(NAR newRecord, NAR oldRecord) Determines whether there would be overflow when summing the fields of the new record into the fields of the old record.int[]
Returns the fields that should be stored in a newly created record entry.void
shutdown()
This method should handle shutting down the routines that have been started by this class.
-
Constructor Details
-
AggrCalcFields
Creates an object to handle calculated aggregation fields.
-
-
Method Details
-
getConfigData
protected void getConfigData()Description copied from class:AggregatorModule
This method should obtain the necessary information from the config class, in order to configure the module.- Specified by:
getConfigData
in classAggregatorModule
-
recordInitFields
public int[] recordInitFields()Returns the fields that should be stored in a newly created record entry. The fields returned are those that this object uses/knows about.- Specified by:
recordInitFields
in classAggregatorModule
- Returns:
- Array of integers, representing the fields to initialize.
-
addKeepFields
public void addKeepFields(int[] fields) Adds more fields that need to be kept at "keep" time. Basically, this method should be used for the implied "keep" fields, so that the user doesn't have to specify the whole record in the rules file. This should only need to be called once.- Parameters:
fields
- Int array of field ID's to keep.
-
calc_keep
Keeps the specified fields from the new record in the updated record. Note that this will overwrite any existing fields in the updated record. The fields need to be specified by the "keep" configuration file setting. This calculation works on all field types.- Parameters:
newRecord
- incoming recordupdatedRecord
- updated record, from the table
-
calc_sum
Sum the fields in two records according to the settings of "sum", and store the result in the updated record. This calculation supports fields of the following types: - byte - short - integer - long Note that there is the possibility of summation overflow. This means that the resulting field cannot store the value of the new field and the existing field because of the data type limitiations. For example: int i = Integer.MAX_VALUE + 1; is an invalid statement. In this case, the method throws an ArithmeticException. If this exception is thrown, the new and updated records will not have been modified.- Parameters:
newRecord
- Record containing the new valuesupdatedRecord
- Record to contain the updated values- Throws:
ArithmeticException
-
calc_max
Compares the fields in the new record and the updated record, and keep the greater value in the updated record. This calculation is applied to those fields set in the "max" configuration file setting. This calculation supports fields of the following types: - byte - short - integer - long- Parameters:
newRecord
- incoming recordupdatedRecord
- updated record, from the record table
-
calc_growlist
Appends the values of the new record's List field with the existing list of the updated record. The lists used are those set in the "growlist" configuration setting. This calculation supports fields of the following types: - ListField- Parameters:
newRecord
- incoming recordupdatedRecord
- updated record, from the record table
-
calc_strconcat
Concatenate the String fields in two records according to the settings of "strconcat", and store the result in the updated record. This calculation supports fields of the following types: - String- Parameters:
newRecord
- Record containing the new valuesupdatedRecord
- Record to contain the updated values
-
isSumOverflow
Determines whether there would be overflow when summing the fields of the new record into the fields of the old record.- Parameters:
newRecord
- Incoming recordoldRecord
- Record that exists in the table- Returns:
- true, if there is overflow.
-
shutdown
public void shutdown()Description copied from class:AggregatorModule
This method should handle shutting down the routines that have been started by this class.- Specified by:
shutdown
in classAggregatorModule
-