public void merge(List other, DoubleObjectInspector doi) {
    if(other == null) {
      return;
    }

    if(nbins == 0 || nusedbins == 0)  {
      // Our aggregation buffer has nothing in it, so just copy over 'other'
      // by deserializing the ArrayList of (x,y) pairs into an array of Coord objects
      nbins = (int) doi.get(other.get(0));
      nusedbins = (other.size()-1)/2;
      bins = new ArrayList<Coord>(nusedbins);
      for (int i = 1; i < other.size(); i+=2) {
        Coord bin = new Coord();
        bin.x = doi.get(other.get(i));
        bin.y = doi.get(other.get(i+1));
        bins.add(bin);
      }
    } else {
      // The aggregation buffer already contains a partial histogram. Therefore, we need
      // to merge histograms using Algorithm #2 from the Ben-Haim and Tom-Tov paper.

      ArrayList<Coord> tmp_bins = new ArrayList<Coord>(nusedbins + (other.size()-1)/2);
      // Copy all the histogram bins from us and 'other' into an overstuffed histogram
      for (int i = 0; i < nusedbins; i++) {
        Coord bin = new Coord();
        bin.x = bins.get(i).x;
        bin.y = bins.get(i).y;
        tmp_bins.add(bin);
      }
      for (int j = 1; j < other.size(); j += 2) {
        Coord bin = new Coord();
        bin.x = doi.get(other.get(j));
        bin.y = doi.get(other.get(j+1));
        tmp_bins.add(bin);
      }
      Collections.sort(tmp_bins);

      // Now trim the overstuffed histogram down to the correct number of bins
      bins = tmp_bins;
      nusedbins += (other.size()-1)/2;
      trim();
    }
  }
Takes a serialized histogram created by the serialize() method and merges
it with the current histogram object.

@param other A serialized histogram created by the serialize() method
@see #merge
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/NumericHistogram.java