Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public CKMSQuantiles(Quantile[] quantiles) {
*
* @param value
*/
public synchronized void insert(double value) {
public void insert(double value) {
buffer[bufferCount] = value;
bufferCount++;

Expand All @@ -104,7 +104,7 @@ public synchronized void insert(double value) {
* Queried quantile, e.g. 0.50 or 0.99.
* @return Estimated value at that quantile.
*/
public synchronized double get(double q) {
public double get(double q) {
// clear the buffer
insertBatch();
compress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ public TimeWindowQuantiles(Quantile[] quantiles, long maxAgeSeconds, int ageBuck
this.durationBetweenRotatesMillis = TimeUnit.SECONDS.toMillis(maxAgeSeconds) / ageBuckets;
}

public double get(double q) {
public synchronized double get(double q) {
CKMSQuantiles currentBucket = rotate();
return currentBucket.get(q);
}

public void insert(double value) {
public synchronized void insert(double value) {
rotate();
for (CKMSQuantiles ckmsQuantiles : ringBuffer) {
ckmsQuantiles.insert(value);
}
}

private synchronized CKMSQuantiles rotate() {
private CKMSQuantiles rotate() {
long timeSinceLastRotateMillis = System.currentTimeMillis() - lastRotateTimestampMillis;
while (timeSinceLastRotateMillis > durationBetweenRotatesMillis) {
ringBuffer[currentBucket] = new CKMSQuantiles(quantiles);
Expand Down