serialize.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. ///
  3. /// @file yt/cpp/mapreduce/interface/serialize.h
  4. ///
  5. /// Header containing declaration of functions for serializing to/from YSON.
  6. #include "common.h"
  7. #include <library/cpp/type_info/fwd.h>
  8. namespace NYT::NYson {
  9. struct IYsonConsumer;
  10. } // namespace NYT::NYson
  11. namespace NYT {
  12. ////////////////////////////////////////////////////////////////////////////////
  13. template <class T>
  14. void Deserialize(TMaybe<T>& value, const TNode& node)
  15. {
  16. value.ConstructInPlace();
  17. Deserialize(value.GetRef(), node);
  18. }
  19. template <class T>
  20. void Deserialize(TVector<T>& value, const TNode& node)
  21. {
  22. for (const auto& element : node.AsList()) {
  23. value.emplace_back();
  24. Deserialize(value.back(), element);
  25. }
  26. }
  27. template <class T>
  28. void Deserialize(THashMap<TString, T>& value, const TNode& node)
  29. {
  30. for (const auto& item : node.AsMap()) {
  31. Deserialize(value[item.first], item.second);
  32. }
  33. }
  34. ////////////////////////////////////////////////////////////////////////////////
  35. void Serialize(const TKey& key, NYT::NYson::IYsonConsumer* consumer);
  36. void Deserialize(TKey& key, const TNode& node);
  37. void Serialize(const TSortColumns& sortColumns, NYT::NYson::IYsonConsumer* consumer);
  38. void Deserialize(TSortColumns& sortColumns, const TNode& node);
  39. void Serialize(const TColumnNames& columnNames, NYT::NYson::IYsonConsumer* consumer);
  40. void Deserialize(TColumnNames& columnNames, const TNode& node);
  41. void Serialize(const TSortColumn& sortColumn, NYT::NYson::IYsonConsumer* consumer);
  42. void Deserialize(TSortColumn& sortColumn, const TNode& node);
  43. void Serialize(const TKeyBound& keyBound, NYT::NYson::IYsonConsumer* consumer);
  44. void Deserialize(TKeyBound& keyBound, const TNode& node);
  45. void Serialize(const TReadLimit& readLimit, NYT::NYson::IYsonConsumer* consumer);
  46. void Deserialize(TReadLimit& readLimit, const TNode& node);
  47. void Serialize(const TReadRange& readRange, NYT::NYson::IYsonConsumer* consumer);
  48. void Serialize(const TRichYPath& path, NYT::NYson::IYsonConsumer* consumer);
  49. void Deserialize(TRichYPath& path, const TNode& node);
  50. void Serialize(const TAttributeFilter& filter, NYT::NYson::IYsonConsumer* consumer);
  51. void Serialize(const TColumnSchema& columnSchema, NYT::NYson::IYsonConsumer* consumer);
  52. void Serialize(const TTableSchema& tableSchema, NYT::NYson::IYsonConsumer* consumer);
  53. void Deserialize(EValueType& valueType, const TNode& node);
  54. void Deserialize(TTableSchema& tableSchema, const TNode& node);
  55. void Deserialize(TColumnSchema& columnSchema, const TNode& node);
  56. void Deserialize(TTableColumnarStatistics& statistics, const TNode& node);
  57. void Deserialize(TMultiTablePartition& partition, const TNode& node);
  58. void Deserialize(TMultiTablePartitions& partitions, const TNode& node);
  59. void Deserialize(TTabletInfo& tabletInfos, const TNode& node);
  60. void Serialize(const TGUID& path, NYT::NYson::IYsonConsumer* consumer);
  61. void Deserialize(TGUID& value, const TNode& node);
  62. void Serialize(const NTi::TTypePtr& type, NYT::NYson::IYsonConsumer* consumer);
  63. void Deserialize(NTi::TTypePtr& type, const TNode& node);
  64. ////////////////////////////////////////////////////////////////////////////////
  65. } // namespace NYT