Skip to content

Commit

Permalink
Replace std::vector with chunked_vector in list_offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisRP committed Oct 18, 2024
1 parent 32aa4fb commit efde79a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/v/kafka/server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ redpanda_cc_library(
"//src/v/ssx:sharded_ptr",
"//src/v/ssx:sharded_value",
"//src/v/ssx:thread_worker",
"//src/v/ssx:when_all",
"//src/v/storage",
"//src/v/storage:parser_utils",
"//src/v/storage:record_batch_builder",
Expand Down
14 changes: 9 additions & 5 deletions src/v/kafka/server/handlers/list_offsets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "model/fundamental.h"
#include "model/namespace.h"
#include "resource_mgmt/io_priority.h"
#include "ssx/when_all.h"

namespace kafka {

Expand Down Expand Up @@ -193,7 +194,7 @@ static ss::future<list_offset_partition_response> list_offsets_partition(

static ss::future<list_offset_topic_response>
list_offsets_topic(list_offsets_ctx& octx, list_offset_topic& topic) {
std::vector<ss::future<list_offset_partition_response>> partitions;
chunked_vector<ss::future<list_offset_partition_response>> partitions;
partitions.reserve(topic.partitions.size());

const auto* disabled_set
Expand Down Expand Up @@ -232,9 +233,11 @@ list_offsets_topic(list_offsets_ctx& octx, list_offset_topic& topic) {
partitions.push_back(std::move(pr));
}

return when_all_succeed(partitions.begin(), partitions.end())
return ssx::when_all_succeed<
chunked_vector<list_offset_partition_response>>(
std::move(partitions))
.then([name = std::move(topic.name)](
std::vector<list_offset_partition_response> parts) mutable {
chunked_vector<list_offset_partition_response> parts) mutable {
return list_offset_topic_response{
.name = std::move(name),
.partitions = chunked_vector<list_offset_partition_response>{
Expand Down Expand Up @@ -341,8 +344,9 @@ list_offsets_handler::handle(request_context ctx, ss::smp_service_group ssg) {

return ss::do_with(std::move(octx), [](list_offsets_ctx& octx) {
auto topics = list_offsets_topics(octx);
return ss::when_all_succeed(topics.begin(), topics.end())
.then([&octx](std::vector<list_offset_topic_response> topics) {
return ssx::when_all_succeed<
chunked_vector<list_offset_topic_response>>(std::move(topics))
.then([&octx](chunked_vector<list_offset_topic_response> topics) {
octx.response.data.topics = {
std::make_move_iterator(topics.begin()),
std::make_move_iterator(topics.end())};
Expand Down

0 comments on commit efde79a

Please sign in to comment.