cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r888279 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/db/ColumnFamilyStore.java test/unit/org/apache/cassandra/db/CompactionsTest.java
Date Tue, 08 Dec 2009 06:19:30 GMT
Author: jbellis
Date: Tue Dec  8 06:19:30 2009
New Revision: 888279

URL: http://svn.apache.org/viewvc?rev=888279&view=rev
Log:
compute major-ness of compaction in the compaction method, rather than relying on caller to
do it correctly (as some tests were not).  patch by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsTest.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=888279&r1=888278&r2=888279&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue
Dec  8 06:19:30 2009
@@ -660,7 +660,7 @@
                 // re-compacting files we just created.
                 Collections.sort(sstables);
                 boolean major = sstables.size() == ssTables_.size();
-                filesCompacted += doFileCompaction(sstables.subList(0, Math.min(sstables.size(),
maxThreshold)), major);
+                filesCompacted += doFileCompaction(sstables.subList(0, Math.min(sstables.size(),
maxThreshold)));
             }
             logger_.debug(filesCompacted + " files compacted");
         }
@@ -702,7 +702,7 @@
             sstables = ssTables_.getSSTables();
         }
 
-        doFileCompaction(sstables, major);
+        doFileCompaction(sstables);
     }
 
     /*
@@ -858,9 +858,9 @@
         return results;
     }
 
-    private int doFileCompaction(Collection<SSTableReader> sstables, boolean major)
throws IOException
+    private int doFileCompaction(Collection<SSTableReader> sstables) throws IOException
     {
-        return doFileCompaction(sstables, getDefaultGCBefore(), major);
+        return doFileCompaction(sstables, getDefaultGCBefore());
     }
 
     /*
@@ -876,7 +876,7 @@
     * The collection of sstables passed may be empty (but not null); even if
     * it is not empty, it may compact down to nothing if all rows are deleted.
     */
-    int doFileCompaction(Collection<SSTableReader> sstables, int gcBefore, boolean
major) throws IOException
+    int doFileCompaction(Collection<SSTableReader> sstables, int gcBefore) throws IOException
     {
         if (DatabaseDescriptor.isSnapshotBeforeCompaction())
             Table.open(table_).snapshot("compact-" + columnFamily_);
@@ -889,9 +889,14 @@
             SSTableReader maxFile = getMaxSizeFile(sstables);
             List<SSTableReader> smallerSSTables = new ArrayList<SSTableReader>(sstables);
             smallerSSTables.remove(maxFile);
-            return doFileCompaction(smallerSSTables, gcBefore, false);
+            return doFileCompaction(smallerSSTables, gcBefore);
         }
 
+        // new sstables from flush can be added during a compaction, but only the compaction
can remove them,
+        // so in our single-threaded compaction world this is a valid way of determining
if we're compacting
+        // all the sstables (that existed when we started)
+        boolean major = sstables.size() == ssTables_.size();
+
         long startTime = System.currentTimeMillis();
         long totalkeysWritten = 0;
 

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsTest.java?rev=888279&r1=888278&r2=888279&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsTest.java Tue Dec
 8 06:19:30 2009
@@ -112,7 +112,7 @@
         store.forceBlockingFlush();
 
         // compact and test that all columns but the resurrected one is completely gone
-        store.doFileCompaction(store.getSSTables(), Integer.MAX_VALUE, false);
+        store.doFileCompaction(store.getSSTables(), Integer.MAX_VALUE);
         ColumnFamily cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key,
new QueryPath(cfName)));
         assert cf.getColumnCount() == 1;
         assert cf.getColumn(String.valueOf(5).getBytes()) != null;
@@ -150,7 +150,7 @@
         assert store.getSSTables().size() == 1 : store.getSSTables(); // inserts & deletes
were in the same memtable -> only deletes in sstable
 
         // compact and test that the row is completely gone
-        store.doFileCompaction(store.getSSTables(), Integer.MAX_VALUE, false);
+        store.doFileCompaction(store.getSSTables(), Integer.MAX_VALUE);
         assert store.getSSTables().isEmpty();
         ColumnFamily cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key,
new QueryPath(cfName)));
         assert cf == null : cf;



Mime
View raw message