yt_unittest_lib-inl.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #ifndef YT_UNITTEST_LIB_H_
  3. #error "Direct inclusion of this file is not allowed, use yt_unittest_lib.h"
  4. #endif
  5. #undef YT_UNITTEST_LIB_H_
  6. #include <yt/cpp/mapreduce/interface/client.h>
  7. namespace NYT::NTesting {
  8. ////////////////////////////////////////////////////////////////////////////////
  9. template <class TMessage>
  10. TVector<TMessage> ReadProtoTable(const IClientBasePtr& client, const TString& tablePath)
  11. {
  12. TVector<TMessage> result;
  13. auto reader = client->CreateTableReader<TMessage>(tablePath);
  14. for (; reader->IsValid(); reader->Next()) {
  15. result.push_back(reader->GetRow());
  16. }
  17. return result;
  18. }
  19. template <class TMessage>
  20. void WriteProtoTable(const IClientBasePtr& client, const TString& tablePath, const std::vector<TMessage>& rowList)
  21. {
  22. auto writer = client->CreateTableWriter<TMessage>(tablePath);
  23. for (const auto& row : rowList) {
  24. writer->AddRow(row);
  25. }
  26. writer->Finish();
  27. }
  28. ////////////////////////////////////////////////////////////////////////////////
  29. } // namespace NYT::Testing