@Override
    public List<Metric> transform(QueryContext context, List<Metric> metrics) {
        SystemAssert.requireArgument(metrics != null, "Cannot transform empty metric/metrics");
        if (metrics.isEmpty()) {
            return metrics;
        }

        // do a union transform, the reducer perform a sum calculation
        Transform unionTransform = new MetricUnionTransform(new CountValueUnionReducer());
        List<Metric> sumUnitMetric = unionTransform.transform(null, metrics);

        // union of all timestamp
        Set<Long> unionKeyset = sumUnitMetric.get(0).getDatapoints().keySet();

        // create a list of metrics, for every metric it has union of all timestamps
        List<Metric> paddingMetrics = new ArrayList<Metric>();

        // Padding Zeros for every datapoints map in every metric
        for (Metric metric : metrics) {
            Map<Long, Double> paddingDatapoints = new TreeMap<>();
            Set<Long> metricDPKeyset = metric.getDatapoints().keySet();

            // Calculate those timestamps this datapoint map doesn't have
            for (Long unionKey : unionKeyset) {
                if (!metricDPKeyset.contains(unionKey)) {
                    paddingDatapoints.put(unionKey, 0.0);
                }
            }

            // create paddingDatapoints
            paddingDatapoints.putAll(metric.getDatapoints());
            metric.setDatapoints(paddingDatapoints);
            paddingMetrics.add(metric);
        }

        // adding base metric
        paddingMetrics.add(sumUnitMetric.get(0));

        // do a divide_v transform
        // Transform divide_vTransform = transformFactory.createMetricZipperTransform(Function.DIVIDE_V);
        Transform divide_vTransform = new MetricZipperTransform(new DivideValueZipper());

        return divide_vTransform.transform(null, paddingMetrics);
    }
@ Override public List < Metric > transform ( QueryContext context , List < Metric > metrics ) { SystemAssert . requireArgument ( metrics != null , "Cannot transform empty metric/metrics" ) ; if ( metrics . isEmpty ( ) ) { return metrics ; } Transform unionTransform = new MetricUnionTransform ( new CountValueUnionReducer ( ) ) ; List < Metric > sumUnitMetric = unionTransform . transform ( null , metrics ) ; Set < Long > unionKeyset = sumUnitMetric . get ( 0 ) . getDatapoints ( ) . keySet ( ) ; List < Metric > paddingMetrics = new ArrayList < Metric > ( ) ; for ( Metric metric : metrics ) { Map < Long , Double > paddingDatapoints = new TreeMap < > ( ) ; Set < Long > metricDPKeyset = metric . getDatapoints ( ) . keySet ( ) ; for ( Long unionKey : unionKeyset ) { if ( ! metricDPKeyset . contains ( unionKey ) ) { paddingDatapoints . put ( unionKey , 0.0 ) ; } } paddingDatapoints . putAll ( metric . getDatapoints ( ) ) ; metric . setDatapoints ( paddingDatapoints ) ; paddingMetrics . add ( metric ) ; } paddingMetrics . add ( sumUnitMetric . get ( 0 ) ) ; Transform divide_vTransform = new MetricZipperTransform ( new DivideValueZipper ( ) ) ; return divide_vTransform . transform ( null , paddingMetrics ) ; }
~ Methods **************************************************************************************************************************************