Class AggrCalcFields

java.lang.Object
com.nt.udc.aggregator.AggregatorModule
com.nt.udc.aggregator.util.AggrCalcFields

public class AggrCalcFields extends AggregatorModule
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

    Constructors
    Constructor
    Description
    Creates an object to handle calculated aggregation fields.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    calc_keep(NAR newRecord, NAR updatedRecord)
    Keeps the specified fields from the new record in the updated record.
    void
    calc_max(NAR newRecord, NAR updatedRecord)
    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
    calc_sum(NAR newRecord, NAR updatedRecord)
    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
    This method should handle shutting down the routines that have been started by this class.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AggrCalcFields

      public AggrCalcFields(ConfigIfc config, LoggerIfc logger)
      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 class AggregatorModule
    • 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 class AggregatorModule
      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

      public void calc_keep(NAR newRecord, NAR updatedRecord)
      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 record
      updatedRecord - updated record, from the table
    • calc_sum

      public void calc_sum(NAR newRecord, NAR updatedRecord) throws ArithmeticException
      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 values
      updatedRecord - Record to contain the updated values
      Throws:
      ArithmeticException
    • calc_max

      public void calc_max(NAR newRecord, NAR updatedRecord)
      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 record
      updatedRecord - updated record, from the record table
    • calc_growlist

      public 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. The lists used are those set in the "growlist" configuration setting. This calculation supports fields of the following types: - ListField
      Parameters:
      newRecord - incoming record
      updatedRecord - updated record, from the record table
    • calc_strconcat

      public 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. This calculation supports fields of the following types: - String
      Parameters:
      newRecord - Record containing the new values
      updatedRecord - Record to contain the updated values
    • isSumOverflow

      public 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.
      Parameters:
      newRecord - Incoming record
      oldRecord - 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 class AggregatorModule