Stream table (that maps stream IDs to location of first segment in underlying stream) is something that I need to make better. For the simplicity, stream table only exists in memory. When storage is opened it needs to be rebuilt by going through all segments in underlying stream and checking if segment contains StreamMetadata structure. If yes, storage adds it to stream table.
But, since scanning if of course slow, stream table is cached in the storage when it is closed. It is stored inside the empty space (actually in the stream representing empty space). So next time when storage opens it loads the stream table back instead of scanning the whole storage.
Therefore I want to implement stream table in the form of B+ tree, but haven't figured out the algorithm yet.