diff options
author | ermolovd <ermolovd@yandex-team.com> | 2024-11-23 11:11:27 +0300 |
---|---|---|
committer | ermolovd <ermolovd@yandex-team.com> | 2024-11-23 11:24:00 +0300 |
commit | c46068e0065014b783098fc52829398858dd707e (patch) | |
tree | 3e560cf51e36d079b652958e494d900d0acfb6f4 /yt/cpp/mapreduce | |
parent | 8e841b73f8df78e6844dfe9350d0f0a6c98c30cb (diff) | |
download | ydb-c46068e0065014b783098fc52829398858dd707e.tar.gz |
fix buffered stream interleaving for proto format
commit_hash:66e6b75f97ea253ddbf4c97a180f9f971c59f93b
Diffstat (limited to 'yt/cpp/mapreduce')
-rw-r--r-- | yt/cpp/mapreduce/io/proto_table_writer.cpp | 17 | ||||
-rw-r--r-- | yt/cpp/mapreduce/io/proto_table_writer.h | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/io/proto_table_writer.cpp b/yt/cpp/mapreduce/io/proto_table_writer.cpp index 517d572181..f56784eb60 100644 --- a/yt/cpp/mapreduce/io/proto_table_writer.cpp +++ b/yt/cpp/mapreduce/io/proto_table_writer.cpp @@ -231,4 +231,21 @@ void TLenvalProtoSingleTableWriter::AddRow(const Message& row, size_t tableIndex //////////////////////////////////////////////////////////////////////////////// +void LenvalEncodeProto(IZeroCopyOutput* output, const ::google::protobuf::Message& message) +{ + i32 size = message.ByteSizeLong(); + output->Write(&size, sizeof(size)); + + TProtobufZeroCopyOutputStream adapter(output); + auto result = message.SerializeToZeroCopyStream(&adapter); + + adapter.ThrowOnError(); + + if (!result) { + ythrow yexception() << "Failed to serialize protobuf message"; + } +} + +//////////////////////////////////////////////////////////////////////////////// + } // namespace NYT diff --git a/yt/cpp/mapreduce/io/proto_table_writer.h b/yt/cpp/mapreduce/io/proto_table_writer.h index 532cf3302b..336230f55f 100644 --- a/yt/cpp/mapreduce/io/proto_table_writer.h +++ b/yt/cpp/mapreduce/io/proto_table_writer.h @@ -79,4 +79,8 @@ public: //////////////////////////////////////////////////////////////////////////////// +void LenvalEncodeProto(IZeroCopyOutput* output, const ::google::protobuf::Message& message); + +//////////////////////////////////////////////////////////////////////////////// + } // namespace NYT |