You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by db...@apache.org on 2016/11/23 23:25:26 UTC

cassandra git commit: Fixing double division and rounding.

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 9cd7d540d -> 801c1a594


Fixing double division and rounding.

Patch by Per Otterstrom; reviewed by dbrosius for CASSANDRA-11752


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/801c1a59
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/801c1a59
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/801c1a59

Branch: refs/heads/cassandra-2.2
Commit: 801c1a5942dc986dc3b63aa35416d586df5cf225
Parents: 9cd7d54
Author: Per Otterstrom <pe...@ericsson.com>
Authored: Tue Aug 30 22:33:49 2016 -0400
Committer: Dave Brosius <db...@mebigfatguy.com>
Committed: Wed Nov 23 18:25:08 2016 -0500

----------------------------------------------------------------------
 .../metrics/DecayingEstimatedHistogramReservoir.java         | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/801c1a59/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java b/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java
index 14a4366..2458164 100644
--- a/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java
+++ b/src/java/org/apache/cassandra/metrics/DecayingEstimatedHistogramReservoir.java
@@ -179,7 +179,7 @@ public class DecayingEstimatedHistogramReservoir implements Reservoir
 
         try
         {
-            decayingBuckets.getAndAdd(index, forwardDecayWeight(now));
+            decayingBuckets.getAndAdd(index, Math.round(forwardDecayWeight(now)));
         }
         finally
         {
@@ -189,9 +189,9 @@ public class DecayingEstimatedHistogramReservoir implements Reservoir
         buckets.getAndIncrement(index);
     }
 
-    private long forwardDecayWeight(long now)
+    private double forwardDecayWeight(long now)
     {
-        return Math.round(Math.exp(((now - decayLandmark) / 1000L) / MEAN_LIFETIME_IN_S));
+        return Math.exp(((now - decayLandmark) / 1000L) / MEAN_LIFETIME_IN_S);
     }
 
     /**
@@ -270,7 +270,7 @@ public class DecayingEstimatedHistogramReservoir implements Reservoir
 
             try
             {
-                final long rescaleFactor = forwardDecayWeight(now);
+                final double rescaleFactor = forwardDecayWeight(now);
                 decayLandmark = now;
 
                 final int bucketCount = decayingBuckets.length();