Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/v/model/record_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ void append_record_to_buffer(iobuf& a, const model::record& r) {
append_vint_to_iobuf(a, r.timestamp_delta());
append_vint_to_iobuf(a, r.offset_delta());

a.reserve_memory(r.key_size() + r.value_size());
auto key_bytes = std::max(r.key_size(), 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do these methods return -1 and not 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 is used to distinguish a key/value in a record that is empty (std::nullopt) versus having a key/value that has a length of 0 ("").

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back to 1999

auto val_bytes = std::max(r.value_size(), 0);
a.reserve_memory(key_bytes + val_bytes);
Comment thread
WillemKauf marked this conversation as resolved.
append_vint_to_iobuf(a, r.key_size());
if (r.key_size() > 0) {
for (auto& f : r.key()) {
Expand Down