client_method_options.h 45 KB

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