Follow up issue for #138639 (comment).
For the implementation of first_over_time and last_over_time, we need to keep track of the currently "best" exponential_histogram. This is at the moment done by naively copying the histogram, causing both an allocation and a decoding of the histogram stored in the block.
We should optimize this by introducing something similar to a BreakingBytesRefBuilder, e.g. a resuable EncodedHistogramHolder:
- It should internally use a
BreakingBytesRefBuilder to store the histogram bytes and be reusable
- It should be populateable from an
ExponentialHistogram returned from a block without decoding: It should "see through" e.g. the CompressedHistogram´ and directly access and copy the underlying bytes[]`
- It should be addable to an
ExponentialHistogramBlockBuilder without requiring an encoding: The data should be directly copied instead