cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [02/22] cassandra git commit: Fixing double division and rounding.
Date Mon, 28 Nov 2016 22:23:03 GMT
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-3.X
Commit: 801c1a5942dc986dc3b63aa35416d586df5cf225
Parents: 9cd7d54
Author: Per Otterstrom <per.otterstrom@ericsson.com>
Authored: Tue Aug 30 22:33:49 2016 -0400
Committer: Dave Brosius <dbrosius@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();


Mime
View raw message