EstimatedHistogram: Support empty histogram
When creating an estimated histogram from buckets it is a valid option to get a zero size array as the buckets array. In that case the newOffsets method would get a negative value for its size, which should result in a zero length array of offsets. Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
parent
5362b2045d
commit
e0dea0c27e
@ -74,6 +74,9 @@ public class EstimatedHistogram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long[] newOffsets(int size) {
|
private static long[] newOffsets(int size) {
|
||||||
|
if (size <= 0) {
|
||||||
|
return new long[0];
|
||||||
|
}
|
||||||
long[] result = new long[size];
|
long[] result = new long[size];
|
||||||
long last = 1;
|
long last = 1;
|
||||||
result[0] = last;
|
result[0] = last;
|
||||||
|
Loading…
Reference in New Issue
Block a user