client_method_options.h 45 KB

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