pub fn local_retention_prefix(
segments: &[LocalRetentionSegment],
size_debt: Option<u64>,
) -> usizeExpand description
Count the oldest local segments that Kafka’s local retention passes delete.
segments is every local segment, oldest first, and the newest one is
the segment the log appends to: Kafka’s deletableSegments walks the
active segment too. A result that covers every segment tells the host to
roll first and then delete them all, the way Kafka’s deleteSegments
does (if (numberOfSegments == numToDelete) roll()); the walk never
takes a newest segment that is empty, so the roll always leaves a fresh
empty segment behind and never has to recreate the one it deletes.
size_debt is None when Kafka skips the size pass: retention.bytes
is unset, the policy does not delete, or the log is smaller than the
budget. Otherwise it is the log size minus the budget. The walk never
passes a blocked segment.
The result equals local_retention_model from the oldest segment,
limited by local_retention_limit. That fold states the Kafka rule.
Before that limit, the first kept segment is blocked or not expired.
Every selected non-expired segment fits the initial size debt together with
every older segment. Before the limit, an unblocked kept segment exceeds
that debt. These independent cost bounds reject a selector/reference pair
that omits the size pass or deletes beyond the budget.