client_method_options.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491
  1. #pragma once
  2. ///
  3. /// @file yt/cpp/mapreduce/interface/client_method_options.h
  4. ///
  5. /// Header containing options for @ref NYT::IClient methods.
  6. #include "common.h"
  7. #include "config.h"
  8. #include "format.h"
  9. #include "public.h"
  10. #include "retry_policy.h"
  11. #include <util/datetime/base.h>
  12. namespace NYT {
  13. ////////////////////////////////////////////////////////////////////////////////
  14. /// Type of the cypress node.
  15. enum ENodeType : int
  16. {
  17. NT_STRING /* "string_node" */,
  18. NT_INT64 /* "int64_node" */,
  19. NT_UINT64 /* "uint64_node" */,
  20. NT_DOUBLE /* "double_node" */,
  21. NT_BOOLEAN /* "boolean_node" */,
  22. NT_MAP /* "map_node" */,
  23. NT_LIST /* "list_node" */,
  24. NT_FILE /* "file" */,
  25. NT_TABLE /* "table" */,
  26. NT_DOCUMENT /* "document" */,
  27. NT_REPLICATED_TABLE /* "replicated_table" */,
  28. NT_TABLE_REPLICA /* "table_replica" */,
  29. NT_USER /* "user" */,
  30. NT_SCHEDULER_POOL /* "scheduler_pool" */,
  31. NT_LINK /* "link" */,
  32. NT_GROUP /* "group" */,
  33. NT_PORTAL /* "portal_entrance" */,
  34. NT_CHAOS_TABLE_REPLICA /* "chaos_table_replica" */,
  35. };
  36. ///
  37. /// @brief Mode of composite type representation in yson.
  38. ///
  39. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/data-types#yson
  40. enum class EComplexTypeMode : int
  41. {
  42. Named /* "named" */,
  43. Positional /* "positional" */,
  44. };
  45. ///
  46. /// @brief Options for @ref NYT::ICypressClient::Create
  47. ///
  48. /// @see https://ytsaurus.tech/docs/en/api/commands.html#create
  49. struct TCreateOptions
  50. {
  51. /// @cond Doxygen_Suppress
  52. using TSelf = TCreateOptions;
  53. /// @endcond
  54. /// Create missing parent directories if required.
  55. FLUENT_FIELD_DEFAULT(bool, Recursive, false);
  56. ///
  57. /// @brief Do not raise error if node already exists.
  58. ///
  59. /// Node is not recreated.
  60. /// Force and IgnoreExisting MUST NOT be used simultaneously.
  61. FLUENT_FIELD_DEFAULT(bool, IgnoreExisting, false);
  62. ///
  63. /// @brief Recreate node if it exists.
  64. ///
  65. /// Force and IgnoreExisting MUST NOT be used simultaneously.
  66. FLUENT_FIELD_DEFAULT(bool, Force, false);
  67. /// @brief Set node attributes.
  68. FLUENT_FIELD_OPTION(TNode, Attributes);
  69. };
  70. ///
  71. /// @brief Options for @ref NYT::ICypressClient::Remove
  72. ///
  73. /// @see https://ytsaurus.tech/docs/en/api/commands.html#remove
  74. struct TRemoveOptions
  75. {
  76. /// @cond Doxygen_Suppress
  77. using TSelf = TRemoveOptions;
  78. /// @endcond
  79. ///
  80. /// @brief Remove whole tree when removing composite cypress node (e.g. `map_node`).
  81. ///
  82. /// Without this option removing nonempty composite node will fail.
  83. FLUENT_FIELD_DEFAULT(bool, Recursive, false);
  84. /// @brief Do not fail if removing node doesn't exist.
  85. FLUENT_FIELD_DEFAULT(bool, Force, false);
  86. };
  87. /// Base class for options for operations that read from master.
  88. template <typename TDerived>
  89. struct TMasterReadOptions
  90. {
  91. /// @cond Doxygen_Suppress
  92. using TSelf = TDerived;
  93. /// @endcond
  94. /// @brief Where to read from.
  95. FLUENT_FIELD_OPTION(EMasterReadKind, ReadFrom);
  96. };
  97. ///
  98. /// @brief Options for @ref NYT::ICypressClient::Exists
  99. ///
  100. /// @see https://ytsaurus.tech/docs/en/api/commands.html#exists
  101. struct TExistsOptions
  102. : public TMasterReadOptions<TExistsOptions>
  103. {
  104. };
  105. ///
  106. /// @brief Options for @ref NYT::ICypressClient::Get
  107. ///
  108. /// @see https://ytsaurus.tech/docs/en/api/commands.html#get
  109. struct TGetOptions
  110. : public TMasterReadOptions<TGetOptions>
  111. {
  112. /// @brief Attributes that should be fetched with each node.
  113. FLUENT_FIELD_OPTION(TAttributeFilter, AttributeFilter);
  114. /// @brief Limit for the number of children node.
  115. FLUENT_FIELD_OPTION(i64, MaxSize);
  116. };
  117. ///
  118. /// @brief Options for @ref NYT::ICypressClient::Set
  119. ///
  120. /// @see https://ytsaurus.tech/docs/en/api/commands.html#set
  121. struct TSetOptions
  122. {
  123. /// @cond Doxygen_Suppress
  124. using TSelf = TSetOptions;
  125. /// @endcond
  126. /// Create missing parent directories if required.
  127. FLUENT_FIELD_DEFAULT(bool, Recursive, false);
  128. /// Allow setting any nodes, not only attribute and document ones.
  129. FLUENT_FIELD_OPTION(bool, Force);
  130. };
  131. ///
  132. /// @brief Options for @ref NYT::ICypressClient::MultisetAttributes
  133. ///
  134. /// @see https://ytsaurus.tech/docs/en/api/commands.html#multiset_attributes
  135. struct TMultisetAttributesOptions
  136. {
  137. /// @cond Doxygen_Suppress
  138. using TSelf = TMultisetAttributesOptions;
  139. /// @endcond
  140. FLUENT_FIELD_OPTION(bool, Force);
  141. };
  142. ///
  143. /// @brief Options for @ref NYT::ICypressClient::List
  144. ///
  145. /// @see https://ytsaurus.tech/docs/en/api/commands.html#list
  146. struct TListOptions
  147. : public TMasterReadOptions<TListOptions>
  148. {
  149. /// @cond Doxygen_Suppress
  150. using TSelf = TListOptions;
  151. /// @endcond
  152. /// Attributes that should be fetched for each node.
  153. FLUENT_FIELD_OPTION(TAttributeFilter, AttributeFilter);
  154. /// Limit for the number of children that will be fetched.
  155. FLUENT_FIELD_OPTION(i64, MaxSize);
  156. };
  157. ///
  158. /// @brief Options for @ref NYT::ICypressClient::Copy
  159. ///
  160. /// @see https://ytsaurus.tech/docs/en/api/commands.html#copy
  161. struct TCopyOptions
  162. {
  163. /// @cond Doxygen_Suppress
  164. using TSelf = TCopyOptions;
  165. /// @endcond
  166. /// Create missing directories in destination path if required.
  167. FLUENT_FIELD_DEFAULT(bool, Recursive, false);
  168. /// Allows to use existing node as destination, it will be overwritten.
  169. FLUENT_FIELD_DEFAULT(bool, Force, false);
  170. /// Whether to preserves account of source node.
  171. FLUENT_FIELD_DEFAULT(bool, PreserveAccount, false);
  172. /// Whether to preserve `expiration_time` attribute of source node.
  173. FLUENT_FIELD_OPTION(bool, PreserveExpirationTime);
  174. };
  175. ///
  176. /// @brief Options for @ref NYT::ICypressClient::Move
  177. ///
  178. /// @see https://ytsaurus.tech/docs/en/api/commands.html#move
  179. struct TMoveOptions
  180. {
  181. /// @cond Doxygen_Suppress
  182. using TSelf = TMoveOptions;
  183. /// @endcond
  184. /// Create missing directories in destination path if required.
  185. FLUENT_FIELD_DEFAULT(bool, Recursive, false);
  186. /// Allows to use existing node as destination, it will be overwritten.
  187. FLUENT_FIELD_DEFAULT(bool, Force, false);
  188. /// Whether to preserves account of source node.
  189. FLUENT_FIELD_DEFAULT(bool, PreserveAccount, false);
  190. /// Whether to preserve `expiration_time` attribute of source node.
  191. FLUENT_FIELD_OPTION(bool, PreserveExpirationTime);
  192. };
  193. ///
  194. /// @brief Options for @ref NYT::ICypressClient::Link
  195. ///
  196. /// @see https://ytsaurus.tech/docs/en/api/commands.html#link
  197. struct TLinkOptions
  198. {
  199. /// @cond Doxygen_Suppress
  200. using TSelf = TLinkOptions;
  201. /// @endcond
  202. /// Create parent directories of destination if they don't exist.
  203. FLUENT_FIELD_DEFAULT(bool, Recursive, false);
  204. /// Do not raise error if link already exists.
  205. FLUENT_FIELD_DEFAULT(bool, IgnoreExisting, false);
  206. /// Force rewrite target node.
  207. FLUENT_FIELD_DEFAULT(bool, Force, false);
  208. /// Attributes of created link.
  209. FLUENT_FIELD_OPTION(TNode, Attributes);
  210. };
  211. ///
  212. /// @brief Options for @ref NYT::ICypressClient::Concatenate
  213. ///
  214. /// @see https://ytsaurus.tech/docs/en/api/commands.html#concatenate
  215. struct TConcatenateOptions
  216. {
  217. /// @cond Doxygen_Suppress
  218. using TSelf = TConcatenateOptions;
  219. /// @endcond
  220. /// Whether we should append to destination or rewrite it.
  221. FLUENT_FIELD_OPTION(bool, Append);
  222. };
  223. ///
  224. /// @brief Options for @ref NYT::IIOClient::CreateBlobTableReader
  225. ///
  226. /// @see https://ytsaurus.tech/docs/en/api/commands.html#read_blob_table
  227. struct TBlobTableReaderOptions
  228. {
  229. /// @cond Doxygen_Suppress
  230. using TSelf = TBlobTableReaderOptions;
  231. /// @endcond
  232. /// Name of the part index column. By default it is "part_index".
  233. FLUENT_FIELD_OPTION(TString, PartIndexColumnName);
  234. /// Name of the data column. By default it is "data".
  235. FLUENT_FIELD_OPTION(TString, DataColumnName);
  236. ///
  237. /// @brief Size of each part.
  238. ///
  239. /// All blob parts except the last part of the blob must be of this size
  240. /// otherwise blob table reader emits error.
  241. FLUENT_FIELD_DEFAULT(ui64, PartSize, 4 * 1024 * 1024);
  242. /// @brief Offset from which to start reading
  243. FLUENT_FIELD_DEFAULT(i64, Offset, 0);
  244. };
  245. ///
  246. /// @brief Resource limits for operation (or pool)
  247. ///
  248. /// @see https://ytsaurus.tech/docs/en/user-guide/data-processing/scheduler/scheduler-and-pools#resursy
  249. /// @see NYT::TUpdateOperationParametersOptions
  250. struct TResourceLimits
  251. {
  252. /// @cond Doxygen_Suppress
  253. using TSelf = TResourceLimits;
  254. /// @endcond
  255. /// Number of slots for user jobs.
  256. FLUENT_FIELD_OPTION(i64, UserSlots);
  257. /// Number of cpu cores.
  258. FLUENT_FIELD_OPTION(double, Cpu);
  259. /// Network usage. Doesn't have precise physical unit.
  260. FLUENT_FIELD_OPTION(i64, Network);
  261. /// Memory in bytes.
  262. FLUENT_FIELD_OPTION(i64, Memory);
  263. };
  264. ///
  265. /// @brief Scheduling options for single pool tree.
  266. ///
  267. /// @see NYT::TUpdateOperationParametersOptions
  268. struct TSchedulingOptions
  269. {
  270. /// @cond Doxygen_Suppress
  271. using TSelf = TSchedulingOptions;
  272. /// @endcond
  273. ///
  274. /// @brief Pool to switch operation to.
  275. ///
  276. /// @note Switching is currently disabled on the server (will induce an exception).
  277. FLUENT_FIELD_OPTION(TString, Pool);
  278. /// @brief Operation weight.
  279. FLUENT_FIELD_OPTION(double, Weight);
  280. /// @brief Operation resource limits.
  281. FLUENT_FIELD_OPTION(TResourceLimits, ResourceLimits);
  282. };
  283. ///
  284. /// @brief Collection of scheduling options for multiple pool trees.
  285. ///
  286. /// @see NYT::TUpdateOperationParametersOptions
  287. struct TSchedulingOptionsPerPoolTree
  288. {
  289. /// @cond Doxygen_Suppress
  290. using TSelf = TSchedulingOptionsPerPoolTree;
  291. /// @endcond
  292. TSchedulingOptionsPerPoolTree(const THashMap<TString, TSchedulingOptions>& options = {})
  293. : Options_(options)
  294. { }
  295. /// Add scheduling options for pool tree.
  296. TSelf& Add(TStringBuf poolTreeName, const TSchedulingOptions& schedulingOptions)
  297. {
  298. Y_ENSURE(Options_.emplace(poolTreeName, schedulingOptions).second);
  299. return *this;
  300. }
  301. THashMap<TString, TSchedulingOptions> Options_;
  302. };
  303. ///
  304. /// @brief Options for @ref NYT::IOperation::SuspendOperation
  305. ///
  306. /// @see https://ytsaurus.tech/docs/en/api/commands.html#suspend_operation
  307. struct TSuspendOperationOptions
  308. {
  309. /// @cond Doxygen_Suppress
  310. using TSelf = TSuspendOperationOptions;
  311. /// @endcond
  312. ///
  313. /// @brief Whether to abort already running jobs.
  314. ///
  315. /// By default running jobs are not aborted.
  316. FLUENT_FIELD_OPTION(bool, AbortRunningJobs);
  317. };
  318. ///
  319. /// @brief Options for @ref NYT::IOperation::ResumeOperation
  320. ///
  321. /// @note They are empty for now but options might appear in the future.
  322. ///
  323. /// @see https://ytsaurus.tech/docs/en/api/commands.html#resume_operation
  324. struct TResumeOperationOptions
  325. {
  326. /// @cond Doxygen_Suppress
  327. using TSelf = TResumeOperationOptions;
  328. /// @endcond
  329. };
  330. ///
  331. /// @brief Options for @ref NYT::IOperation::UpdateParameters
  332. ///
  333. /// @see https://ytsaurus.tech/docs/en/api/commands.html#update_operation_parameters
  334. struct TUpdateOperationParametersOptions
  335. {
  336. /// @cond Doxygen_Suppress
  337. using TSelf = TUpdateOperationParametersOptions;
  338. /// @endcond
  339. /// New owners of the operation.
  340. FLUENT_VECTOR_FIELD(TString, Owner);
  341. /// Pool to switch operation to (for all pool trees it is running in).
  342. FLUENT_FIELD_OPTION(TString, Pool);
  343. /// New operation weight (for all pool trees it is running in).
  344. FLUENT_FIELD_OPTION(double, Weight);
  345. /// Scheduling options for each pool tree the operation is running in.
  346. FLUENT_FIELD_OPTION(TSchedulingOptionsPerPoolTree, SchedulingOptionsPerPoolTree);
  347. };
  348. ///
  349. /// @brief Base class for many options related to IO.
  350. ///
  351. /// @ref NYT::TFileWriterOptions
  352. /// @ref NYT::TFileReaderOptions
  353. /// @ref NYT::TTableReaderOptions
  354. /// @ref NYT::TTableWriterOptions
  355. template <class TDerived>
  356. struct TIOOptions
  357. {
  358. /// @cond Doxygen_Suppress
  359. using TSelf = TDerived;
  360. /// @endcond
  361. ///
  362. /// @brief Advanced options for reader/writer.
  363. ///
  364. /// Readers/writers have many options not of all of them are supported by library.
  365. /// If you need such unsupported option, you might use `Config` option until
  366. /// option is supported.
  367. ///
  368. /// Example:
  369. ///
  370. /// TTableWriterOptions().Config(TNode()("max_row_weight", 64 << 20)))
  371. ///
  372. /// @note We encourage you to ask yt@ to add native C++ support of required options
  373. /// and use `Config` only as temporary solution while native support is not ready.
  374. FLUENT_FIELD_OPTION(TNode, Config);
  375. ///
  376. /// @brief Whether to create internal client transaction for reading / writing table.
  377. ///
  378. /// This is advanced option.
  379. ///
  380. /// If `CreateTransaction` is set to `false` reader/writer doesn't create internal transaction
  381. /// and doesn't lock table. This option is overridden (effectively `false`) for writers by
  382. /// @ref NYT::TTableWriterOptions::SingleHttpRequest
  383. ///
  384. /// WARNING: if `CreateTransaction` is `false`, read/write might become non-atomic.
  385. /// Change ONLY if you are sure what you are doing!
  386. FLUENT_FIELD_DEFAULT(bool, CreateTransaction, true);
  387. };
  388. /// @brief Options for reading file from YT.
  389. struct TFileReaderOptions
  390. : public TIOOptions<TFileReaderOptions>
  391. {
  392. ///
  393. /// @brief Offset to start reading from.
  394. ///
  395. /// By default reading is started from the beginning of the file.
  396. FLUENT_FIELD_OPTION(i64, Offset);
  397. ///
  398. /// @brief Maximum length to read.
  399. ///
  400. /// By default file is read until the end.
  401. FLUENT_FIELD_OPTION(i64, Length);
  402. };
  403. /// @brief Options that control how server side of YT stores data.
  404. struct TWriterOptions
  405. {
  406. /// @cond Doxygen_Suppress
  407. using TSelf = TWriterOptions;
  408. /// @endcond
  409. ///
  410. /// @brief Whether to wait all replicas to be written.
  411. ///
  412. /// When set to true upload will be considered successful as soon as
  413. /// @ref NYT::TWriterOptions::MinUploadReplicationFactor number of replicas are created.
  414. FLUENT_FIELD_OPTION(bool, EnableEarlyFinish);
  415. /// Number of replicas to be created.
  416. FLUENT_FIELD_OPTION(ui64, UploadReplicationFactor);
  417. ///
  418. /// Min number of created replicas needed to consider upload successful.
  419. ///
  420. /// @see NYT::TWriterOptions::EnableEarlyFinish
  421. FLUENT_FIELD_OPTION(ui64, MinUploadReplicationFactor);
  422. ///
  423. /// @brief Desired size of a chunk.
  424. ///
  425. /// @see @ref NYT::TWriterOptions::RetryBlockSize
  426. FLUENT_FIELD_OPTION(ui64, DesiredChunkSize);
  427. ///
  428. /// @brief Size of data block accumulated in memory to provide retries.
  429. ///
  430. /// Data is accumulated in memory buffer so in case error occurs data could be resended.
  431. ///
  432. /// If `RetryBlockSize` is not set buffer size is set to `DesiredChunkSize`.
  433. /// If neither `RetryBlockSize` nor `DesiredChunkSize` is set size of buffer is 64MB.
  434. ///
  435. /// @note Written chunks cannot be larger than size of this memory buffer.
  436. ///
  437. /// Since DesiredChunkSize is compared against data already compressed with compression codec
  438. /// it makes sense to set `RetryBlockSize = DesiredChunkSize / ExpectedCompressionRatio`
  439. ///
  440. /// @see @ref NYT::TWriterOptions::DesiredChunkSize
  441. /// @see @ref NYT::TTableWriterOptions::SingleHttpRequest
  442. FLUENT_FIELD_OPTION(size_t, RetryBlockSize);
  443. };
  444. ///
  445. /// @brief Options for writing file
  446. ///
  447. /// @see NYT::IIOClient::CreateFileWriter
  448. struct TFileWriterOptions
  449. : public TIOOptions<TFileWriterOptions>
  450. {
  451. ///
  452. /// @brief Whether to compute MD5 sum of written file.
  453. ///
  454. /// If ComputeMD5 is set to `true` and we are appending to an existing file
  455. /// the `md5` attribute must be set (i.e. it was previously written only with `ComputeMD5 == true`).
  456. FLUENT_FIELD_OPTION(bool, ComputeMD5);
  457. ///
  458. /// @brief Wheter to call Finish automatically in writer destructor.
  459. ///
  460. /// If set to true (default) Finish() is called automatically in the destructor of writer.
  461. /// It is convenient for simple usecases but might be error-prone if writing exception safe code
  462. /// (In case of exceptions it's common to abort writer and not commit partial data).
  463. ///
  464. /// If set to false Finish() has to be called explicitly.
  465. FLUENT_FIELD_DEFAULT(bool, AutoFinish, true);
  466. ///
  467. /// @brief Options to control how YT server side writes data.
  468. ///
  469. /// @see NYT::TWriterOptions
  470. FLUENT_FIELD_OPTION(TWriterOptions, WriterOptions);
  471. };
  472. class TSkiffRowHints
  473. {
  474. public:
  475. /// @cond Doxygen_Suppress
  476. using TSelf = TSkiffRowHints;
  477. /// @endcond
  478. ///
  479. /// @brief Library doesn't interpret it, only pass it to CreateSkiffParser<...>() and GetSkiffSchema<...>() functions.
  480. ///
  481. /// You can set something in it to pass necessary information to CreateSkiffParser<...>() and GetSkiffSchema<...>() functions.
  482. FLUENT_FIELD_OPTION(TNode, Attributes);
  483. ///
  484. /// @brief Index of table in parallel table reader.
  485. ///
  486. /// For internal usage only. If you set it, it will be overriden by parallel table reader.
  487. FLUENT_FIELD_OPTION(int, TableIndex);
  488. };
  489. /// Options that control how C++ objects represent table rows when reading or writing a table.
  490. class TFormatHints
  491. {
  492. public:
  493. /// @cond Doxygen_Suppress
  494. using TSelf = TFormatHints;
  495. /// @endcond
  496. ///
  497. /// @brief Whether to skip null values.
  498. ///
  499. /// When set to true TNode doesn't contain null column values
  500. /// (e.g. corresponding keys will be missing instead of containing null value).
  501. ///
  502. /// Only meaningful for TNode representation.
  503. ///
  504. /// Useful for sparse tables which have many columns in schema
  505. /// but only few columns are set in any row.
  506. FLUENT_FIELD_DEFAULT(bool, SkipNullValuesForTNode, false);
  507. ///
  508. /// @brief Whether to convert string to numeric and boolean types (e.g. "42u" -> 42u, "false" -> %false)
  509. /// when writing to schemaful table.
  510. FLUENT_FIELD_OPTION(bool, EnableStringToAllConversion);
  511. ///
  512. /// @brief Whether to convert numeric and boolean types to string (e.g., 3.14 -> "3.14", %true -> "true")
  513. /// when writing to schemaful table.
  514. FLUENT_FIELD_OPTION(bool, EnableAllToStringConversion);
  515. ///
  516. /// @brief Whether to convert uint64 <-> int64 when writing to schemaful table.
  517. ///
  518. /// On overflow the corresponding error with be raised.
  519. ///
  520. /// This options is enabled by default.
  521. FLUENT_FIELD_OPTION(bool, EnableIntegralTypeConversion);
  522. /// Whether to convert uint64 and int64 to double (e.g. 42 -> 42.0) when writing to schemaful table.
  523. FLUENT_FIELD_OPTION(bool, EnableIntegralToDoubleConversion);
  524. /// Shortcut for enabling all type conversions.
  525. FLUENT_FIELD_OPTION(bool, EnableTypeConversion);
  526. ///
  527. /// @brief Controls how complex types are represented in TNode or yson-strings.
  528. ///
  529. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/data-types#yson
  530. FLUENT_FIELD_OPTION(EComplexTypeMode, ComplexTypeMode);
  531. ///
  532. /// @brief Allow to use any meta-information for creating skiff schema and parser for reading ISkiffRow.
  533. FLUENT_FIELD_OPTION(TSkiffRowHints, SkiffRowHints);
  534. ///
  535. /// @brief Apply the patch to the fields.
  536. ///
  537. /// Non-default and non-empty values replace the default and empty ones.
  538. void Merge(const TFormatHints& patch);
  539. };
  540. /// Options that control which control attributes (like row_index) are added to rows during read.
  541. class TControlAttributes
  542. {
  543. public:
  544. /// @cond Doxygen_Suppress
  545. using TSelf = TControlAttributes;
  546. /// @endcond
  547. ///
  548. /// @brief Whether to add "row_index" attribute to rows read.
  549. FLUENT_FIELD_DEFAULT(bool, EnableRowIndex, true);
  550. ///
  551. /// @brief Whether to add "range_index" attribute to rows read.
  552. FLUENT_FIELD_DEFAULT(bool, EnableRangeIndex, true);
  553. };
  554. /// Options for @ref NYT::IClient::CreateTableReader
  555. struct TTableReaderOptions
  556. : public TIOOptions<TTableReaderOptions>
  557. {
  558. /// @deprecated Size of internal client buffer.
  559. FLUENT_FIELD_DEFAULT(size_t, SizeLimit, 4 << 20);
  560. ///
  561. /// @brief Allows to fine tune format that is used for reading tables.
  562. ///
  563. /// Has no effect when used with raw-reader.
  564. FLUENT_FIELD_OPTION(TFormatHints, FormatHints);
  565. ///
  566. /// @brief Allows to tune which attributes are added to rows while reading tables.
  567. ///
  568. FLUENT_FIELD_DEFAULT(TControlAttributes, ControlAttributes, TControlAttributes());
  569. };
  570. /// Options for @ref NYT::IClient::CreateTableWriter
  571. struct TTableWriterOptions
  572. : public TIOOptions<TTableWriterOptions>
  573. {
  574. ///
  575. /// @brief Enable or disable retryful writing.
  576. ///
  577. /// If set to true no retry is made but we also make less requests to master.
  578. /// If set to false writer can make up to `TConfig::RetryCount` attempts to send each block of data.
  579. ///
  580. /// @note Writers' methods might throw strange exceptions that might look like network error
  581. /// when `SingleHttpRequest == true` and YT node encounters an error
  582. /// (due to limitations of HTTP protocol YT node have no chance to report error
  583. /// before it reads the whole input so it just drops the connection).
  584. FLUENT_FIELD_DEFAULT(bool, SingleHttpRequest, false);
  585. ///
  586. /// @brief Allows to change the size of locally buffered rows before flushing to yt.
  587. ///
  588. /// Used only with @ref NYT::TTableWriterOptions::SingleHttpRequest
  589. FLUENT_FIELD_DEFAULT(size_t, BufferSize, 64 << 20);
  590. ///
  591. /// @brief Allows to fine tune format that is used for writing tables.
  592. ///
  593. /// Has no effect when used with raw-writer.
  594. FLUENT_FIELD_OPTION(TFormatHints, FormatHints);
  595. /// @brief Try to infer schema of inexistent table from the type of written rows.
  596. ///
  597. /// @note Default values for this option may differ depending on the row type.
  598. /// For protobuf it's currently false by default.
  599. FLUENT_FIELD_OPTION(bool, InferSchema);
  600. ///
  601. /// @brief Wheter to call Finish automatically in writer destructor.
  602. ///
  603. /// If set to true (default) Finish() is called automatically in the destructor of writer.
  604. /// It is convenient for simple usecases but might be error-prone if writing exception safe code
  605. /// (In case of exceptions it's common to abort writer and not commit partial data).
  606. ///
  607. /// If set to false Finish() has to be called explicitly.
  608. FLUENT_FIELD_DEFAULT(bool, AutoFinish, true);
  609. ///
  610. /// @brief Options to control how YT server side writes data.
  611. ///
  612. /// @see NYT::TWriterOptions
  613. FLUENT_FIELD_OPTION(TWriterOptions, WriterOptions);
  614. };
  615. ///
  616. /// @brief Options for @ref NYT::IClient::StartTransaction
  617. ///
  618. /// @see https://ytsaurus.tech/docs/en/api/commands.html#start_tx
  619. struct TStartTransactionOptions
  620. {
  621. /// @cond Doxygen_Suppress
  622. using TSelf = TStartTransactionOptions;
  623. /// @endcond
  624. FLUENT_FIELD_DEFAULT(bool, PingAncestors, false);
  625. ///
  626. /// @brief How long transaction lives after last ping.
  627. ///
  628. /// If server doesn't receive any pings for transaction for this time
  629. /// transaction will be aborted. By default timeout is 15 seconds.
  630. FLUENT_FIELD_OPTION(TDuration, Timeout);
  631. ///
  632. /// @brief Moment in the future when transaction is aborted.
  633. FLUENT_FIELD_OPTION(TInstant, Deadline);
  634. ///
  635. /// @brief Whether to ping created transaction automatically.
  636. ///
  637. /// When set to true library creates a thread that pings transaction.
  638. /// When set to false library doesn't ping transaction and it's user responsibility to ping it.
  639. FLUENT_FIELD_DEFAULT(bool, AutoPingable, true);
  640. ///
  641. /// @brief Set the title attribute of transaction.
  642. ///
  643. /// If title was not specified
  644. /// neither using this option nor using @ref NYT::TStartTransactionOptions::Attributes option
  645. /// library will generate default title for transaction.
  646. /// Such default title includes machine name, pid, user name and some other useful info.
  647. FLUENT_FIELD_OPTION(TString, Title);
  648. ///
  649. /// @brief Set custom transaction attributes
  650. ///
  651. /// @note @ref NYT::TStartTransactionOptions::Title option overrides `"title"` attribute.
  652. FLUENT_FIELD_OPTION(TNode, Attributes);
  653. };
  654. ///
  655. /// @brief Options for attaching transaction.
  656. ///
  657. /// @see NYT::IClient::AttachTransaction
  658. struct TAttachTransactionOptions
  659. {
  660. /// @cond Doxygen_Suppress
  661. using TSelf = TAttachTransactionOptions;
  662. /// @endcond
  663. ///
  664. /// @brief Ping transaction automatically.
  665. ///
  666. /// When set to |true| library creates a thread that pings transaction.
  667. /// When set to |false| library doesn't ping transaction and
  668. /// it's user responsibility to ping it.
  669. FLUENT_FIELD_DEFAULT(bool, AutoPingable, false);
  670. ///
  671. /// @brief Abort transaction on program termination.
  672. ///
  673. /// Should the transaction be aborted on program termination
  674. /// (either normal or by a signal or uncaught exception -- two latter
  675. /// only if @ref TInitializeOptions::CleanupOnTermination is set).
  676. FLUENT_FIELD_DEFAULT(bool, AbortOnTermination, false);
  677. };
  678. ///
  679. /// @brief Type of the lock.
  680. ///
  681. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/transactions#locking_mode
  682. /// @see NYT::ITransaction::Lock
  683. enum ELockMode : int
  684. {
  685. /// Exclusive lock.
  686. LM_EXCLUSIVE /* "exclusive" */,
  687. /// Shared lock.
  688. LM_SHARED /* "shared" */,
  689. /// Snapshot lock.
  690. LM_SNAPSHOT /* "snapshot" */,
  691. };
  692. ///
  693. /// @brief Options for locking cypress node
  694. ///
  695. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/transactions#locks
  696. /// @see NYT::ITransaction::Lock
  697. struct TLockOptions
  698. {
  699. /// @cond Doxygen_Suppress
  700. using TSelf = TLockOptions;
  701. /// @endcond
  702. ///
  703. /// @brief Whether to wait already locked node to be unlocked.
  704. ///
  705. /// If `Waitable' is set to true Lock method will create
  706. /// waitable lock, that will be taken once other transactions
  707. /// that hold lock to that node are committed / aborted.
  708. ///
  709. /// @note Lock method DOES NOT wait until lock is actually acquired.
  710. /// Waiting should be done using corresponding methods of ILock.
  711. ///
  712. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/transactions#locking_queue
  713. FLUENT_FIELD_DEFAULT(bool, Waitable, false);
  714. ///
  715. /// @brief Also take attribute_key lock.
  716. ///
  717. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/transactions#locks_compatibility
  718. FLUENT_FIELD_OPTION(TString, AttributeKey);
  719. ///
  720. /// @brief Also take child_key lock.
  721. ///
  722. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/transactions#locks_compatibility
  723. FLUENT_FIELD_OPTION(TString, ChildKey);
  724. };
  725. ///
  726. /// @brief Options for @ref NYT::ITransaction::Unlock
  727. ///
  728. /// @note They are empty for now but options might appear in the future.
  729. ///
  730. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/transactions#locks_compatibility
  731. struct TUnlockOptions
  732. {
  733. /// @cond Doxygen_Suppress
  734. using TSelf = TUnlockOptions;
  735. /// @endcond
  736. };
  737. /// Base class for options that deal with tablets.
  738. template <class TDerived>
  739. struct TTabletOptions
  740. {
  741. /// @cond Doxygen_Suppress
  742. using TSelf = TDerived;
  743. /// @endcond
  744. /// Index of a first tablet to deal with.
  745. FLUENT_FIELD_OPTION(i64, FirstTabletIndex);
  746. /// Index of a last tablet to deal with.
  747. FLUENT_FIELD_OPTION(i64, LastTabletIndex);
  748. };
  749. ///
  750. /// @brief Options for @ref NYT::IClient::MountTable
  751. ///
  752. /// @see https://ytsaurus.tech/docs/en/api/commands#mount_table
  753. struct TMountTableOptions
  754. : public TTabletOptions<TMountTableOptions>
  755. {
  756. /// @cond Doxygen_Suppress
  757. using TSelf = TMountTableOptions;
  758. /// @endcond
  759. /// If specified table will be mounted to this cell.
  760. FLUENT_FIELD_OPTION(TTabletCellId, CellId);
  761. /// If set to true tablets will be mounted in freezed state.
  762. FLUENT_FIELD_DEFAULT(bool, Freeze, false);
  763. };
  764. ///
  765. /// @brief Options for @ref NYT::IClient::UnmountTable
  766. ///
  767. /// @see https://ytsaurus.tech/docs/en/api/commands#unmount_table
  768. struct TUnmountTableOptions
  769. : public TTabletOptions<TUnmountTableOptions>
  770. {
  771. /// @cond Doxygen_Suppress
  772. using TSelf = TUnmountTableOptions;
  773. /// @endcond
  774. /// Advanced option, don't use unless yt team told you so.
  775. FLUENT_FIELD_DEFAULT(bool, Force, false);
  776. };
  777. ///
  778. /// @brief Options for @ref NYT::IClient::RemountTable
  779. ///
  780. /// @see https://ytsaurus.tech/docs/en/api/commands#remount_table
  781. struct TRemountTableOptions
  782. : public TTabletOptions<TRemountTableOptions>
  783. { };
  784. ///
  785. /// @brief Options for @ref NYT::IClient::ReshardTable
  786. ///
  787. /// @see https://ytsaurus.tech/docs/en/api/commands#reshard_table
  788. struct TReshardTableOptions
  789. : public TTabletOptions<TReshardTableOptions>
  790. { };
  791. ///
  792. /// @brief Options for @ref NYT::IClient::FreezeTable
  793. ///
  794. /// @see https://ytsaurus.tech/docs/en/api/commands#freeze_table
  795. struct TFreezeTableOptions
  796. : public TTabletOptions<TFreezeTableOptions>
  797. { };
  798. ///
  799. /// @brief Options for @ref NYT::IClient::UnfreezeTable
  800. ///
  801. /// @see https://ytsaurus.tech/docs/en/api/commands#unfreeze_table
  802. struct TUnfreezeTableOptions
  803. : public TTabletOptions<TUnfreezeTableOptions>
  804. { };
  805. ///
  806. /// @brief Options for @ref NYT::IClient::AlterTable
  807. ///
  808. /// @see https://ytsaurus.tech/docs/en/api/commands#alter_table
  809. struct TAlterTableOptions
  810. {
  811. /// @cond Doxygen_Suppress
  812. using TSelf = TAlterTableOptions;
  813. /// @endcond
  814. /// Change table schema.
  815. FLUENT_FIELD_OPTION(TTableSchema, Schema);
  816. /// Alter table between static and dynamic mode.
  817. FLUENT_FIELD_OPTION(bool, Dynamic);
  818. ///
  819. /// @brief Changes id of upstream replica on metacluster.
  820. ///
  821. /// @see https://ytsaurus.tech/docs/en/description/dynamic_tables/replicated_dynamic_tables
  822. FLUENT_FIELD_OPTION(TReplicaId, UpstreamReplicaId);
  823. };
  824. ///
  825. /// @brief Options for @ref NYT::IClient::LookupRows
  826. ///
  827. /// @see https://ytsaurus.tech/docs/en/api/commands#lookup_rows
  828. struct TLookupRowsOptions
  829. {
  830. /// @cond Doxygen_Suppress
  831. using TSelf = TLookupRowsOptions;
  832. /// @endcond
  833. /// Timeout for operation.
  834. FLUENT_FIELD_OPTION(TDuration, Timeout);
  835. /// Column names to return.
  836. FLUENT_FIELD_OPTION(TColumnNames, Columns);
  837. ///
  838. /// @brief Whether to return rows that were not found in table.
  839. ///
  840. /// If set to true List returned by LookupRows method will have same
  841. /// length as list of keys. If row is not found in table corresponding item in list
  842. /// will have null value.
  843. FLUENT_FIELD_DEFAULT(bool, KeepMissingRows, false);
  844. /// If set to true returned values will have "timestamp" attribute.
  845. FLUENT_FIELD_OPTION(bool, Versioned);
  846. };
  847. ///
  848. /// @brief Options for @ref NYT::IClient::SelectRows
  849. ///
  850. /// @see https://ytsaurus.tech/docs/en/api/commands#select_rows
  851. struct TSelectRowsOptions
  852. {
  853. /// @cond Doxygen_Suppress
  854. using TSelf = TSelectRowsOptions;
  855. /// @endcond
  856. /// Timeout for operation.
  857. FLUENT_FIELD_OPTION(TDuration, Timeout);
  858. ///
  859. /// @brief Limitation for number of rows read by single node.
  860. ///
  861. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/dyn-query-language#query-complexity-limits-options
  862. FLUENT_FIELD_OPTION(i64, InputRowLimit);
  863. ///
  864. /// @brief Limitation for number of output rows on single cluster node.
  865. ///
  866. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/dyn-query-language#query-complexity-limits-options
  867. FLUENT_FIELD_OPTION(i64, OutputRowLimit);
  868. ///
  869. /// @brief Maximum row ranges derived from WHERE clause.
  870. ///
  871. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/dyn-query-language#query-complexity-limits-options
  872. FLUENT_FIELD_DEFAULT(ui64, RangeExpansionLimit, 1000);
  873. ///
  874. /// @brief Whether to fail if InputRowLimit or OutputRowLimit is exceeded.
  875. ///
  876. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/dyn-query-language#query-complexity-limits-options
  877. FLUENT_FIELD_DEFAULT(bool, FailOnIncompleteResult, true);
  878. /// @brief Enable verbose logging on server side.
  879. FLUENT_FIELD_DEFAULT(bool, VerboseLogging, false);
  880. FLUENT_FIELD_DEFAULT(bool, EnableCodeCache, true);
  881. };
  882. /// Options for NYT::CreateClient;
  883. struct TCreateClientOptions
  884. {
  885. /// @cond Doxygen_Suppress
  886. using TSelf = TCreateClientOptions;
  887. /// @endcond
  888. /// @brief Impersonated user name.
  889. ///
  890. /// If authenticated user is allowed to impersonate other YT users (e.g. yql_agent), this field may be used to override user name.
  891. FLUENT_FIELD_OPTION(TString, ImpersonationUser);
  892. /// @brief User token.
  893. ///
  894. /// @see NYT::TCreateClientOptions::TokenPath
  895. FLUENT_FIELD(TString, Token);
  896. /// @brief Path to the file where user token is stored.
  897. ///
  898. /// Token is looked in these places in following order:
  899. /// - @ref NYT::TCreateClientOptions::Token
  900. /// - @ref NYT::TCreateClientOptions::TokenPath
  901. /// - `TConfig::Get()->Token` option.
  902. /// - `YT_TOKEN` environment variable
  903. /// - `YT_SECURE_VAULT_YT_TOKEN` environment variable
  904. /// - File specified in `YT_TOKEN_PATH` environment variable
  905. /// - `$HOME/.yt/token` file.
  906. FLUENT_FIELD(TString, TokenPath);
  907. /// @brief TVM service ticket producer.
  908. ///
  909. /// We store a wrapper of NYT::TIntrusivePtr here (not a NYT::TIntrusivePtr),
  910. /// because otherwise other projects will have build problems
  911. /// because of visibility of two different `TIntrusivePtr`-s (::TInstrusivePtr and NYT::TInstrusivePtr).
  912. ///
  913. /// @see NYT::NAuth::TServiceTicketClientAuth
  914. /// {@
  915. NAuth::IServiceTicketAuthPtrWrapperPtr ServiceTicketAuth_ = nullptr;
  916. TSelf& ServiceTicketAuth(const NAuth::IServiceTicketAuthPtrWrapper& wrapper);
  917. /// @}
  918. /// @brief Use tvm-only endpoints in cluster connection.
  919. FLUENT_FIELD_DEFAULT(bool, TvmOnly, false);
  920. /// @brief Use HTTPs (use HTTP client from yt/yt/core always).
  921. ///
  922. /// @see UseCoreHttpClient
  923. FLUENT_FIELD_OPTION(bool, UseTLS);
  924. /// @brief Use HTTP client from yt/yt/core.
  925. FLUENT_FIELD_DEFAULT(bool, UseCoreHttpClient, false);
  926. ///
  927. /// @brief RetryConfig provider allows to fine tune request retries.
  928. ///
  929. /// E.g. set total timeout for all retries.
  930. FLUENT_FIELD_DEFAULT(IRetryConfigProviderPtr, RetryConfigProvider, nullptr);
  931. /// @brief Override global config for the client.
  932. ///
  933. /// The config contains implementation parameters such as connection timeouts,
  934. /// access token, api version and more.
  935. /// @see NYT::TConfig
  936. FLUENT_FIELD_DEFAULT(TConfigPtr, Config, nullptr);
  937. /// @brief Proxy Address to be used for connection
  938. FLUENT_FIELD_OPTION(TString, ProxyAddress);
  939. };
  940. ///
  941. /// @brief Options for @ref NYT::IBatchRequest::ExecuteBatch
  942. ///
  943. /// @see https://ytsaurus.tech/docs/en/api/commands#execute_batch
  944. struct TExecuteBatchOptions
  945. {
  946. /// @cond Doxygen_Suppress
  947. using TSelf = TExecuteBatchOptions;
  948. /// @endcond
  949. ///
  950. /// @brief How many requests will be executed in parallel on the cluster.
  951. ///
  952. /// This parameter could be used to avoid RequestLimitExceeded errors.
  953. FLUENT_FIELD_OPTION(ui64, Concurrency);
  954. ///
  955. /// @brief Maximum size of batch sent in one request to server.
  956. ///
  957. /// Huge batches are executed using multiple requests.
  958. /// BatchPartMaxSize is maximum size of single request that goes to server
  959. /// If not specified it is set to `Concurrency * 5'
  960. FLUENT_FIELD_OPTION(ui64, BatchPartMaxSize);
  961. };
  962. ///
  963. /// @brief Durability mode.
  964. ///
  965. /// @see NYT::TTabletTransactionOptions::TDurability
  966. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/sorted-dynamic-tables
  967. enum class EDurability
  968. {
  969. /// Sync mode (default).
  970. Sync /* "sync" */,
  971. /// Async mode (might reduce latency of write requests, but less reliable).
  972. Async /* "async" */,
  973. };
  974. ///
  975. /// @brief Atomicity mode.
  976. ///
  977. /// @see NYT::TTabletTransactionOptions::TDurability
  978. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/sorted-dynamic-tables
  979. enum class EAtomicity
  980. {
  981. /// Transactions are non atomic (might reduce latency of write requests).
  982. None /* "none" */,
  983. /// Transactions are atomic (default).
  984. Full /* "full" */,
  985. };
  986. ///
  987. /// @brief Table replica mode.
  988. ///
  989. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/replicated-dynamic-tables#attributes
  990. enum class ETableReplicaMode
  991. {
  992. Sync /* "sync" */,
  993. Async /* "async" */,
  994. };
  995. /// Base class for options dealing with io to dynamic tables.
  996. template <typename TDerived>
  997. struct TTabletTransactionOptions
  998. {
  999. /// @cond Doxygen_Suppress
  1000. using TSelf = TDerived;
  1001. /// @endcond
  1002. ///
  1003. /// @brief Atomicity mode of operation
  1004. ///
  1005. /// Setting to NYT::EAtomicity::None allows to improve latency of operations
  1006. /// at the cost of weakening contracts.
  1007. ///
  1008. /// @note Use with care.
  1009. ///
  1010. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/sorted-dynamic-tables
  1011. FLUENT_FIELD_OPTION(EAtomicity, Atomicity);
  1012. ///
  1013. /// @brief Durability mode of operation
  1014. ///
  1015. /// Setting to NYT::EDurability::Async allows to improve latency of operations
  1016. /// at the cost of weakening contracts.
  1017. ///
  1018. /// @note Use with care.
  1019. ///
  1020. /// @see https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/sorted-dynamic-tables
  1021. FLUENT_FIELD_OPTION(EDurability, Durability);
  1022. };
  1023. ///
  1024. /// @brief Options for NYT::IClient::InsertRows
  1025. ///
  1026. /// @see https://ytsaurus.tech/docs/en/api/commands.html#insert_rows
  1027. struct TInsertRowsOptions
  1028. : public TTabletTransactionOptions<TInsertRowsOptions>
  1029. {
  1030. ///
  1031. /// @brief Whether to overwrite missing columns with nulls.
  1032. ///
  1033. /// By default all columns missing in input data are set to Null and overwrite currently stored value.
  1034. /// If `Update' is set to true currently stored value will not be overwritten for columns that are missing in input data.
  1035. FLUENT_FIELD_OPTION(bool, Update);
  1036. ///
  1037. /// @brief Whether to overwrite or aggregate aggregated columns.
  1038. ///
  1039. /// Used with aggregating columns.
  1040. /// By default value in aggregating column will be overwritten.
  1041. /// If `Aggregate' is set to true row will be considered as delta and it will be aggregated with currently stored value.
  1042. FLUENT_FIELD_OPTION(bool, Aggregate);
  1043. ///
  1044. /// @brief Whether to fail when inserting to table without sync replica.
  1045. ///
  1046. /// Used for insert operation for tables without sync replica.
  1047. /// https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/replicated-dynamic-tables#write
  1048. /// Default value is 'false'. So insertion into table without sync replicas fails.
  1049. FLUENT_FIELD_OPTION(bool, RequireSyncReplica);
  1050. };
  1051. ///
  1052. /// @brief Options for NYT::IClient::DeleteRows
  1053. ///
  1054. /// @see https://ytsaurus.tech/docs/en/api/commands.html#delete_rows
  1055. struct TDeleteRowsOptions
  1056. : public TTabletTransactionOptions<TDeleteRowsOptions>
  1057. {
  1058. ///
  1059. /// @brief Whether to fail when deleting from table without sync replica.
  1060. ///
  1061. // Used for delete operation for tables without sync replica.
  1062. /// https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/replicated-dynamic-tables#write
  1063. // Default value is 'false'. So deletion into table without sync replicas fails.
  1064. FLUENT_FIELD_OPTION(bool, RequireSyncReplica);
  1065. };
  1066. ///
  1067. /// @brief Options for NYT::IClient::TrimRows
  1068. ///
  1069. /// @see https://ytsaurus.tech/docs/en/api/commands.html#trim_rows
  1070. struct TTrimRowsOptions
  1071. : public TTabletTransactionOptions<TTrimRowsOptions>
  1072. { };
  1073. /// @brief Options for NYT::IClient::AlterTableReplica
  1074. ///
  1075. /// @see https://ytsaurus.tech/docs/en/api/commands.html#alter_table_replica
  1076. /// https://ytsaurus.tech/docs/en/user-guide/dynamic-tables/replicated-dynamic-tables
  1077. struct TAlterTableReplicaOptions
  1078. {
  1079. /// @cond Doxygen_Suppress
  1080. using TSelf = TAlterTableReplicaOptions;
  1081. /// @endcond
  1082. ///
  1083. /// @brief Whether to enable or disable replica.
  1084. ///
  1085. /// Doesn't change state of replica if `Enabled' is not set.
  1086. FLUENT_FIELD_OPTION(bool, Enabled);
  1087. ///
  1088. /// @brief Change replica mode.
  1089. ///
  1090. /// Doesn't change replica mode if `Mode` is not set.
  1091. FLUENT_FIELD_OPTION(ETableReplicaMode, Mode);
  1092. };
  1093. ///
  1094. /// @brief Options for @ref NYT::IClient::GetFileFromCache
  1095. ///
  1096. /// @note They are empty for now but options might appear in the future.
  1097. ///
  1098. /// @see https://ytsaurus.tech/docs/en/api/commands.html#get_file_from_cache
  1099. struct TGetFileFromCacheOptions
  1100. {
  1101. /// @cond Doxygen_Suppress
  1102. using TSelf = TGetFileFromCacheOptions;
  1103. /// @endcond
  1104. };
  1105. ///
  1106. /// @brief Options for @ref NYT::IClient::GetTableColumnarStatistics
  1107. ///
  1108. /// @note They are empty for now but options might appear in the future.
  1109. ///
  1110. /// @see https://ytsaurus.tech/docs/en/api/commands.html#put_file_to_cache
  1111. struct TPutFileToCacheOptions
  1112. {
  1113. /// @cond Doxygen_Suppress
  1114. using TSelf = TPutFileToCacheOptions;
  1115. /// @endcond
  1116. /// Whether to preserve `expiration_timeout` attribute of source node.
  1117. FLUENT_FIELD_OPTION(bool, PreserveExpirationTimeout);
  1118. };
  1119. ///
  1120. /// Type of permission used in ACL.
  1121. ///
  1122. /// @see https://ytsaurus.tech/docs/en/user-guide/storage/access-control
  1123. enum class EPermission : int
  1124. {
  1125. /// Applies to: all objects.
  1126. Read /* "read" */,
  1127. /// Applies to: all objects.
  1128. Write /* "write" */,
  1129. /// Applies to: accounts / pools.
  1130. Use /* "use" */,
  1131. /// Applies to: all objects.
  1132. Administer /* "administer" */,
  1133. /// Applies to: schemas.
  1134. Create /* "create" */,
  1135. /// Applies to: all objects.
  1136. Remove /* "remove" */,
  1137. /// Applies to: tables.
  1138. Mount /* "mount" */,
  1139. /// Applies to: operations.
  1140. Manage /* "manage" */,
  1141. };
  1142. /// Whether permission is granted or denied.
  1143. enum class ESecurityAction : int
  1144. {
  1145. /// Permission is granted.
  1146. Allow /* "allow" */,
  1147. /// Permission is denied.
  1148. Deny /* "deny" */,
  1149. };
  1150. ///
  1151. /// @brief Options for @ref NYT::IClient::CheckPermission
  1152. ///
  1153. /// @see https://ytsaurus.tech/docs/en/api/commands.html#check_permission
  1154. struct TCheckPermissionOptions
  1155. {
  1156. /// @cond Doxygen_Suppress
  1157. using TSelf = TCheckPermissionOptions;
  1158. /// @endcond
  1159. /// Columns to check permission to (for tables only).
  1160. FLUENT_VECTOR_FIELD(TString, Column);
  1161. };
  1162. ///
  1163. /// @brief Columnar statistics fetching mode.
  1164. ///
  1165. /// @ref NYT::TGetTableColumnarStatisticsOptions::FetcherMode
  1166. enum class EColumnarStatisticsFetcherMode
  1167. {
  1168. /// Slow mode for fetching precise columnar statistics.
  1169. FromNodes /* "from_nodes" */,
  1170. ///
  1171. /// @brief Fast mode for fetching lightweight columnar statistics.
  1172. ///
  1173. /// Relative precision is 1 / 256.
  1174. ///
  1175. /// @note Might be unavailable for old tables in that case some upper bound is returned.
  1176. FromMaster /* "from_master" */,
  1177. /// Use lightweight columnar statistics (FromMaster) if available otherwise switch to slow but precise mode (FromNodes).
  1178. Fallback /* "fallback" */,
  1179. };
  1180. ///
  1181. /// @brief Options for @ref NYT::IClient::GetTableColumnarStatistics
  1182. ///
  1183. /// @see https://ytsaurus.tech/docs/en/api/commands.html#get_table_columnar_statistics
  1184. struct TGetTableColumnarStatisticsOptions
  1185. {
  1186. /// @cond Doxygen_Suppress
  1187. using TSelf = TGetTableColumnarStatisticsOptions;
  1188. /// @endcond
  1189. ///
  1190. /// @brief Mode of statistics fetching.
  1191. ///
  1192. /// @ref NYT::EColumnarStatisticsFetcherMode
  1193. FLUENT_FIELD_OPTION(EColumnarStatisticsFetcherMode, FetcherMode);
  1194. };
  1195. ///
  1196. /// @brief Table partitioning mode.
  1197. ///
  1198. /// @ref NYT::TGetTablePartitionsOptions::PartitionMode
  1199. enum class ETablePartitionMode
  1200. {
  1201. ///
  1202. /// @brief Ignores the order of input tables and their chunk and sorting orders.
  1203. ///
  1204. Unordered /* "unordered" */,
  1205. ///
  1206. /// @brief The order of table ranges inside each partition obey the order of input tables and their chunk orders.
  1207. ///
  1208. Ordered /* "ordered" */,
  1209. };
  1210. ///
  1211. /// @brief Options for @ref NYT::IClient::GetTablePartitions
  1212. ///
  1213. struct TGetTablePartitionsOptions
  1214. {
  1215. /// @cond Doxygen_Suppress
  1216. using TSelf = TGetTablePartitionsOptions;
  1217. /// @endcond
  1218. ///
  1219. /// @brief Table partitioning mode.
  1220. ///
  1221. /// @ref NYT::ETablePartitionMode
  1222. FLUENT_FIELD(ETablePartitionMode, PartitionMode);
  1223. ///
  1224. /// @brief Approximate data weight of each output partition.
  1225. ///
  1226. FLUENT_FIELD(i64, DataWeightPerPartition);
  1227. ///
  1228. /// @brief Maximum output partition count.
  1229. ///
  1230. /// Consider the situation when the `MaxPartitionCount` is given
  1231. /// and the total data weight exceeds `MaxPartitionCount * DataWeightPerPartition`.
  1232. /// If `AdjustDataWeightPerPartition` is |true|
  1233. /// `GetTablePartitions` will yield partitions exceeding the `DataWeightPerPartition`.
  1234. /// If `AdjustDataWeightPerPartition` is |false|
  1235. /// the partitioning will be aborted as soon as the output partition count exceeds this limit.
  1236. FLUENT_FIELD_OPTION(int, MaxPartitionCount);
  1237. ///
  1238. /// @brief Allow the data weight per partition to exceed `DataWeightPerPartition` when `MaxPartitionCount` is set.
  1239. ///
  1240. /// |True| by default.
  1241. FLUENT_FIELD_DEFAULT(bool, AdjustDataWeightPerPartition, true);
  1242. };
  1243. ///
  1244. /// @brief Options for @ref NYT::IClient::GetTabletInfos
  1245. ///
  1246. /// @note They are empty for now but options might appear in the future.
  1247. ///
  1248. /// @see https://ytsaurus.tech/docs/en/api/commands.html#get_tablet_infos
  1249. struct TGetTabletInfosOptions
  1250. {
  1251. /// @cond Doxygen_Suppress
  1252. using TSelf = TGetTabletInfosOptions;
  1253. /// @endcond
  1254. };
  1255. /// Options for @ref NYT::IClient::SkyShareTable
  1256. struct TSkyShareTableOptions
  1257. {
  1258. /// @cond Doxygen_Suppress
  1259. using TSelf = TSkyShareTableOptions;
  1260. /// @endcond
  1261. ///
  1262. /// @brief Key columns that are used to group files in a table into torrents.
  1263. ///
  1264. /// One torrent is created for each value of `KeyColumns` columns.
  1265. /// If not specified, all files go into single torrent.
  1266. FLUENT_FIELD_OPTION(TColumnNames, KeyColumns);
  1267. /// @brief Allow skynet manager to return fastbone links to skynet. See YT-11437
  1268. FLUENT_FIELD_OPTION(bool, EnableFastbone);
  1269. };
  1270. ////////////////////////////////////////////////////////////////////////////////
  1271. } // namespace NYT