You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2010/10/18 19:41:04 UTC
svn commit: r1023920 - in /cassandra/trunk: CHANGES.txt
src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
Author: jbellis
Date: Mon Oct 18 17:41:04 2010
New Revision: 1023920
URL: http://svn.apache.org/viewvc?rev=1023920&view=rev
Log:
build stats post-stream
patch by jbellis; reviewed by brandonwilliams for CASSANDRA-1620
Modified:
cassandra/trunk/CHANGES.txt
cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1023920&r1=1023919&r2=1023920&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Mon Oct 18 17:41:04 2010
@@ -41,6 +41,7 @@ dev
* add cli support for get_range_slices (CASSANDRA-1088)
* Make memtable flush thresholds per-CF instead of global (CASSANDRA-1007)
* add cli support for binary data without CfDef hints (CASSANDRA-1603)
+ * fix building SSTable statistics post-stream (CASSANDRA-1620)
0.7-beta2
Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1023920&r1=1023919&r2=1023920&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Mon Oct 18 17:41:04 2010
@@ -172,7 +172,7 @@ public class SSTableWriter extends SSTab
dataFile.close(); // calls force
// write sstable statistics
- writeStatistics(descriptor);
+ writeStatistics(descriptor, estimatedRowSize, estimatedColumnCount);
// remove the 'tmp' marker from all components
final Descriptor newdesc = rename(descriptor, components);
@@ -187,12 +187,12 @@ public class SSTableWriter extends SSTab
return sstable;
}
- private void writeStatistics(Descriptor desc) throws IOException
+ private static void writeStatistics(Descriptor desc, EstimatedHistogram rowSizes, EstimatedHistogram columnnCounts) throws IOException
{
- DataOutputStream dos = new DataOutputStream(new FileOutputStream(desc.filenameFor(SSTable.COMPONENT_STATS)));
- EstimatedHistogram.serializer.serialize(estimatedRowSize, dos);
- EstimatedHistogram.serializer.serialize(estimatedColumnCount, dos);
- dos.close();
+ DataOutputStream out = new DataOutputStream(new FileOutputStream(desc.filenameFor(SSTable.COMPONENT_STATS)));
+ EstimatedHistogram.serializer.serialize(rowSizes, out);
+ EstimatedHistogram.serializer.serialize(rowSizes, out);
+ out.close();
}
static Descriptor rename(Descriptor tmpdesc, Set<Component> components)
@@ -258,6 +258,9 @@ public class SSTableWriter extends SSTab
assert !ifile.exists();
assert !ffile.exists();
+ EstimatedHistogram rowSizes = SSTable.defaultRowHistogram();
+ EstimatedHistogram columnCounts = SSTable.defaultColumnHistogram();
+
IndexWriter iwriter;
long estimatedRows;
try
@@ -280,12 +283,21 @@ public class SSTableWriter extends SSTab
while (rowPosition < dfile.length())
{
key = SSTableReader.decodeKey(StorageService.getPartitioner(), desc, FBUtilities.readShortByteArray(dfile));
- long dataSize = SSTableReader.readRowSize(dfile, desc);
iwriter.afterAppend(key, rowPosition);
+
+ long dataSize = SSTableReader.readRowSize(dfile, desc);
+ IndexHelper.skipBloomFilter(dfile);
+ IndexHelper.skipIndex(dfile);
+ ColumnFamily.serializer().deserializeFromSSTableNoColumns(ColumnFamily.create(cfs.metadata), dfile);
+ rowSizes.add(dataSize);
+ columnCounts.add(dfile.readInt());
+
rowPosition = dfile.getFilePointer() + dataSize;
dfile.seek(rowPosition);
rows++;
}
+
+ writeStatistics(desc, rowSizes, columnCounts);
}
finally
{