cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r923364 - in /cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db: ColumnFamilyStore.java ColumnFamilyStoreMBean.java CompactionManager.java
Date Mon, 15 Mar 2010 17:59:31 GMT
Author: jbellis
Date: Mon Mar 15 17:59:31 2010
New Revision: 923364

URL: http://svn.apache.org/viewvc?rev=923364&view=rev
Log:
Track row stats per CF at compaction time.  patch by Brandon Williams; reviewed by jbellis
for CASSANDRA-870

Modified:
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/CompactionManager.java

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=923364&r1=923363&r2=923364&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Mon Mar 15 17:59:31 2010
@@ -117,6 +117,11 @@ public class ColumnFamilyStore implement
 
     private LatencyTracker readStats_ = new LatencyTracker();
     private LatencyTracker writeStats_ = new LatencyTracker();
+
+    private long minRowCompactedSize = 0L;
+    private long maxRowCompactedSize = 0L;
+    private long rowsCompactedTotalSize = 0L;
+    private long rowsCompactedCount = 0L;
     
     ColumnFamilyStore(String table, String columnFamilyName, boolean isSuper, int indexValue)
throws IOException
     {
@@ -186,6 +191,34 @@ public class ColumnFamilyStore implement
         ssTables_.add(sstables);
     }
 
+    public void addToCompactedRowStats(Long rowsize)
+    {
+        if (minRowCompactedSize < 1 || rowsize < minRowCompactedSize)
+            minRowCompactedSize = rowsize;
+        if (rowsize > maxRowCompactedSize)
+            maxRowCompactedSize = rowsize;
+        rowsCompactedCount++;
+        rowsCompactedTotalSize += rowsize;
+    }
+
+    public long getMinRowCompactedSize()
+    {
+        return minRowCompactedSize;
+    }
+
+    public long getMaxRowCompactedSize()
+    {
+        return maxRowCompactedSize;
+    }
+
+    public long getMeanRowCompactedSize()
+    {
+        if (rowsCompactedCount > 0)
+            return rowsCompactedTotalSize / rowsCompactedCount;
+        else
+            return 0L;
+    }
+
     public static ColumnFamilyStore createColumnFamilyStore(String table, String columnFamily)
throws IOException
     {
         /*

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java?rev=923364&r1=923363&r2=923364&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/ColumnFamilyStoreMBean.java
Mon Mar 15 17:59:31 2010
@@ -118,4 +118,22 @@ public interface ColumnFamilyStoreMBean
      * invalidate the row cache; for use after bulk loading via BinaryMemtable
      */
     public void invalidateRowCache();
+
+    /**
+     * return the size of the smallest compacted row
+     * @return
+     */
+    public long getMinRowCompactedSize();
+
+    /**
+     * return the size of the largest compacted row
+     * @return
+     */
+    public long getMaxRowCompactedSize();
+
+    /**
+     * return the mean size of the rows compacted
+     * @return
+     */
+    public long getMeanRowCompactedSize();
 }

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/CompactionManager.java?rev=923364&r1=923363&r2=923364&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/CompactionManager.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/db/CompactionManager.java
Mon Mar 15 17:59:31 2010
@@ -308,6 +308,7 @@ public class CompactionManager implement
                 long rowsize = writer.getFilePointer() - prevpos;
                 if (rowsize > DatabaseDescriptor.getRowWarningThreshold())
                     logger.warn("Large row " + row.key.key + " in " + cfs.getColumnFamilyName()
+ " " + rowsize + " bytes");
+                cfs.addToCompactedRowStats(rowsize);
             }
             validator.complete();
         }



Mime
View raw message