public ArrayList<DoubleWritable> serialize() {
    ArrayList<DoubleWritable> result = new ArrayList<DoubleWritable>();

    // Return a single ArrayList where the first element is the number of bins bins,
    // and subsequent elements represent bins (x,y) pairs.
    result.add(new DoubleWritable(nbins));
    if(bins != null) {
      for(int i = 0; i < nusedbins; i++) {
        result.add(new DoubleWritable(bins.get(i).x));
        result.add(new DoubleWritable(bins.get(i).y));
      }
    }

    return result;
  }
In preparation for a Hive merge() call, serializes the current histogram object into an
ArrayList of DoubleWritable objects. This list is deserialized and merged by the
merge method.

@return An ArrayList of Hadoop DoubleWritable objects that represents the current
histogram.
@see #merge
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/NumericHistogram.java