Skip to main content

remote_time_index_candidate_count

Function remote_time_index_candidate_count 

Source
pub fn remote_time_index_candidate_count(
    entries: &[TimeEntry],
    target_timestamp: i64,
) -> usize
Expand description

Return the length of the usable strict-predecessor prefix of a remote time index.

Kafka preallocates a time index, so its tail is padding. The usable prefix is where relative offsets strictly increase; the first non-increasing offset is padding and ends it. The count stops there or at the first entry whose timestamp is at or above target_timestamp, whichever comes first.

Every counted entry is strictly below the target. A time-index entry holds the largest timestamp at or before its offset, so no record up to that offset can match the target, and each counted entry, the last one included, is a safe place to start a scan. The bytes come from the remote tier, so nothing here assumes their timestamps are sorted: for a Kafka-written index they are, and the last counted entry is then the latest safe one.