common.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329
  1. #pragma once
  2. ///
  3. /// @file yt/cpp/mapreduce/interface/common.h
  4. ///
  5. /// Header containing miscellaneous structs and classes used in library.
  6. #include "fwd.h"
  7. #include <library/cpp/type_info/type_info.h>
  8. #include <library/cpp/yson/node/node.h>
  9. #include <util/generic/guid.h>
  10. #include <util/generic/map.h>
  11. #include <util/generic/maybe.h>
  12. #include <util/generic/ptr.h>
  13. #include <util/system/type_name.h>
  14. #include <util/generic/vector.h>
  15. #include <google/protobuf/message.h>
  16. #include <initializer_list>
  17. #include <type_traits>
  18. namespace NYT {
  19. ////////////////////////////////////////////////////////////////////////////////
  20. /// @cond Doxygen_Suppress
  21. #define FLUENT_FIELD(type, name) \
  22. type name##_; \
  23. TSelf& name(const type& value) \
  24. { \
  25. name##_ = value; \
  26. return static_cast<TSelf&>(*this); \
  27. } \
  28. static_assert(true)
  29. #define FLUENT_FIELD_ENCAPSULATED(type, name) \
  30. private: \
  31. type name##_; \
  32. public: \
  33. TSelf& name(const type& value) & \
  34. { \
  35. name##_ = value; \
  36. return static_cast<TSelf&>(*this); \
  37. } \
  38. TSelf name(const type& value) && \
  39. { \
  40. name##_ = value; \
  41. return static_cast<TSelf&>(*this); \
  42. } \
  43. const type& name() const & \
  44. { \
  45. return name##_; \
  46. } \
  47. type name() && \
  48. { \
  49. return name##_; \
  50. } \
  51. static_assert(true)
  52. #define FLUENT_FIELD_OPTION(type, name) \
  53. TMaybe<type> name##_; \
  54. TSelf& name(const type& value) \
  55. { \
  56. name##_ = value; \
  57. return static_cast<TSelf&>(*this); \
  58. } \
  59. static_assert(true)
  60. #define FLUENT_FIELD_OPTION_ENCAPSULATED(type, name) \
  61. private: \
  62. TMaybe<type> name##_; \
  63. public: \
  64. TSelf& name(const type& value) & \
  65. { \
  66. name##_ = value; \
  67. return static_cast<TSelf&>(*this); \
  68. } \
  69. TSelf name(const type& value) && \
  70. { \
  71. name##_ = value; \
  72. return static_cast<TSelf&>(*this); \
  73. } \
  74. TSelf& Reset##name() & \
  75. { \
  76. name##_ = Nothing(); \
  77. return static_cast<TSelf&>(*this); \
  78. } \
  79. TSelf Reset##name() && \
  80. { \
  81. name##_ = Nothing(); \
  82. return static_cast<TSelf&>(*this); \
  83. } \
  84. const TMaybe<type>& name() const& \
  85. { \
  86. return name##_; \
  87. } \
  88. TMaybe<type> name() && \
  89. { \
  90. return name##_; \
  91. } \
  92. static_assert(true)
  93. #define FLUENT_FIELD_DEFAULT(type, name, defaultValue) \
  94. type name##_ = defaultValue; \
  95. TSelf& name(const type& value) \
  96. { \
  97. name##_ = value; \
  98. return static_cast<TSelf&>(*this); \
  99. } \
  100. static_assert(true)
  101. #define FLUENT_FIELD_DEFAULT_ENCAPSULATED(type, name, defaultValue) \
  102. private: \
  103. type name##_ = defaultValue; \
  104. public: \
  105. TSelf& name(const type& value) & \
  106. { \
  107. name##_ = value; \
  108. return static_cast<TSelf&>(*this); \
  109. } \
  110. TSelf name(const type& value) && \
  111. { \
  112. name##_ = value; \
  113. return static_cast<TSelf&>(*this); \
  114. } \
  115. const type& name() const & \
  116. { \
  117. return name##_; \
  118. } \
  119. type name() && \
  120. { \
  121. return name##_; \
  122. } \
  123. static_assert(true)
  124. #define FLUENT_VECTOR_FIELD(type, name) \
  125. TVector<type> name##s_; \
  126. TSelf& Add##name(const type& value) \
  127. { \
  128. name##s_.push_back(value); \
  129. return static_cast<TSelf&>(*this);\
  130. } \
  131. TSelf& name##s(TVector<type> values) \
  132. { \
  133. name##s_ = std::move(values); \
  134. return static_cast<TSelf&>(*this);\
  135. } \
  136. static_assert(true)
  137. #define FLUENT_OPTIONAL_VECTOR_FIELD_ENCAPSULATED(type, name) \
  138. private: \
  139. TMaybe<TVector<type>> name##s_; \
  140. public: \
  141. const TMaybe<TVector<type>>& name##s() const & { \
  142. return name##s_; \
  143. } \
  144. TMaybe<TVector<type>>& name##s() & { \
  145. return name##s_; \
  146. } \
  147. TMaybe<TVector<type>> name##s() && { \
  148. return std::move(name##s_); \
  149. } \
  150. TSelf& Add##name(const type& value) & \
  151. { \
  152. if (name##s_.Empty()) { \
  153. name##s_.ConstructInPlace(); \
  154. } \
  155. name##s_->push_back(value); \
  156. return static_cast<TSelf&>(*this);\
  157. } \
  158. TSelf Add##name(const type& value) && \
  159. { \
  160. if (name##s_.Empty()) { \
  161. name##s_.ConstructInPlace(); \
  162. } \
  163. name##s_->push_back(value); \
  164. return static_cast<TSelf&&>(*this);\
  165. } \
  166. TSelf& name##s(TVector<type> values) & \
  167. { \
  168. name##s_ = std::move(values); \
  169. return static_cast<TSelf&>(*this);\
  170. } \
  171. TSelf name##s(TVector<type> values) && \
  172. { \
  173. name##s_ = std::move(values); \
  174. return static_cast<TSelf&&>(*this);\
  175. } \
  176. TSelf& name##s(TNothing) & \
  177. { \
  178. name##s_ = Nothing(); \
  179. return static_cast<TSelf&>(*this);\
  180. } \
  181. TSelf name##s(TNothing) && \
  182. { \
  183. name##s_ = Nothing(); \
  184. return static_cast<TSelf&&>(*this);\
  185. } \
  186. TSelf& Reset##name##s() & \
  187. { \
  188. name##s_ = Nothing(); \
  189. return static_cast<TSelf&>(*this);\
  190. } \
  191. TSelf Reset##name##s() && \
  192. { \
  193. name##s_ = Nothing(); \
  194. return static_cast<TSelf&&>(*this);\
  195. } \
  196. static_assert(true)
  197. #define FLUENT_VECTOR_FIELD_ENCAPSULATED(type, name) \
  198. private: \
  199. TVector<type> name##s_; \
  200. public: \
  201. TSelf& Add##name(const type& value) & \
  202. { \
  203. name##s_.push_back(value); \
  204. return static_cast<TSelf&>(*this);\
  205. } \
  206. TSelf Add##name(const type& value) && \
  207. { \
  208. name##s_.push_back(value); \
  209. return static_cast<TSelf&>(*this);\
  210. } \
  211. TSelf& name##s(TVector<type> value) & \
  212. { \
  213. name##s_ = std::move(value); \
  214. return static_cast<TSelf&>(*this);\
  215. } \
  216. TSelf name##s(TVector<type> value) && \
  217. { \
  218. name##s_ = std::move(value); \
  219. return static_cast<TSelf&>(*this);\
  220. } \
  221. const TVector<type>& name##s() const & \
  222. { \
  223. return name##s_; \
  224. } \
  225. TVector<type> name##s() && \
  226. { \
  227. return name##s_; \
  228. } \
  229. static_assert(true)
  230. #define FLUENT_MAP_FIELD(keytype, valuetype, name) \
  231. TMap<keytype,valuetype> name##_; \
  232. TSelf& Add##name(const keytype& key, const valuetype& value) \
  233. { \
  234. name##_.emplace(key, value); \
  235. return static_cast<TSelf&>(*this);\
  236. } \
  237. static_assert(true)
  238. /// @endcond
  239. ////////////////////////////////////////////////////////////////////////////////
  240. ///
  241. /// @brief Convenience class that keeps sequence of items.
  242. ///
  243. /// Designed to be used as function parameter.
  244. ///
  245. /// Users of such function can then pass:
  246. /// - single item,
  247. /// - initializer list of items,
  248. /// - vector of items;
  249. /// as argument to this function.
  250. ///
  251. /// Example:
  252. /// ```
  253. /// void Foo(const TOneOrMany<int>& arg);
  254. /// ...
  255. /// Foo(1); // ok
  256. /// Foo({1, 2, 3}); // ok
  257. /// ```
  258. template <class T, class TDerived>
  259. struct TOneOrMany
  260. {
  261. /// @cond Doxygen_Suppress
  262. using TSelf = std::conditional_t<std::is_void_v<TDerived>, TOneOrMany, TDerived>;
  263. /// @endcond
  264. /// Initialize with empty sequence.
  265. TOneOrMany() = default;
  266. // Initialize from initializer list.
  267. template<class U>
  268. TOneOrMany(std::initializer_list<U> il)
  269. {
  270. Parts_.assign(il.begin(), il.end());
  271. }
  272. /// Put arguments to sequence
  273. template <class U, class... TArgs>
  274. requires std::is_convertible_v<U, T>
  275. TOneOrMany(U&& arg, TArgs&&... args)
  276. {
  277. Add(arg, std::forward<TArgs>(args)...);
  278. }
  279. /// Initialize from vector.
  280. TOneOrMany(TVector<T> args)
  281. : Parts_(std::move(args))
  282. { }
  283. /// @brief Order is defined the same way as in TVector
  284. bool operator==(const TOneOrMany& rhs) const
  285. {
  286. // N.B. We would like to make this method to be `= default`,
  287. // but this breaks MSVC compiler for the cases when T doesn't
  288. // support comparison.
  289. return Parts_ == rhs.Parts_;
  290. }
  291. ///
  292. /// @{
  293. ///
  294. /// @brief Add all arguments to sequence
  295. template <class U, class... TArgs>
  296. requires std::is_convertible_v<U, T>
  297. TSelf& Add(U&& part, TArgs&&... args) &
  298. {
  299. Parts_.push_back(std::forward<U>(part));
  300. if constexpr (sizeof...(args) > 0) {
  301. [[maybe_unused]] int dummy[sizeof...(args)] = {(Parts_.push_back(std::forward<TArgs>(args)), 0) ... };
  302. }
  303. return static_cast<TSelf&>(*this);
  304. }
  305. template <class U, class... TArgs>
  306. requires std::is_convertible_v<U, T>
  307. TSelf Add(U&& part, TArgs&&... args) &&
  308. {
  309. return std::move(Add(std::forward<U>(part), std::forward<TArgs>(args)...));
  310. }
  311. /// @}
  312. /// Content of sequence.
  313. TVector<T> Parts_;
  314. };
  315. ////////////////////////////////////////////////////////////////////////////////
  316. ///
  317. /// @brief Type of the value that can occur in YT table.
  318. ///
  319. /// @ref NYT::TTableSchema
  320. /// https://ytsaurus.tech/docs/en/user-guide/storage/data-types
  321. enum EValueType : int
  322. {
  323. /// Int64, signed integer of 64 bits.
  324. VT_INT64,
  325. /// Uint64, unsigned integer of 64 bits.
  326. VT_UINT64,
  327. /// Double, floating point number of double precision (64 bits).
  328. VT_DOUBLE,
  329. /// Boolean, `true` or `false`.
  330. VT_BOOLEAN,
  331. /// String, arbitrary byte sequence.
  332. VT_STRING,
  333. /// Any, arbitrary yson document.
  334. VT_ANY,
  335. /// Int8, signed integer of 8 bits.
  336. VT_INT8,
  337. /// Int16, signed integer of 16 bits.
  338. VT_INT16,
  339. /// Int32, signed integer of 32 bits.
  340. VT_INT32,
  341. /// Uint8, unsigned integer of 8 bits.
  342. VT_UINT8,
  343. /// Uint16, unsigned integer of 16 bits.
  344. VT_UINT16,
  345. /// Uint32, unsigned integer of 32 bits.
  346. VT_UINT32,
  347. /// Utf8, byte sequence that is valid utf8.
  348. VT_UTF8,
  349. /// Null, absence of value (almost never used in schemas)
  350. VT_NULL,
  351. /// Void, absence of value (almost never used in schemas) the difference between null, and void is yql-specific.
  352. VT_VOID,
  353. /// Date, number of days since Unix epoch (unsigned)
  354. VT_DATE,
  355. /// Datetime, number of seconds since Unix epoch (unsigned)
  356. VT_DATETIME,
  357. /// Timestamp, number of milliseconds since Unix epoch (unsigned)
  358. VT_TIMESTAMP,
  359. /// Interval, difference between two timestamps (signed)
  360. VT_INTERVAL,
  361. /// Float, floating point number (32 bits)
  362. VT_FLOAT,
  363. /// Json, sequence of bytes that is valid json.
  364. VT_JSON,
  365. // Date32, number of days shifted from Unix epoch, which is 0 (signed)
  366. VT_DATE32,
  367. // Datetime64, number of seconds shifted from Unix epoch, which is 0 (signed)
  368. VT_DATETIME64,
  369. // Timestamp64, number of milliseconds shifted from Unix epoch, which is 0 (signed)
  370. VT_TIMESTAMP64,
  371. // Interval64, difference between two timestamps64 (signed)
  372. VT_INTERVAL64,
  373. // Universally unique identifier according to RFC-4122.
  374. VT_UUID,
  375. };
  376. ///
  377. /// @brief Sort order.
  378. ///
  379. /// @ref NYT::TTableSchema
  380. enum ESortOrder : int
  381. {
  382. /// Ascending sort order.
  383. SO_ASCENDING /* "ascending" */,
  384. /// Descending sort order.
  385. SO_DESCENDING /* "descending" */,
  386. };
  387. ///
  388. /// @brief Value of "optimize_for" attribute.
  389. ///
  390. /// @ref NYT::TRichYPath
  391. enum EOptimizeForAttr : i8
  392. {
  393. /// Optimize for scan
  394. OF_SCAN_ATTR /* "scan" */,
  395. /// Optimize for lookup
  396. OF_LOOKUP_ATTR /* "lookup" */,
  397. };
  398. ///
  399. /// @brief Value of "erasure_codec" attribute.
  400. ///
  401. /// @ref NYT::TRichYPath
  402. enum EErasureCodecAttr : i8
  403. {
  404. /// @cond Doxygen_Suppress
  405. EC_NONE_ATTR /* "none" */,
  406. EC_REED_SOLOMON_6_3_ATTR /* "reed_solomon_6_3" */,
  407. EC_LRC_12_2_2_ATTR /* "lrc_12_2_2" */,
  408. EC_ISA_LRC_12_2_2_ATTR /* "isa_lrc_12_2_2" */,
  409. /// @endcond
  410. };
  411. ///
  412. /// @brief Value of "schema_modification" attribute.
  413. ///
  414. /// @ref NYT::TRichYPath
  415. enum ESchemaModificationAttr : i8
  416. {
  417. SM_NONE_ATTR /* "none" */,
  418. SM_UNVERSIONED_UPDATE /* "unversioned_update" */,
  419. };
  420. ////////////////////////////////////////////////////////////////////////////////
  421. ///
  422. /// @brief Table key column description.
  423. ///
  424. /// The description includes column name and sort order.
  425. ///
  426. /// @anchor TSortOrder_backward_compatibility
  427. /// @note
  428. /// Many functions that use `TSortOrder` as argument used to take `TString`
  429. /// (the only allowed sort order was "ascending" and user didn't have to specify it).
  430. /// @note
  431. /// This class is designed to provide backward compatibility for such code and therefore
  432. /// objects of this class can be constructed and assigned from TString-like objects only.
  433. ///
  434. /// @see NYT::TSortOperationSpec
  435. class TSortColumn
  436. {
  437. public:
  438. /// @cond Doxygen_Suppress
  439. using TSelf = TSortColumn;
  440. /// @endcond
  441. /// Column name
  442. FLUENT_FIELD_ENCAPSULATED(TString, Name);
  443. /// Sort order
  444. FLUENT_FIELD_DEFAULT_ENCAPSULATED(ESortOrder, SortOrder, ESortOrder::SO_ASCENDING);
  445. ///
  446. /// @{
  447. ///
  448. /// @brief Construct object from name and sort order
  449. ///
  450. /// Constructors are intentionally implicit so `TSortColumn` can be compatible with old code.
  451. /// @ref TSortOrder_backward_compatibility
  452. TSortColumn(TStringBuf name = {}, ESortOrder sortOrder = ESortOrder::SO_ASCENDING);
  453. TSortColumn(const TString& name, ESortOrder sortOrder = ESortOrder::SO_ASCENDING);
  454. TSortColumn(const char* name, ESortOrder sortOrder = ESortOrder::SO_ASCENDING);
  455. /// @}
  456. /// Check that sort order is ascending, throw exception otherwise.
  457. const TSortColumn& EnsureAscending() const;
  458. /// @brief Convert sort to yson representation as YT API expects it.
  459. TNode ToNode() const;
  460. /// @brief Comparison is default and checks both name and sort order.
  461. bool operator == (const TSortColumn& rhs) const = default;
  462. ///
  463. /// @{
  464. ///
  465. /// @brief Assign object from column name, and set sort order to `ascending`.
  466. ///
  467. /// This is backward compatibility methods.
  468. ///
  469. /// @ref TSortOrder_backward_compatibility
  470. TSortColumn& operator = (TStringBuf name);
  471. TSortColumn& operator = (const TString& name);
  472. TSortColumn& operator = (const char* name);
  473. /// @}
  474. bool operator == (const TStringBuf rhsName) const;
  475. bool operator == (const TString& rhsName) const;
  476. bool operator == (const char* rhsName) const;
  477. // Intentionally implicit conversions.
  478. operator TString() const;
  479. operator TStringBuf() const;
  480. operator std::string() const;
  481. Y_SAVELOAD_DEFINE(Name_, SortOrder_);
  482. };
  483. ///
  484. /// @brief List of @ref TSortColumn
  485. ///
  486. /// Contains a bunch of helper methods such as constructing from single object.
  487. class TSortColumns
  488. : public TOneOrMany<TSortColumn, TSortColumns>
  489. {
  490. public:
  491. using TOneOrMany<TSortColumn, TSortColumns>::TOneOrMany;
  492. /// Construct empty list.
  493. TSortColumns();
  494. ///
  495. /// @{
  496. ///
  497. /// @brief Construct list of ascending sort order columns by their names.
  498. ///
  499. /// Required for backward compatibility.
  500. ///
  501. /// @ref TSortOrder_backward_compatibility
  502. TSortColumns(const TVector<TString>& names);
  503. TSortColumns(const TColumnNames& names);
  504. /// @}
  505. ///
  506. /// @brief Implicit conversion to column list.
  507. ///
  508. /// If all columns has ascending sort order return list of their names.
  509. /// Throw exception otherwise.
  510. ///
  511. /// Required for backward compatibility.
  512. ///
  513. /// @ref TSortOrder_backward_compatibility
  514. operator TColumnNames() const;
  515. /// Make sure that all columns are of ascending sort order.
  516. const TSortColumns& EnsureAscending() const;
  517. /// Get list of column names.
  518. TVector<TString> GetNames() const;
  519. };
  520. ////////////////////////////////////////////////////////////////////////////////
  521. /// Helper function to create new style type from old style one.
  522. NTi::TTypePtr ToTypeV3(EValueType type, bool required);
  523. ///
  524. /// @brief Single column description
  525. ///
  526. /// Each field describing column has setter and getter.
  527. ///
  528. /// Example reading field:
  529. /// ```
  530. /// ... columnSchema.Name() ...
  531. /// ```
  532. ///
  533. /// Example setting field:
  534. /// ```
  535. /// columnSchema.Name("my-column").Type(VT_INT64); // set name and type
  536. /// ```
  537. ///
  538. /// @ref https://ytsaurus.tech/docs/en/user-guide/storage/static-schema
  539. class TColumnSchema
  540. {
  541. public:
  542. /// @cond Doxygen_Suppress
  543. using TSelf = TColumnSchema;
  544. /// @endcond
  545. ///
  546. /// @brief Construct empty column schemas
  547. ///
  548. /// @note
  549. /// Such schema cannot be used in schema as it it doesn't have name.
  550. TColumnSchema();
  551. ///
  552. /// @{
  553. ///
  554. /// @brief Copy and move constructors are default.
  555. TColumnSchema(const TColumnSchema&) = default;
  556. TColumnSchema& operator=(const TColumnSchema&) = default;
  557. /// @}
  558. FLUENT_FIELD_ENCAPSULATED(TString, Name);
  559. ///
  560. /// @brief Functions to work with type in old manner.
  561. ///
  562. /// @deprecated New code is recommended to work with types using @ref NTi::TTypePtr from type_info library.
  563. TColumnSchema& Type(EValueType type) &;
  564. TColumnSchema Type(EValueType type) &&;
  565. EValueType Type() const;
  566. /// @brief Set and get column type.
  567. /// @{
  568. TColumnSchema& Type(const NTi::TTypePtr& type) &;
  569. TColumnSchema Type(const NTi::TTypePtr& type) &&;
  570. TColumnSchema& TypeV3(const NTi::TTypePtr& type) &;
  571. TColumnSchema TypeV3(const NTi::TTypePtr& type) &&;
  572. NTi::TTypePtr TypeV3() const;
  573. /// @}
  574. /// Column sort order
  575. FLUENT_FIELD_OPTION_ENCAPSULATED(ESortOrder, SortOrder);
  576. ///
  577. /// @brief Lock group name
  578. ///
  579. /// @ref https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/sorted-dynamic-tables#locking-rows
  580. FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Lock);
  581. /// Expression defining column value
  582. FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Expression);
  583. /// Aggregating function name
  584. FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Aggregate);
  585. ///
  586. /// @brief Storage group name
  587. ///
  588. /// @ref https://ytsaurus.tech/docs/en/user-guide/storage/static-schema
  589. FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Group);
  590. // StableName for renamed and deleted columns.
  591. FLUENT_FIELD_OPTION_ENCAPSULATED(TString, StableName);
  592. /// Deleted column
  593. FLUENT_FIELD_OPTION_ENCAPSULATED(bool, Deleted);
  594. ///
  595. /// @brief Column requiredness.
  596. ///
  597. /// Required columns doesn't accept NULL values.
  598. /// Usually if column is required it means that it has Optional<...> type
  599. bool Required() const;
  600. ///
  601. /// @{
  602. ///
  603. /// @brief Set type in old-style manner
  604. TColumnSchema& Type(EValueType type, bool required) &;
  605. TColumnSchema Type(EValueType type, bool required) &&;
  606. /// @}
  607. ///
  608. /// @{
  609. ///
  610. /// @brief Raw yson representation of column type
  611. /// @deprecated Prefer to use `TypeV3` methods.
  612. const TMaybe<TNode>& RawTypeV3() const;
  613. TColumnSchema& RawTypeV3(TNode rawTypeV3)&;
  614. TColumnSchema RawTypeV3(TNode rawTypeV3)&&;
  615. /// @}
  616. private:
  617. friend void Deserialize(TColumnSchema& columnSchema, const TNode& node);
  618. NTi::TTypePtr TypeV3_;
  619. TMaybe<TNode> RawTypeV3_;
  620. };
  621. /// Equality check checks all fields of column schema.
  622. bool operator==(const TColumnSchema& lhs, const TColumnSchema& rhs);
  623. ///
  624. /// @brief Description of table schema
  625. ///
  626. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/static-schema
  627. class TTableSchema
  628. {
  629. public:
  630. /// @cond Doxygen_Suppress
  631. using TSelf = TTableSchema;
  632. /// @endcond
  633. /// Column schema
  634. FLUENT_VECTOR_FIELD_ENCAPSULATED(TColumnSchema, Column);
  635. ///
  636. /// @brief Strictness of the schema
  637. ///
  638. /// Strict schemas are not allowed to have columns not described in schema.
  639. /// Nonstrict schemas are allowed to have such columns, all such missing columns are assumed to have
  640. /// type any (or optional<yson> in type_v3 terminology).
  641. FLUENT_FIELD_DEFAULT_ENCAPSULATED(bool, Strict, true);
  642. ///
  643. /// @brief Whether keys are unique
  644. ///
  645. /// This flag can be set only for schemas that have sorted columns.
  646. /// If flag is set table cannot have multiple rows with same key.
  647. FLUENT_FIELD_DEFAULT_ENCAPSULATED(bool, UniqueKeys, false);
  648. /// Get modifiable column list
  649. TVector<TColumnSchema>& MutableColumns();
  650. /// Check if schema has any described column
  651. [[nodiscard]] bool Empty() const;
  652. /// Add column
  653. TTableSchema& AddColumn(const TString& name, const NTi::TTypePtr& type, ESortOrder sortOrder) &;
  654. /// @copydoc NYT::TTableSchema::AddColumn(const TString&, const NTi::TTypePtr&, ESortOrder)&;
  655. TTableSchema AddColumn(const TString& name, const NTi::TTypePtr& type, ESortOrder sortOrder) &&;
  656. /// @copydoc NYT::TTableSchema::AddColumn(const TString&, const NTi::TTypePtr&, ESortOrder)&;
  657. TTableSchema& AddColumn(const TString& name, const NTi::TTypePtr& type) &;
  658. /// @copydoc NYT::TTableSchema::AddColumn(const TString&, const NTi::TTypePtr&, ESortOrder)&;
  659. TTableSchema AddColumn(const TString& name, const NTi::TTypePtr& type) &&;
  660. /// Add optional column of specified type
  661. TTableSchema& AddColumn(const TString& name, EValueType type, ESortOrder sortOrder) &;
  662. /// @copydoc NYT::TTableSchema::AddColumn(const TString&, EValueType, ESortOrder)&;
  663. TTableSchema AddColumn(const TString& name, EValueType type, ESortOrder sortOrder) &&;
  664. /// @copydoc NYT::TTableSchema::AddColumn(const TString&, EValueType, ESortOrder)&;
  665. TTableSchema& AddColumn(const TString& name, EValueType type) &;
  666. /// @copydoc NYT::TTableSchema::AddColumn(const TString&, EValueType, ESortOrder)&;
  667. TTableSchema AddColumn(const TString& name, EValueType type) &&;
  668. ///
  669. /// @brief Make table schema sorted by specified columns
  670. ///
  671. /// Resets old key columns if any
  672. TTableSchema& SortBy(const TSortColumns& columns) &;
  673. /// @copydoc NYT::TTableSchema::SortBy(const TSortColumns&)&;
  674. TTableSchema SortBy(const TSortColumns& columns) &&;
  675. /// Get yson description of table schema
  676. [[nodiscard]] TNode ToNode() const;
  677. /// Parse schema from yson node
  678. static NYT::TTableSchema FromNode(const TNode& node);
  679. friend void Deserialize(TTableSchema& tableSchema, const TNode& node);
  680. };
  681. /// Check for equality of all columns and all schema attributes
  682. bool operator==(const TTableSchema& lhs, const TTableSchema& rhs);
  683. // Pretty printer for unittests
  684. void PrintTo(const TTableSchema& schema, std::ostream* out);
  685. /// Create table schema by protobuf message descriptor
  686. TTableSchema CreateTableSchema(
  687. const ::google::protobuf::Descriptor& messageDescriptor,
  688. const TSortColumns& sortColumns = TSortColumns(),
  689. bool keepFieldsWithoutExtension = true);
  690. /// Create table schema by protobuf message type
  691. template <class TProtoType, typename = std::enable_if_t<std::is_base_of_v<::google::protobuf::Message, TProtoType>>>
  692. inline TTableSchema CreateTableSchema(
  693. const TSortColumns& sortColumns = TSortColumns(),
  694. bool keepFieldsWithoutExtension = true)
  695. {
  696. static_assert(
  697. std::is_base_of_v<::google::protobuf::Message, TProtoType>,
  698. "Template argument must be derived from ::google::protobuf::Message");
  699. return CreateTableSchema(
  700. *TProtoType::descriptor(),
  701. sortColumns,
  702. keepFieldsWithoutExtension);
  703. }
  704. ///
  705. /// @brief Create strict table schema from `struct` type.
  706. ///
  707. /// Names and types of columns are taken from struct member names and types.
  708. /// `Strict` flag is set to true, all other attribute of schema and columns
  709. /// are left with default values
  710. TTableSchema CreateTableSchema(NTi::TTypePtr type);
  711. ////////////////////////////////////////////////////////////////////////////////
  712. ///
  713. /// @brief Enumeration describing comparison operation used in key bound.
  714. ///
  715. /// ERelation is a part of @ref NYT::TKeyBound that can be used as
  716. /// lower or upper key limit in @ref TReadLimit.
  717. ///
  718. /// Relations `Less` and `LessOrEqual` are for upper limit and
  719. /// relations `Greater` and `GreaterOrEqual` are for lower limit.
  720. ///
  721. /// It is a error to use relation in the limit of wrong kind.
  722. ///
  723. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/ypath#rich_ypath
  724. enum class ERelation
  725. {
  726. ///
  727. /// @brief Relation "less"
  728. ///
  729. /// Specifies range of keys that are before specified key.
  730. /// Can only be used in upper limit.
  731. Less /* "<" */,
  732. ///
  733. /// @brief Relation "less or equal"
  734. ///
  735. /// Specifies range of keys that are before or equal specified key.
  736. /// Can only be used in upper limit.
  737. LessOrEqual /* "<=" */,
  738. ///
  739. /// @brief Relation "greater"
  740. ///
  741. /// Specifies range of keys that are after specified key.
  742. /// Can only be used in lower limit.
  743. Greater /* ">" */,
  744. ///
  745. /// @brief Relation "greater or equal"
  746. ///
  747. /// Specifies range of keys that are after or equal than specified key.
  748. /// Can only be used in lower limit.
  749. GreaterOrEqual /* ">=" */,
  750. };
  751. ///
  752. /// @brief Key with relation specifying interval of keys in lower or upper limit of @ref NYT::TReadRange
  753. ///
  754. /// @see https://ytsaurus.tech/docs/en/user-guide/common/ypath#rich_ypath
  755. struct TKeyBound
  756. {
  757. /// @cond Doxygen_Suppress
  758. using TSelf = TKeyBound;
  759. explicit TKeyBound(ERelation relation = ERelation::Less, TKey key = TKey{});
  760. FLUENT_FIELD_DEFAULT_ENCAPSULATED(ERelation, Relation, ERelation::Less);
  761. FLUENT_FIELD_DEFAULT_ENCAPSULATED(TKey, Key, TKey{});
  762. /// @endcond
  763. };
  764. ///
  765. /// @brief Description of the read limit.
  766. ///
  767. /// It is actually a variant and must store exactly one field.
  768. ///
  769. /// @see https://ytsaurus.tech/docs/en/user-guide/common/ypath#rich_ypath
  770. struct TReadLimit
  771. {
  772. /// @cond Doxygen_Suppress
  773. using TSelf = TReadLimit;
  774. /// @endcond
  775. ///
  776. /// @brief KeyBound specifies table key and whether to include it
  777. ///
  778. /// It can be used in lower or upper limit when reading tables.
  779. FLUENT_FIELD_OPTION(TKeyBound, KeyBound);
  780. ///
  781. /// @brief Table key
  782. ///
  783. /// It can be used in exact, lower or upper limit when reading tables.
  784. FLUENT_FIELD_OPTION(TKey, Key);
  785. ///
  786. /// @brief Row index
  787. ///
  788. /// It can be used in exact, lower or upper limit when reading tables.
  789. FLUENT_FIELD_OPTION(i64, RowIndex);
  790. ///
  791. /// @brief File offset
  792. ///
  793. /// It can be used in lower or upper limit when reading files.
  794. FLUENT_FIELD_OPTION(i64, Offset);
  795. ///
  796. /// @brief Tablet index
  797. ///
  798. /// It can be used in lower or upper limit in dynamic table operations
  799. FLUENT_FIELD_OPTION(i64, TabletIndex);
  800. };
  801. ///
  802. /// @brief Range of a table or a file
  803. ///
  804. /// @see https://ytsaurus.tech/docs/en/user-guide/common/ypath#rich_ypath
  805. struct TReadRange
  806. {
  807. using TSelf = TReadRange;
  808. ///
  809. /// @brief Lower limit of the range
  810. ///
  811. /// It is usually inclusive (except when @ref NYT::TKeyBound with relation @ref NYT::ERelation::Greater is used).
  812. FLUENT_FIELD(TReadLimit, LowerLimit);
  813. ///
  814. /// @brief Lower limit of the range
  815. ///
  816. /// It is usually exclusive (except when @ref NYT::TKeyBound with relation @ref NYT::ERelation::LessOrEqual is used).
  817. FLUENT_FIELD(TReadLimit, UpperLimit);
  818. /// Exact key or row index.
  819. FLUENT_FIELD(TReadLimit, Exact);
  820. /// Create read range from row indexes.
  821. static TReadRange FromRowIndices(i64 lowerLimit, i64 upperLimit)
  822. {
  823. return TReadRange()
  824. .LowerLimit(TReadLimit().RowIndex(lowerLimit))
  825. .UpperLimit(TReadLimit().RowIndex(upperLimit));
  826. }
  827. /// Create read range from keys.
  828. static TReadRange FromKeys(const TKey& lowerKeyInclusive, const TKey& upperKeyExclusive)
  829. {
  830. return TReadRange()
  831. .LowerLimit(TReadLimit().Key(lowerKeyInclusive))
  832. .UpperLimit(TReadLimit().Key(upperKeyExclusive));
  833. }
  834. };
  835. ///
  836. /// @brief Path with additional attributes.
  837. ///
  838. /// Allows to specify additional attributes for path used in some operations.
  839. ///
  840. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/ypath#rich_ypath
  841. struct TRichYPath
  842. {
  843. /// @cond Doxygen_Suppress
  844. using TSelf = TRichYPath;
  845. /// @endcond
  846. /// Path itself.
  847. FLUENT_FIELD(TYPath, Path);
  848. /// Specifies that path should be appended not overwritten
  849. FLUENT_FIELD_OPTION(bool, Append);
  850. /// @deprecated Deprecated attribute.
  851. FLUENT_FIELD_OPTION(bool, PartiallySorted);
  852. /// Specifies that path is expected to be sorted by these columns.
  853. FLUENT_FIELD(TSortColumns, SortedBy);
  854. /// Add range to read.
  855. TRichYPath& AddRange(TReadRange range)
  856. {
  857. if (!Ranges_) {
  858. Ranges_.ConstructInPlace();
  859. }
  860. Ranges_->push_back(std::move(range));
  861. return *this;
  862. }
  863. TRichYPath& ResetRanges()
  864. {
  865. Ranges_.Clear();
  866. return *this;
  867. }
  868. ///
  869. /// @{
  870. ///
  871. /// Return ranges to read.
  872. ///
  873. /// NOTE: Nothing (in TMaybe) and empty TVector are different ranges.
  874. /// Nothing represents universal range (reader reads all table rows).
  875. /// Empty TVector represents empty range (reader returns empty set of rows).
  876. const TMaybe<TVector<TReadRange>>& GetRanges() const
  877. {
  878. return Ranges_;
  879. }
  880. TMaybe<TVector<TReadRange>>& MutableRanges()
  881. {
  882. return Ranges_;
  883. }
  884. ///
  885. /// @{
  886. ///
  887. /// Get range view, that is convenient way to iterate through all ranges.
  888. TArrayRef<TReadRange> MutableRangesView()
  889. {
  890. if (Ranges_.Defined()) {
  891. return TArrayRef(Ranges_->data(), Ranges_->size());
  892. } else {
  893. return {};
  894. }
  895. }
  896. TArrayRef<const TReadRange> GetRangesView() const
  897. {
  898. if (Ranges_.Defined()) {
  899. return TArrayRef(Ranges_->data(), Ranges_->size());
  900. } else {
  901. return {};
  902. }
  903. }
  904. /// @}
  905. /// @{
  906. ///
  907. /// Get range by index.
  908. const TReadRange& GetRange(ssize_t i) const
  909. {
  910. return Ranges_.GetRef()[i];
  911. }
  912. TReadRange& MutableRange(ssize_t i)
  913. {
  914. return Ranges_.GetRef()[i];
  915. }
  916. /// @}
  917. ///
  918. /// @brief Specifies columns that should be read.
  919. ///
  920. /// If it's set to Nothing then all columns will be read.
  921. /// If empty TColumnNames is specified then each read row will be empty.
  922. FLUENT_FIELD_OPTION(TColumnNames, Columns);
  923. FLUENT_FIELD_OPTION(bool, Teleport);
  924. FLUENT_FIELD_OPTION(bool, Primary);
  925. FLUENT_FIELD_OPTION(bool, Foreign);
  926. FLUENT_FIELD_OPTION(i64, RowCountLimit);
  927. FLUENT_FIELD_OPTION(TString, FileName);
  928. /// Specifies original path to be shown in Web UI
  929. FLUENT_FIELD_OPTION(TYPath, OriginalPath);
  930. ///
  931. /// @brief Specifies that this path points to executable file
  932. ///
  933. /// Used in operation specs.
  934. FLUENT_FIELD_OPTION(bool, Executable);
  935. ///
  936. /// @brief Specify format to use when loading table.
  937. ///
  938. /// Used in operation specs.
  939. FLUENT_FIELD_OPTION(TNode, Format);
  940. /// @brief Specifies table schema that will be set on the path
  941. FLUENT_FIELD_OPTION(TTableSchema, Schema);
  942. /// Specifies compression codec that will be set on the path
  943. FLUENT_FIELD_OPTION(TString, CompressionCodec);
  944. /// Specifies erasure codec that will be set on the path
  945. FLUENT_FIELD_OPTION(EErasureCodecAttr, ErasureCodec);
  946. /// Specifies schema modification that will be set on the path
  947. FLUENT_FIELD_OPTION(ESchemaModificationAttr, SchemaModification);
  948. /// Specifies optimize_for attribute that will be set on the path
  949. FLUENT_FIELD_OPTION(EOptimizeForAttr, OptimizeFor);
  950. ///
  951. /// @brief Do not put file used in operation into node cache
  952. ///
  953. /// If BypassArtifactCache == true, file will be loaded into the job's sandbox bypassing the cache on the YT node.
  954. /// It helps jobs that use tmpfs to start faster,
  955. /// because files will be loaded into tmpfs directly bypassing disk cache
  956. FLUENT_FIELD_OPTION(bool, BypassArtifactCache);
  957. ///
  958. /// @brief Timestamp of dynamic table.
  959. ///
  960. /// NOTE: it is _not_ unix timestamp
  961. /// (instead it's transaction timestamp, that is more complex structure).
  962. FLUENT_FIELD_OPTION(i64, Timestamp);
  963. ///
  964. /// @brief Specify transaction that should be used to access this path.
  965. ///
  966. /// Allows to start cross-transactional operations.
  967. FLUENT_FIELD_OPTION(TTransactionId, TransactionId);
  968. using TRenameColumnsDescriptor = THashMap<TString, TString>;
  969. /// Specifies columnar mapping which will be applied to columns before transfer to job.
  970. FLUENT_FIELD_OPTION(TRenameColumnsDescriptor, RenameColumns);
  971. /// Create empty path with no attributes
  972. TRichYPath()
  973. { }
  974. ///
  975. /// @{
  976. ///
  977. /// @brief Create path from string
  978. TRichYPath(const char* path)
  979. : Path_(path)
  980. { }
  981. TRichYPath(const TYPath& path)
  982. : Path_(path)
  983. { }
  984. /// @}
  985. private:
  986. TMaybe<TVector<TReadRange>> Ranges_;
  987. };
  988. ///
  989. /// @ref Create copy of @ref NYT::TRichYPath with schema derived from proto message.
  990. ///
  991. ///
  992. template <typename TProtoType>
  993. TRichYPath WithSchema(const TRichYPath& path, const TSortColumns& sortBy = TSortColumns())
  994. {
  995. static_assert(std::is_base_of_v<::google::protobuf::Message, TProtoType>, "TProtoType must be Protobuf message");
  996. auto schemedPath = path;
  997. if (!schemedPath.Schema_) {
  998. schemedPath.Schema(CreateTableSchema<TProtoType>(sortBy));
  999. }
  1000. return schemedPath;
  1001. }
  1002. ///
  1003. /// @brief Create copy of @ref NYT::TRichYPath with schema derived from TRowType if possible.
  1004. ///
  1005. /// If TRowType is protobuf message schema is derived from it and set to returned path.
  1006. /// Otherwise schema of original path is left unchanged (and probably unset).
  1007. template <typename TRowType>
  1008. TRichYPath MaybeWithSchema(const TRichYPath& path, const TSortColumns& sortBy = TSortColumns())
  1009. {
  1010. if constexpr (std::is_base_of_v<::google::protobuf::Message, TRowType>) {
  1011. return WithSchema<TRowType>(path, sortBy);
  1012. } else {
  1013. return path;
  1014. }
  1015. }
  1016. ///
  1017. /// @brief Get the list of ranges related to path in compatibility mode.
  1018. ///
  1019. /// - If path is missing ranges, empty list is returned.
  1020. /// - If path has associated range list and the list is not empty, function returns this list.
  1021. /// - If path has associated range list and this list is empty, exception is thrown.
  1022. ///
  1023. /// Before YT-17683 RichYPath didn't support empty range list and empty range actually meant universal range.
  1024. /// This function emulates this old behavior.
  1025. ///
  1026. /// @see https://st.yandex-team.ru/YT-17683
  1027. const TVector<TReadRange>& GetRangesCompat(const TRichYPath& path);
  1028. ////////////////////////////////////////////////////////////////////////////////
  1029. /// Statistics about table columns.
  1030. struct TTableColumnarStatistics
  1031. {
  1032. /// Total data weight for all chunks for each of requested columns.
  1033. THashMap<TString, i64> ColumnDataWeight;
  1034. /// Estimated number of unique elements for each column.
  1035. THashMap<TString, ui64> ColumnEstimatedUniqueCounts;
  1036. /// Total weight of all old chunks that don't keep columnar statistics.
  1037. i64 LegacyChunksDataWeight = 0;
  1038. /// Timestamps total weight (only for dynamic tables).
  1039. TMaybe<i64> TimestampTotalWeight;
  1040. };
  1041. ////////////////////////////////////////////////////////////////////////////////
  1042. /// Description of a partition.
  1043. struct TMultiTablePartition
  1044. {
  1045. struct TStatistics
  1046. {
  1047. i64 ChunkCount = 0;
  1048. i64 DataWeight = 0;
  1049. i64 RowCount = 0;
  1050. };
  1051. /// Ranges of input tables for this partition.
  1052. TVector<TRichYPath> TableRanges;
  1053. /// Aggregate statistics of all the table ranges in the partition.
  1054. TStatistics AggregateStatistics;
  1055. };
  1056. /// Table partitions from GetTablePartitions command.
  1057. struct TMultiTablePartitions
  1058. {
  1059. /// Disjoint partitions into which the input tables were divided.
  1060. TVector<TMultiTablePartition> Partitions;
  1061. };
  1062. ////////////////////////////////////////////////////////////////////////////////
  1063. ///
  1064. /// @brief Contains information about tablet
  1065. ///
  1066. /// @see NYT::IClient::GetTabletInfos
  1067. struct TTabletInfo
  1068. {
  1069. ///
  1070. /// @brief Indicates the total number of rows added to the tablet (including trimmed ones).
  1071. ///
  1072. /// Currently only provided for ordered tablets.
  1073. i64 TotalRowCount = 0;
  1074. ///
  1075. /// @brief Contains the number of front rows that are trimmed and are not guaranteed to be accessible.
  1076. ///
  1077. /// Only makes sense for ordered tablet.
  1078. i64 TrimmedRowCount = 0;
  1079. ///
  1080. /// @brief Tablet cell barrier timestamp, which lags behind the current timestamp
  1081. ///
  1082. /// It is guaranteed that all transactions with commit timestamp not exceeding the barrier are fully committed;
  1083. /// e.g. all their added rows are visible (and are included in @ref NYT::TTabletInfo::TotalRowCount).
  1084. /// Mostly makes sense for ordered tablets.
  1085. ui64 BarrierTimestamp;
  1086. };
  1087. ////////////////////////////////////////////////////////////////////////////////
  1088. /// List of attributes to retrieve in operations like @ref NYT::ICypressClient::Get
  1089. struct TAttributeFilter
  1090. {
  1091. /// @cond Doxygen_Suppress
  1092. using TSelf = TAttributeFilter;
  1093. /// @endcond
  1094. /// List of attributes.
  1095. FLUENT_VECTOR_FIELD(TString, Attribute);
  1096. };
  1097. ////////////////////////////////////////////////////////////////////////////////
  1098. ///
  1099. /// @brief Check if none of the fields of @ref NYT::TReadLimit is set.
  1100. ///
  1101. /// @return true if any field of readLimit is set and false otherwise.
  1102. bool IsTrivial(const TReadLimit& readLimit);
  1103. /// Convert yson node type to table schema type
  1104. EValueType NodeTypeToValueType(TNode::EType nodeType);
  1105. ////////////////////////////////////////////////////////////////////////////////
  1106. ///
  1107. /// @brief Enumeration for specifying how reading from master is performed.
  1108. ///
  1109. /// Used in operations like NYT::ICypressClient::Get
  1110. enum class EMasterReadKind : int
  1111. {
  1112. ///
  1113. /// @brief Reading from leader.
  1114. ///
  1115. /// Should almost never be used since it's expensive and for regular uses has no difference from
  1116. /// "follower" read.
  1117. Leader /* "leader" */,
  1118. /// @brief Reading from master follower (default).
  1119. Follower /* "follower" */,
  1120. Cache /* "cache" */,
  1121. MasterCache /* "master_cache" */,
  1122. };
  1123. ////////////////////////////////////////////////////////////////////////////////
  1124. /// @cond Doxygen_Suppress
  1125. namespace NDetail {
  1126. // MUST NOT BE USED BY CLIENTS
  1127. // TODO: we should use default GENERATE_ENUM_SERIALIZATION
  1128. TString ToString(EValueType type);
  1129. } // namespace NDetail
  1130. /// @endcond
  1131. ////////////////////////////////////////////////////////////////////////////////
  1132. } // namespace NYT