datafu-pig/src/main/java/datafu/pig/stats/FloatVAR.java [193:235]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    static protected Tuple combine(DataBag values) throws ExecException{
        double sum = 0;
        double sumSquare = 0;
        long totalCount = 0;

        // combine is called from Intermediate and Final
        // In either case, Initial would have been called
        // before and would have sent in valid tuples
        // Hence we don't need to check if incoming bag
        // is empty

        Tuple output = mTupleFactory.newTuple(3);
        boolean sawNonNull = false;
        for (Iterator<Tuple> it = values.iterator(); it.hasNext();) {
            Tuple t = it.next();
            Double d = (Double)t.get(0);
            Double dSquare = (Double)t.get(1);
            Long count = (Long)t.get(2);
            
            // we count nulls in var as contributing 0
            // a departure from SQL for performance of
            // COUNT() which implemented by just inspecting
            // size of the bag
            if(d == null) {
                d = 0.0;
                dSquare = 0.0;
            } else {
                sawNonNull = true;
            }
            sum += d;
            sumSquare += dSquare;
            totalCount += count;
        }
        if(sawNonNull) {
            output.set(0, new Double(sum));
            output.set(1, new Double(sumSquare));
        } else {
            output.set(0, null);
            output.set(1, null);
        }
        output.set(2, Long.valueOf(totalCount));
        return output;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



datafu-pig/src/main/java/datafu/pig/stats/DoubleVAR.java [191:233]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    static protected Tuple combine(DataBag values) throws ExecException{
        double sum = 0;
        double sumSquare = 0;
        long totalCount = 0;

        // combine is called from Intermediate and Final
        // In either case, Initial would have been called
        // before and would have sent in valid tuples
        // Hence we don't need to check if incoming bag
        // is empty

        Tuple output = mTupleFactory.newTuple(3);
        boolean sawNonNull = false;
        for (Iterator<Tuple> it = values.iterator(); it.hasNext();) {
            Tuple t = it.next();
            Double d = (Double)t.get(0);
            Double dSquare = (Double)t.get(1);
            Long count = (Long)t.get(2);
            
            // we count nulls in var as contributing 0
            // a departure from SQL for performance of
            // COUNT() which implemented by just inspecting
            // size of the bag
            if(d == null) {
                d = 0.0;
                dSquare = 0.0;
            } else {
                sawNonNull = true;
            }
            sum += d;
            sumSquare += dSquare;
            totalCount += count;
        }
        if(sawNonNull) {
            output.set(0, new Double(sum));
            output.set(1, new Double(sumSquare));
        } else {
            output.set(0, null);
            output.set(1, null);
        }
        output.set(2, Long.valueOf(totalCount));
        return output;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



