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

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@888279 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-12-08 06:19:30 +00:00
parent 49197c98a9
commit 8417db8fa9
2 changed files with 13 additions and 8 deletions

View File

@ -660,7 +660,7 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
// 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 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
sstables = ssTables_.getSSTables();
}
doFileCompaction(sstables, major);
doFileCompaction(sstables);
}
/*
@ -858,9 +858,9 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
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 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
* 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 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean
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;

View File

@ -112,7 +112,7 @@ public class CompactionsTest extends CleanupHelper
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 @@ public class CompactionsTest extends CleanupHelper
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;