This method will get called for all the records which need to be
> aggregated. RecordValuesContext will contain the record values of the
> current record being processed. aggregateFields will contain an array of
> fields which will be used for the aggregation. The order of the
> aggregateFields will matter when we implement the logic. For example, lets
> say we are going to implement SUM aggregate. Then we know that only one
> field will be required to calculate SUM and always aggregateFields will
> contain one field name in it, which is the name of the field being SUMed.
>
> public void process(RecordValuesContext ctx, String[] aggregateFields)
> throws AnalyticsException {
> if (aggregateFields == null || aggregateFields.length == 0) {
> throw new AnalyticsException("Field to be aggregated, is
> missing");
> }
> Object value = ctx.getValue(aggregateFields[0]);
> if (value == null) {
> throw new AnalyticsException("Error while calculating SUM:
> value of the field, " +
> aggregateFields[0] + " is null");
> }
> if (value instanceof Number) {
> sum += ((Number)value).doubleValue();
> } else {
> throw new AnalyticsException("Error while calculating Average:
> Value '" + value.toString() +
> "', being aggregated is not
> numeric.");
> }
> }
>
>
>
Hi Gimantha
Is aggregateFields parameter a constant for an AggregateFunction object? In
that case, can we set it just after instantiating an object?
Regards,
Chathura
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture