DataFile

Multiple SSTable are stored in a large file, the DataFile.

DataFile only allocates or reclaims space by a fixed size: its allocation unit. There is one DataFile for each allocation unit.

Assuming in openkv the allocation unit are 4MB and 16MB, then there are two DataFiles: df-4mb and df-16mb.

Each DataFile has a corresponding bitmap for tracking allocated unit.

The bitmap is part of the manifest

bitmap-4mb:DataFile-4mb:bitmap-16mb:1SST01...00111100SST0SST0...

Commit a SSTable

  • Find the first 0 in df-bitmap. This bitmap has to be indexed to speed up searching for the first 0.

  • Flush and fsync SSTable data to DataFile.

  • Flush and fsync bitmap in manifest.