1818#include " storage/logger.h"
1919#include " storage/offset_translator_state.h"
2020#include " storage/parser_errc.h"
21+ #include " storage/parser_utils.h"
2122#include " storage/segment_set.h"
2223#include " storage/types.h"
2324
@@ -581,8 +582,8 @@ bool log_reader::is_done() {
581582 || is_finished_offset (_lease->range , _config.start_offset );
582583}
583584
584- timequery_result batch_timequery (
585- const model::record_batch& b,
585+ ss::future< timequery_result> batch_timequery (
586+ model::record_batch b,
586587 model::offset min_offset,
587588 model::timestamp t,
588589 model::offset max_offset) {
@@ -595,23 +596,25 @@ timequery_result batch_timequery(
595596 // records in the batch have different timestamps.
596597 model::offset result_o = b.base_offset ();
597598 model::timestamp result_t = b.header ().first_timestamp ;
598- if (!b.compressed ()) {
599- b.for_each_record (
600- [&result_o, &result_t , &b, query_interval, t](
601- const model::record& r) -> ss::stop_iteration {
602- auto record_o = model::offset{r.offset_delta ()} + b.base_offset ();
603- auto record_t = model::timestamp (
604- b.header ().first_timestamp () + r.timestamp_delta ());
605- if (record_t >= t && query_interval.contains (record_o)) {
606- result_o = record_o;
607- result_t = record_t ;
608- return ss::stop_iteration::yes;
609- } else {
610- return ss::stop_iteration::no;
611- }
612- });
613- }
614- return {result_o, result_t };
599+ auto batch = co_await internal::decompress_batch (std::move (b));
600+ co_await batch.for_each_record_async (
601+ [&result_o, &result_t , &batch, query_interval, t](
602+ const model::record& r) -> ss::future<ss::stop_iteration> {
603+ auto record_o = model::offset{r.offset_delta ()} + batch.base_offset ();
604+ auto record_t = model::timestamp (
605+ batch.header ().first_timestamp () + r.timestamp_delta ());
606+ if (record_t >= t && query_interval.contains (record_o)) {
607+ result_o = record_o;
608+ result_t = record_t ;
609+ return ss::make_ready_future<ss::stop_iteration>(
610+ ss::stop_iteration::yes);
611+ } else {
612+ return ss::make_ready_future<ss::stop_iteration>(
613+ ss::stop_iteration::no);
614+ }
615+ });
616+
617+ co_return timequery_result{result_o, result_t };
615618}
616619
617620} // namespace storage
0 commit comments