aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-11-10 23:10:20 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-11-10 23:23:03 +0300
commit1b1aa156e8d25c70ae67da6e52c769f8a47129f2 (patch)
treec450fd758eab68ba29341a1b0ba46b8cf4ca4690
parentc840323f1e0d3cf553c869fce04915f0d0b9c282 (diff)
downloadydb-1b1aa156e8d25c70ae67da6e52c769f8a47129f2.tar.gz
Intermediate changes
-rw-r--r--yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib-inl.h37
-rw-r--r--yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib.h21
2 files changed, 52 insertions, 6 deletions
diff --git a/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib-inl.h b/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib-inl.h
new file mode 100644
index 0000000000..084db72d01
--- /dev/null
+++ b/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib-inl.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#ifndef YT_UNITTEST_LIB_H_
+#error "Direct inclusion of this file is not allowed, use yt_unittest_lib.h"
+#endif
+#undef YT_UNITTEST_LIB_H_
+
+#include <yt/cpp/mapreduce/interface/client.h>
+
+namespace NYT::NTesting {
+
+////////////////////////////////////////////////////////////////////////////////
+
+template <class TMessage>
+TVector<TMessage> ReadProtoTable(const IClientBasePtr& client, const TString& tablePath)
+{
+ TVector<TMessage> result;
+ auto reader = client->CreateTableReader<TMessage>(tablePath);
+ for (; reader->IsValid(); reader->Next()) {
+ result.push_back(reader->GetRow());
+ }
+ return result;
+}
+
+template <class TMessage>
+void WriteProtoTable(const IClientBasePtr& client, const TString& tablePath, const std::vector<TMessage>& rowList)
+{
+ auto writer = client->CreateTableWriter<TMessage>(tablePath);
+ for (const auto& row : rowList) {
+ writer->AddRow(row);
+ }
+ writer->Finish();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+} // namespace NYT::Testing
diff --git a/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib.h b/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib.h
index 237fa0abbe..1b1c40d5bb 100644
--- a/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib.h
+++ b/yt/cpp/mapreduce/tests/yt_unittest_lib/yt_unittest_lib.h
@@ -13,16 +13,15 @@
////////////////////////////////////////////////////////////////////////////////
-template<>
+template <>
void Out<NYT::TNode>(IOutputStream& s, const NYT::TNode& node);
-template<>
+template <>
void Out<TGUID>(IOutputStream& s, const TGUID& guid);
////////////////////////////////////////////////////////////////////////////////
-namespace NYT {
-namespace NTesting {
+namespace NYT::NTesting {
////////////////////////////////////////////////////////////////////////////////
@@ -36,6 +35,12 @@ TString GenerateRandomData(size_t size, ui64 seed = 42);
TVector<TNode> ReadTable(const IClientBasePtr& client, const TString& tablePath);
void WriteTable(const IClientBasePtr& client, const TString& tablePath, const std::vector<TNode>& rowList);
+template <class TMessage>
+TVector<TMessage> ReadProtoTable(const IClientBasePtr& client, const TString& tablePath);
+
+template <class TMessage>
+void WriteProtoTable(const IClientBasePtr& client, const TString& tablePath, const std::vector<TMessage>& rowList);
+
////////////////////////////////////////////////////////////////////////////////
// TODO: should be removed, usages should be replaced with TConfigSaverGuard
@@ -172,8 +177,7 @@ TString ToYson(const T& x)
////////////////////////////////////////////////////////////////////////////////
-} // namespace NTesting
-} // namespace NYT
+} // namespace NYT::NTesting
////////////////////////////////////////////////////////////////////////////////
@@ -195,3 +199,8 @@ void Out<NYT::NTesting::TOwningYaMRRow>(IOutputStream& out, const NYT::NTesting:
#define ASSERT_SERIALIZABLES_NE(a, b) \
ASSERT_NE(a, b) << NYT::NTesting::ToYson(a) << " == " << NYT::NTesting::ToYson(b)
+
+#define YT_UNITTEST_LIB_H_
+#include "yt_unittest_lib-inl.h"
+#undef YT_UNITTEST_LIB_H_
+