File ifile = new File(desc.filenameFor(SSTable.COMPONENT_INDEX));
File ffile = new File(desc.filenameFor(SSTable.COMPONENT_FILTER));
assert !ifile.exists();
assert !ffile.exists();
EstimatedHistogram rowSizes = SSTable.defaultRowHistogram();
EstimatedHistogram columnCounts = SSTable.defaultColumnHistogram();
IndexWriter iwriter;
long estimatedRows;
try
{
estimatedRows = SSTable.estimateRowsFromData(desc, dfile);
iwriter = new IndexWriter(desc, StorageService.getPartitioner(), estimatedRows);
}
catch(IOException e)
{
dfile.close();
throw e;
}
// build the index and filter
long rows = 0;
try
{
DecoratedKey key;
long rowPosition = 0;
while (rowPosition < dfile.length())
{
key = SSTableReader.decodeKey(StorageService.getPartitioner(), desc, ByteBufferUtil.readWithShortLength(dfile));
iwriter.afterAppend(key, rowPosition);
long dataSize = SSTableReader.readRowSize(dfile, desc);
rowPosition = dfile.getFilePointer() + dataSize; // next row
IndexHelper.skipBloomFilter(dfile);
IndexHelper.skipIndex(dfile);
ColumnFamily.serializer().deserializeFromSSTableNoColumns(ColumnFamily.create(cfs.metadata), dfile);
rowSizes.add(dataSize);
columnCounts.add(dfile.readInt());
dfile.seek(rowPosition);
rows++;
}