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));
// If the key is in (row) cache, we need the cache to be aware of the streamed row. To keep this simple, we
// simply invalidate the row (we always invalidate but invalidating a key not in the cache is a no-op).
cfs.invalidateCachedRow(key);
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++;
}