Hi Pradeep,

Adding dev@apex.

In an operator defines these Metrics
1. total tuples
2. special tuples

The percentage metric aggregator can be written like this

public class PercentageAggregator implements AutoMetric.Aggregator
{

  @Override
  public Map<String, Object> aggregate(long l,
Collection<AutoMetric.PhysicalMetricsContext> collection)
  {
    long total = 0;
    long special = 0;
    for (AutoMetric.PhysicalMetricsContext context : collection) {
      total += (Long)context.getMetrics().get("total");
      special += (Long)context.getMetrics().get("special");
    }

    Map<String, Object> result = Maps.newHashMap();
    result.put("specials_percent", (special / (total * 1.0)) * 100);
    return result;
  }
}

Chandni




On Wed, Dec 30, 2015 at 9:16 PM, Pradeep Dalvi <
[email protected]> wrote:

> Has anyone used or have an idea about percentage aggregator of autometrics?
> Any pointer would be useful.
>
> Thanks,
> Pradeep A. Dalvi
>
>
> --
> Pradeep A. Dalvi
>
> Software Engineer
> DataTorrent (India)
>
>

Reply via email to