EstimatedHistogram: Add constructor from data

This patch allows to create an EstimatedHistogram from an array of data
value.

It will be used by the APIClient to return EstimatedHistogram

Signed-off-by: Amnon Heiman <amnon@cloudius-systems.com>
This commit is contained in:
Amnon Heiman 2015-10-21 11:34:15 +03:00
parent a568e52cb5
commit 931571c3ed
1 changed files with 6 additions and 0 deletions

View File

@ -67,6 +67,12 @@ public class EstimatedHistogram {
buckets = new AtomicLongArray(bucketData);
}
public EstimatedHistogram(long[] bucketData) {
bucketOffsets = newOffsets(bucketData.length - 1);
buckets = new AtomicLongArray(bucketData);
}
private static long[] newOffsets(int size) {
long[] result = new long[size];
long last = 1;