cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r989352 - in /cassandra/trunk: CHANGES.txt src/java/org/apache/cassandra/io/sstable/SSTable.java src/java/org/apache/cassandra/utils/EstimatedHistogram.java test/unit/org/apache/cassandra/utils/EstimatedHistogramTest.java
Date Wed, 25 Aug 2010 20:35:15 GMT
Author: jbellis
Date: Wed Aug 25 20:35:15 2010
New Revision: 989352

URL: http://svn.apache.org/viewvc?rev=989352&view=rev
Log:
fix EH.max.  patch by jbellis and brandonwilliams for CASSANDRA-1413

Modified:
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java
    cassandra/trunk/test/unit/org/apache/cassandra/utils/EstimatedHistogramTest.java

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=989352&r1=989351&r2=989352&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Wed Aug 25 20:35:15 2010
@@ -35,6 +35,7 @@ dev
  * fix using DynamicEndpointSnitch with NetworkTopologyStrategy
    (CASSANDRA-1429)
  * Add CfDef.default_validation_class (CASSANDRA-891)
+ * fix EstimatedHistogram.max (CASSANDRA-1413)
 
 
 0.7-beta1

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java?rev=989352&r1=989351&r2=989352&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTable.java Wed Aug 25 20:35:15
2010
@@ -64,8 +64,8 @@ public abstract class SSTable
     public static final String TEMPFILE_MARKER = "tmp";
 
     public static List<String> components = Collections.unmodifiableList(Arrays.asList(COMPONENT_FILTER,
COMPONENT_INDEX, COMPONENT_DATA));
-    protected EstimatedHistogram estimatedRowSize = new EstimatedHistogram(130);
-    protected EstimatedHistogram estimatedColumnCount = new EstimatedHistogram(112);
+    protected EstimatedHistogram estimatedRowSize = new EstimatedHistogram(150);
+    protected EstimatedHistogram estimatedColumnCount = new EstimatedHistogram(114);
 
     protected SSTable(String filename, CFMetaData metadata, IPartitioner partitioner)
     {

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java?rev=989352&r1=989351&r2=989352&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java Wed Aug 25
20:35:15 2010
@@ -40,8 +40,7 @@ public class EstimatedHistogram
 
     public EstimatedHistogram()
     {
-        makeOffsets(90);
-        buckets = new AtomicLongArray(numBuckets);
+        this(90);
     }
 
     public EstimatedHistogram(int bucketCount)
@@ -118,10 +117,14 @@ public class EstimatedHistogram
 
     public long max()
     {
-        for (int i = numBuckets - 1; i >= 0; i--)
+        int lastBucket = numBuckets - 1;
+        if (buckets.get(lastBucket) > 0)
+            throw new IllegalStateException("Unable to compute ceiling for max when all buckets
are full");
+
+        for (int i = lastBucket - 1; i >= 0; i--)
         {
             if (buckets.get(i) > 0)
-                return bucketOffsets[i == 0 ? 0 : i - 1];
+                return bucketOffsets[i];
         }
         return 0;
     }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/utils/EstimatedHistogramTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/utils/EstimatedHistogramTest.java?rev=989352&r1=989351&r2=989352&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/utils/EstimatedHistogramTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/utils/EstimatedHistogramTest.java Wed Aug
25 20:35:15 2010
@@ -33,8 +33,8 @@ public class EstimatedHistogramTest
         histogram.add(0L);
         assertEquals(1, histogram.get(false)[0]);
 
-        histogram.add(33282687);
-        assertEquals(1, histogram.get(false)[histogram.buckets.length()-1]);
+        histogram.add(23282687);
+        assertEquals(1, histogram.get(false)[histogram.buckets.length() - 2]);
 
         histogram.add(1);
         assertEquals(1, histogram.get(false)[1]);



Mime
View raw message