client_method_options.h 46 KB

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