code: public byte[] toBytesSparse(int nonEmptyBuckets)
    {
      int size = SERDE_HEADER_SIZE + getSparseStorageSize(nonEmptyBuckets);
      ByteBuffer buf = ByteBuffer.allocate(size);
      writeByteBufferSparse(buf, nonEmptyBuckets);
      return buf.array();
    }
docs: Serialize the histogram in sparse encoding mode.
  
  The serialization header is always written, since the sparse encoding is only used in situations where the
  header is required.
  
  @param nonEmptyBuckets Number of non-empty buckets in the histogram
  @return Serialized histogram with sparse encoding