@@ -237,7 +237,7 @@ footer::seek_result footer::file_position_before_kafka_offset(
237237}
238238
239239footer::seek_result footer::file_position_before_max_timestamp (
240- const model::topic_id_partition& tidp, model::timestamp target) {
240+ const model::topic_id_partition& tidp, model::timestamp target) const {
241241 auto [begin, end] = partitions.equal_range (tidp);
242242 auto filtered = std::views::filter (
243243 std::ranges::subrange{begin, end}, [&target](const auto & entry) {
@@ -256,20 +256,20 @@ footer::seek_result footer::file_position_before_max_timestamp(
256256 index, target, std::less<>{}, [](const auto & entry) {
257257 return entry.max_timestamp ;
258258 });
259- // If we're past all index entries, but still within the recorded file
260- // bounds, the best we can do is start at the last well known offset (the
261- // last index entry).
262- if (it == index.end ()) {
263- --it;
264- }
265- // If at the first entry, we must start at the file beginning, because the
259+ // If we're at the first entry, we must start at the file beginning because
266260 // the max is inclusive of those entries.
267261 if (it == index.begin ()) {
268262 return {
269263 .file_position = partition.file_position ,
270264 .length = partition.length ,
271265 };
272266 }
267+ // If we're past all index entries, but still within the recorded file
268+ // bounds, the best we can do is start at the last well known offset (the
269+ // last index entry).
270+ if (it == index.end ()) {
271+ --it;
272+ }
273273 auto delta = it->file_position - partition.file_position ;
274274 return {
275275 .file_position = it->file_position ,
0 commit comments