Two policies, one storage engine
Segments, retention, compaction
A partition on disk is a sequence of log segments (.log + .index files). Two cleanup policies decide their fate:
delete(default) — drop segments older thanretention.msor aboveretention.bytes.compact— keep only the latest value per key; null values become tombstones and are eventually GC'd. Turns the topic into a changelog of state.
Compacted topics are how Kafka itself stores consumer offsets (__consumer_offsets) and Streams' state-store changelogs. Use them whenever the topic represents state, not events.