flush

fun flush()

Seals the active memtable and writes every sealed one out as a segment.

Returns when the segments are on the platter and the manifest names them — whether or not maintenance runs in the background, because the writing is done on the calling thread either way. That is what makes it usable as a barrier: before measuring anything, before copying a store directory somewhere else, or before asserting on the shape of the tree.

It does not compact. Any compaction the flush made due is left to compact or to the background thread, so that "everything is in a segment" and "the tree is in shape" stay two separate statements a caller can ask for one at a time.