client_method_options.h 46 KB

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