Example #1
0
 public void serialize(StreamingHistogram histogram, DataOutput dos) throws IOException {
   dos.writeInt(histogram.maxBinSize);
   Map<Double, Long> entries = histogram.getAsMap();
   dos.writeInt(entries.size());
   for (Map.Entry<Double, Long> entry : entries.entrySet()) {
     dos.writeDouble(entry.getKey());
     dos.writeLong(entry.getValue());
   }
 }
Example #2
0
  /**
   * Merges given histogram with this histogram.
   *
   * @param other histogram to merge
   */
  public void merge(StreamingHistogram other) {
    if (other == null) return;

    for (Map.Entry<Double, Long> entry : other.getAsMap().entrySet())
      update(entry.getKey(), entry.getValue());
  }