client_method_options.h 44 KB

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