Skip to content

Commit 0f845dd

Browse files
Apply suggestions from code review
Co-authored-by: Felix Barnsteiner <[email protected]>
1 parent 4096604 commit 0f845dd

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

x-pack/plugin/mapper-exponential-histogram/src/main/java/org/elasticsearch/xpack/exponentialhistogram/EncodedHistogramData.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ final class EncodedHistogramData {
4343
- if there are no buckets, the result is an empty array (byte[0])
4444
- write the index of the first bucket as ZigZag-VLong
4545
- write the count of the first bucket as ZigZag-VLong
46-
- for each remaining bucket:
47-
- if the index of the bucket is exactly previousBucketIndex+1, write the count for the bucket as ZigZag-VLong
46+
- for each remaining (non-empty) bucket:
47+
- if there was no empty bucket right before this bucket (the index of the bucket is exactly previousBucketIndex+1), write the count for the bucket as ZigZag-VLong
4848
- Otherwise there is at least one empty bucket between this one and the previous one.
49-
We compute that number as n=currentBucketIndex-previousIndex-1 and then write -n out as
49+
We compute the number of empty buckets as n=currentBucketIndex-previousIndex-1 and then write -n out as
5050
ZigZag-VLong followed by the count for the bucket as ZigZag-VLong. The negation is performed to allow to
51-
distinguish the cases when decoding.
51+
distinguish whether a value represents a bucket count (positive number) or the number of empty buckets (negative number) when decoding.
5252
5353
While this encoding is designed for sparse histograms, it compresses well for dense histograms too.
5454
For fully dense histograms it effectively results in encoding the index of the first bucket, followed by just an array of counts.
5555
For sparse histograms it corresponds to an interleaved encoding of the bucket indices with delta compression and the bucket counts.
56-
Even partially dense histograms profit from this encoding.
56+
Even mostly sparse histograms that have some dense regions profit from this encoding.
5757
*/
5858

5959
static final long SHALLOW_SIZE = RamUsageEstimator.shallowSizeOfInstance(EncodedHistogramData.class);

x-pack/plugin/mapper-exponential-histogram/src/main/java/org/elasticsearch/xpack/exponentialhistogram/ExponentialHistogramFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static String zeroThresholdSubFieldName(String fullPath) {
125125
* This is done to allow access to it at query time without having to load the entire histogram.
126126
*
127127
* As a side effect, this is used to avoid storing the count for the zero bucket with the histogram data,
128-
* is it can be computed from this value minus the sum of the counts of all other buckets.
128+
* as it can be computed from this value minus the sum of the counts of all other buckets.
129129
*
130130
* @param fullPath the full path of the mapped field
131131
* @return the name for the lucene field

0 commit comments

Comments
 (0)