From 5d4371a0c4e6941f540c8aa7f60d2cfb0744d9c4 Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Sat, 27 Feb 2010 15:18:50 +0000 Subject: [PATCH] merge from 0.6 git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@916962 13f79535-47bb-0310-9956-ffa450edef68 --- conf/storage-conf.xml | 23 ++-- .../apache/cassandra/config/CFMetaData.java | 17 +-- .../cassandra/config/DatabaseDescriptor.java | 53 ++++----- .../apache/cassandra/db/BinaryMemtable.java | 2 +- .../cassandra/db/ColumnFamilyStore.java | 103 +++++------------- .../cassandra/db/CompactionManager.java | 4 +- .../org/apache/cassandra/db/Memtable.java | 2 +- .../apache/cassandra/io/SSTableReader.java | 62 +++++------ .../apache/cassandra/io/SSTableTracker.java | 63 ++++++++++- .../apache/cassandra/io/SSTableWriter.java | 25 ++--- .../apache/cassandra/tools/SSTableImport.java | 4 +- .../apache/cassandra/utils/FBUtilities.java | 36 ++++++ test/conf/storage-conf.xml | 4 +- .../org/apache/cassandra/io/SSTableTest.java | 4 +- .../org/apache/cassandra/io/SSTableUtils.java | 2 +- .../cassandra/tools/SSTableExportTest.java | 11 +- .../cassandra/tools/SSTableImportTest.java | 5 +- 17 files changed, 227 insertions(+), 193 deletions(-) diff --git a/conf/storage-conf.xml b/conf/storage-conf.xml index 6c1f2a1d42..7494ceb97b 100644 --- a/conf/storage-conf.xml +++ b/conf/storage-conf.xml @@ -83,25 +83,22 @@ ~ An optional `Comment` attribute may be used to attach additional ~ human-readable information about the column family to its definition. ~ - ~ The optional KeysCachedFraction attribute specifies - ~ The fraction of keys per sstable whose locations we keep in + ~ The optional KeysCached attribute specifies + ~ the number of keys per sstable whose locations we keep in ~ memory in "mostly LRU" order. (JUST the key locations, NOT any - ~ column values.) The amount of memory used by the default setting of - ~ 0.01 is comparable to the amount used by the internal per-sstable key - ~ index. Consider increasing this if you have fewer, wider rows. - ~ Set to 0 to disable entirely. + ~ column values.) Specify a fraction (value less than 1), a percentage + ~ (ending in a % sign) or an absolute number of keys to cache. ~ ~ The optional RowsCached attribute specifies the number of rows - ~ whose entire contents we cache in memory, either as a fixed number - ~ of rows or as a percent of rows in the ColumnFamily. - ~ Do not use this on ColumnFamilies with large rows, or - ~ ColumnFamilies with high write:read ratios. As with key caching, - ~ valid values are from 0 to 1. The default 0 disables it entirely. + ~ whose entire contents we cache in memory. Do not use this on + ~ ColumnFamilies with large rows, or ColumnFamilies with high write:read + ~ ratios. Specify a fraction (value less than 1), a percentage (ending in + ~ a % sign) or an absolute number of rows to cache. --> + KeysCached="0"/> - + - + diff --git a/test/unit/org/apache/cassandra/io/SSTableTest.java b/test/unit/org/apache/cassandra/io/SSTableTest.java index 5750b55a92..ca7322415e 100644 --- a/test/unit/org/apache/cassandra/io/SSTableTest.java +++ b/test/unit/org/apache/cassandra/io/SSTableTest.java @@ -43,7 +43,7 @@ public class SSTableTest extends CleanupHelper TreeMap map = new TreeMap(); map.put(key, bytes); - SSTableReader ssTable = SSTableUtils.writeRawSSTable("table", "singlewrite", map); + SSTableReader ssTable = SSTableUtils.writeRawSSTable("Keyspace1", "Standard1", map); // verify verifySingle(ssTable, bytes, key); @@ -71,7 +71,7 @@ public class SSTableTest extends CleanupHelper } // write - SSTableReader ssTable = SSTableUtils.writeRawSSTable("table", "manywrites", map); + SSTableReader ssTable = SSTableUtils.writeRawSSTable("Keyspace1", "Standard2", map); // verify verifyMany(ssTable, map); diff --git a/test/unit/org/apache/cassandra/io/SSTableUtils.java b/test/unit/org/apache/cassandra/io/SSTableUtils.java index 6bf7830f26..0089d9b914 100644 --- a/test/unit/org/apache/cassandra/io/SSTableUtils.java +++ b/test/unit/org/apache/cassandra/io/SSTableUtils.java @@ -104,6 +104,6 @@ public class SSTableUtils entry.getValue()); new File(writer.indexFilename()).deleteOnExit(); new File(writer.filterFilename()).deleteOnExit(); - return writer.closeAndOpenReader(1.0); + return writer.closeAndOpenReader(); } } diff --git a/test/unit/org/apache/cassandra/tools/SSTableExportTest.java b/test/unit/org/apache/cassandra/tools/SSTableExportTest.java index 4f067deadb..ef139d1138 100644 --- a/test/unit/org/apache/cassandra/tools/SSTableExportTest.java +++ b/test/unit/org/apache/cassandra/tools/SSTableExportTest.java @@ -28,7 +28,6 @@ import org.apache.cassandra.db.ColumnFamily; import org.apache.cassandra.db.filter.NamesQueryFilter; import org.apache.cassandra.db.filter.QueryPath; import org.apache.cassandra.dht.IPartitioner; -import org.apache.cassandra.io.SSTableAccessor; import org.apache.cassandra.io.SSTableReader; import org.apache.cassandra.io.SSTableWriter; import org.apache.cassandra.io.util.DataOutputBuffer; @@ -67,7 +66,7 @@ public class SSTableExportTest dob.reset(); cfamily.clear(); - writer.closeAndOpenReader(0); + writer.closeAndOpenReader(); // Enumerate and verify File temp = File.createTempFile("Standard1", ".txt"); @@ -105,7 +104,7 @@ public class SSTableExportTest dob.reset(); cfamily.clear(); - SSTableReader reader = writer.closeAndOpenReader(0); + SSTableReader reader = writer.closeAndOpenReader(); // Export to JSON and verify File tempJson = File.createTempFile("Standard1", ".json"); @@ -145,7 +144,7 @@ public class SSTableExportTest dob.reset(); cfamily.clear(); - SSTableReader reader = writer.closeAndOpenReader(0); + SSTableReader reader = writer.closeAndOpenReader(); // Export to JSON and verify File tempJson = File.createTempFile("Super4", ".json"); @@ -178,7 +177,7 @@ public class SSTableExportTest dob.reset(); cfamily.clear(); - SSTableReader reader = writer.closeAndOpenReader(0); + SSTableReader reader = writer.closeAndOpenReader(); // Export to JSON and verify File tempJson = File.createTempFile("Standard1", ".json"); @@ -188,7 +187,7 @@ public class SSTableExportTest File tempSS2 = tempSSTableFile("Keyspace1", "Standard1"); SSTableImport.importJson(tempJson.getPath(), "Keyspace1", "Standard1", tempSS2.getPath()); - reader = SSTableAccessor.getSSTableReader(tempSS2.getPath(), DatabaseDescriptor.getPartitioner()); + reader = SSTableReader.open(tempSS2.getPath(), DatabaseDescriptor.getPartitioner()); NamesQueryFilter qf = new NamesQueryFilter("rowA", new QueryPath("Standard1", null, null), "name".getBytes()); ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily(); assertTrue(cf != null); diff --git a/test/unit/org/apache/cassandra/tools/SSTableImportTest.java b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java index 10f3585f16..fe200349c1 100644 --- a/test/unit/org/apache/cassandra/tools/SSTableImportTest.java +++ b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java @@ -26,7 +26,6 @@ import org.apache.cassandra.db.ColumnFamily; import org.apache.cassandra.db.IColumn; import org.apache.cassandra.db.filter.NamesQueryFilter; import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.io.SSTableAccessor; import org.apache.cassandra.io.SSTableReader; import static org.apache.cassandra.utils.FBUtilities.hexToBytes; import static org.apache.cassandra.io.SSTableUtils.tempSSTableFile; @@ -44,7 +43,7 @@ public class SSTableImportTest SSTableImport.importJson(jsonUrl, "Keyspace1", "Standard1", tempSS.getPath()); // Verify results - SSTableReader reader = SSTableAccessor.getSSTableReader(tempSS.getPath(), DatabaseDescriptor.getPartitioner()); + SSTableReader reader = SSTableReader.open(tempSS.getPath(), DatabaseDescriptor.getPartitioner()); NamesQueryFilter qf = new NamesQueryFilter("rowA", new QueryPath("Standard1", null, null), "colAA".getBytes()); ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily(); assert Arrays.equals(cf.getColumn("colAA".getBytes()).value(), hexToBytes("76616c4141")); @@ -58,7 +57,7 @@ public class SSTableImportTest SSTableImport.importJson(jsonUrl, "Keyspace1", "Super4", tempSS.getPath()); // Verify results - SSTableReader reader = SSTableAccessor.getSSTableReader(tempSS.getPath(), DatabaseDescriptor.getPartitioner()); + SSTableReader reader = SSTableReader.open(tempSS.getPath(), DatabaseDescriptor.getPartitioner()); NamesQueryFilter qf = new NamesQueryFilter("rowA", new QueryPath("Super4", null, null), "superA".getBytes()); ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily(); IColumn superCol = cf.getColumn("superA".getBytes());