It's trivial to add a callback hook that allows the app to modify a document body as it's being written to the new file during compaction. This has a couple of uses:
- Schema migration – it's an efficient and atomic way to change the data format of all or many documents.
- Discarding obsolete data — for example, a doc might store a time series of records, and the older ones could be pruned during the compaction.
- Removing file offsets — if a doc stores a file offset to an earlier revision of itself (something I'm going to be doing for implementing revision trees) this needs to get removed during compaction since the offset (and the older revision) are no longer valid.