C++ YT Wrapper
C++ library for working with YT clusters
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1#pragma once
2
7
8#include "fwd.h"
9
10#include <library/cpp/type_info/type_info.h>
11#include <library/cpp/yson/node/node.h>
12
13#include <util/generic/guid.h>
14#include <util/generic/map.h>
15#include <util/generic/maybe.h>
16#include <util/generic/ptr.h>
17#include <util/generic/vector.h>
18
19#include <google/protobuf/message.h>
20
21#include <initializer_list>
22#include <type_traits>
23
24namespace NYT {
25
27
29#define FLUENT_FIELD(type, name) \
30 type name##_; \
31 TSelf& name(const type& value) \
32 { \
33 name##_ = value; \
34 return static_cast<TSelf&>(*this); \
35 } \
36 static_assert(true)
37
38#define FLUENT_FIELD_ENCAPSULATED(type, name) \
39private: \
40 type name##_; \
41public: \
42 TSelf& name(const type& value) & \
43 { \
44 name##_ = value; \
45 return static_cast<TSelf&>(*this); \
46 } \
47 TSelf name(const type& value) && \
48 { \
49 name##_ = value; \
50 return static_cast<TSelf&>(*this); \
51 } \
52 const type& name() const & \
53 { \
54 return name##_; \
55 } \
56 type name() && \
57 { \
58 return name##_; \
59 } \
60 static_assert(true)
61
62#define FLUENT_FIELD_OPTION(type, name) \
63 TMaybe<type> name##_; \
64 TSelf& name(const type& value) \
65 { \
66 name##_ = value; \
67 return static_cast<TSelf&>(*this); \
68 } \
69 static_assert(true)
70
71#define FLUENT_FIELD_OPTION_ENCAPSULATED(type, name) \
72private: \
73 TMaybe<type> name##_; \
74public: \
75 TSelf& name(const type& value) & \
76 { \
77 name##_ = value; \
78 return static_cast<TSelf&>(*this); \
79 } \
80 TSelf name(const type& value) && \
81 { \
82 name##_ = value; \
83 return static_cast<TSelf&>(*this); \
84 } \
85 TSelf& Reset##name() & \
86 { \
87 name##_ = Nothing(); \
88 return static_cast<TSelf&>(*this); \
89 } \
90 TSelf Reset##name() && \
91 { \
92 name##_ = Nothing(); \
93 return static_cast<TSelf&>(*this); \
94 } \
95 const TMaybe<type>& name() const& \
96 { \
97 return name##_; \
98 } \
99 TMaybe<type> name() && \
100 { \
101 return name##_; \
102 } \
103 static_assert(true)
104
105#define FLUENT_FIELD_DEFAULT(type, name, defaultValue) \
106 type name##_ = defaultValue; \
107 TSelf& name(const type& value) \
108 { \
109 name##_ = value; \
110 return static_cast<TSelf&>(*this); \
111 } \
112 static_assert(true)
113
114#define FLUENT_FIELD_DEFAULT_ENCAPSULATED(type, name, defaultValue) \
115private: \
116 type name##_ = defaultValue; \
117public: \
118 TSelf& name(const type& value) & \
119 { \
120 name##_ = value; \
121 return static_cast<TSelf&>(*this); \
122 } \
123 TSelf name(const type& value) && \
124 { \
125 name##_ = value; \
126 return static_cast<TSelf&>(*this); \
127 } \
128 const type& name() const & \
129 { \
130 return name##_; \
131 } \
132 type name() && \
133 { \
134 return name##_; \
135 } \
136 static_assert(true)
137
138#define FLUENT_VECTOR_FIELD(type, name) \
139 TVector<type> name##s_; \
140 TSelf& Add##name(const type& value) \
141 { \
142 name##s_.push_back(value); \
143 return static_cast<TSelf&>(*this);\
144 } \
145 TSelf& name##s(TVector<type> values) \
146 { \
147 name##s_ = std::move(values); \
148 return static_cast<TSelf&>(*this);\
149 } \
150 static_assert(true)
151
152#define FLUENT_OPTIONAL_VECTOR_FIELD_ENCAPSULATED(type, name) \
153private: \
154 TMaybe<TVector<type>> name##s_; \
155public: \
156 const TMaybe<TVector<type>>& name##s() const & { \
157 return name##s_; \
158 } \
159 TMaybe<TVector<type>>& name##s() & { \
160 return name##s_; \
161 } \
162 TMaybe<TVector<type>> name##s() && { \
163 return std::move(name##s_); \
164 } \
165 TSelf& Add##name(const type& value) & \
166 { \
167 if (name##s_.Empty()) { \
168 name##s_.ConstructInPlace(); \
169 } \
170 name##s_->push_back(value); \
171 return static_cast<TSelf&>(*this);\
172 } \
173 TSelf Add##name(const type& value) && \
174 { \
175 if (name##s_.Empty()) { \
176 name##s_.ConstructInPlace(); \
177 } \
178 name##s_->push_back(value); \
179 return static_cast<TSelf&&>(*this);\
180 } \
181 TSelf& name##s(TVector<type> values) & \
182 { \
183 name##s_ = std::move(values); \
184 return static_cast<TSelf&>(*this);\
185 } \
186 TSelf name##s(TVector<type> values) && \
187 { \
188 name##s_ = std::move(values); \
189 return static_cast<TSelf&&>(*this);\
190 } \
191 TSelf& name##s(TNothing) & \
192 { \
193 name##s_ = Nothing(); \
194 return static_cast<TSelf&>(*this);\
195 } \
196 TSelf name##s(TNothing) && \
197 { \
198 name##s_ = Nothing(); \
199 return static_cast<TSelf&&>(*this);\
200 } \
201 TSelf& Reset##name##s() & \
202 { \
203 name##s_ = Nothing(); \
204 return static_cast<TSelf&>(*this);\
205 } \
206 TSelf Reset##name##s() && \
207 { \
208 name##s_ = Nothing(); \
209 return static_cast<TSelf&&>(*this);\
210 } \
211 static_assert(true)
212
213#define FLUENT_VECTOR_FIELD_ENCAPSULATED(type, name) \
214private: \
215 TVector<type> name##s_; \
216public: \
217 TSelf& Add##name(const type& value) & \
218 { \
219 name##s_.push_back(value); \
220 return static_cast<TSelf&>(*this);\
221 } \
222 TSelf Add##name(const type& value) && \
223 { \
224 name##s_.push_back(value); \
225 return static_cast<TSelf&>(*this);\
226 } \
227 TSelf& name##s(TVector<type> value) & \
228 { \
229 name##s_ = std::move(value); \
230 return static_cast<TSelf&>(*this);\
231 } \
232 TSelf name##s(TVector<type> value) && \
233 { \
234 name##s_ = std::move(value); \
235 return static_cast<TSelf&>(*this);\
236 } \
237 const TVector<type>& name##s() const & \
238 { \
239 return name##s_; \
240 } \
241 TVector<type> name##s() && \
242 { \
243 return name##s_; \
244 } \
245 static_assert(true)
246
247#define FLUENT_MAP_FIELD(keytype, valuetype, name) \
248 TMap<keytype,valuetype> name##_; \
249 TSelf& Add##name(const keytype& key, const valuetype& value) \
250 { \
251 name##_.emplace(key, value); \
252 return static_cast<TSelf&>(*this);\
253 } \
254 static_assert(true)
255
257
259
278template <class T, class TDerived>
280{
282 using TSelf = std::conditional_t<std::is_void_v<TDerived>, TOneOrMany, TDerived>;
284
286 TOneOrMany() = default;
287
288 // Initialize from initializer list.
289 template<class U>
290 TOneOrMany(std::initializer_list<U> il)
291 {
292 Parts_.assign(il.begin(), il.end());
293 }
294
296 template <class U, class... TArgs>
297 requires std::is_convertible_v<U, T>
298 TOneOrMany(U&& arg, TArgs&&... args)
299 {
300 Add(arg, std::forward<TArgs>(args)...);
301 }
302
304 TOneOrMany(TVector<T> args)
305 : Parts_(std::move(args))
306 { }
307
309 bool operator==(const TOneOrMany& rhs) const
310 {
311 // N.B. We would like to make this method to be `= default`,
312 // but this breaks MSVC compiler for the cases when T doesn't
313 // support comparison.
314 return Parts_ == rhs.Parts_;
315 }
316
321 template <class U, class... TArgs>
322 requires std::is_convertible_v<U, T>
323 TSelf& Add(U&& part, TArgs&&... args) &
324 {
325 Parts_.push_back(std::forward<U>(part));
326 if constexpr (sizeof...(args) > 0) {
327 [[maybe_unused]] int dummy[sizeof...(args)] = {(Parts_.push_back(std::forward<TArgs>(args)), 0) ... };
328 }
329 return static_cast<TSelf&>(*this);
330 }
331
332 template <class U, class... TArgs>
333 requires std::is_convertible_v<U, T>
334 TSelf Add(U&& part, TArgs&&... args) &&
335 {
336 return std::move(Add(std::forward<U>(part), std::forward<TArgs>(args)...));
337 }
339
341 TVector<T> Parts_;
342};
343
345
351enum EValueType : int
352{
355
358
363
366
369
376
383
386
391
400
405
406 // Date32, number of days shifted from Unix epoch, which is 0 (signed)
407 VT_DATE32,
408 // Datetime64, number of seconds shifted from Unix epoch, which is 0 (signed)
409 VT_DATETIME64,
410 // Timestamp64, number of milliseconds shifted from Unix epoch, which is 0 (signed)
411 VT_TIMESTAMP64,
412 // Interval64, difference between two timestamps64 (signed)
413 VT_INTERVAL64,
414
415 // Universally unique identifier according to RFC-4122.
416 VT_UUID,
417
418 VT_TZ_DATE,
419 VT_TZ_DATETIME,
420 VT_TZ_TIMESTAMP,
421 VT_TZ_DATE32,
422 VT_TZ_DATETIME64,
423 VT_TZ_TIMESTAMP64,
424};
425
430enum ESortOrder : int
431{
433 SO_ASCENDING /* "ascending" */,
435 SO_DESCENDING /* "descending" */,
436};
437
443{
445 OF_SCAN_ATTR /* "scan" */,
446
448 OF_LOOKUP_ATTR /* "lookup" */,
449};
450
456{
458 EC_NONE_ATTR /* "none" */,
459 EC_REED_SOLOMON_6_3_ATTR /* "reed_solomon_6_3" */,
460 EC_LRC_12_2_2_ATTR /* "lrc_12_2_2" */,
461 EC_ISA_LRC_12_2_2_ATTR /* "isa_lrc_12_2_2" */,
462 EC_ISA_REED_SOLOMON_6_3_ATTR /* "isa_reed_solomon_6_3" */,
463 EC_ISA_REED_SOLOMON_3_3_ATTR /* "isa_reed_solomon_3_3" */,
465};
466
472{
473 SM_NONE_ATTR /* "none" */,
474 SM_UNVERSIONED_UPDATE /* "unversioned_update" */,
475};
476
478
494{
495public:
497 using TSelf = TSortColumn;
499
502
505
513 TSortColumn(TStringBuf name = {}, ESortOrder sortOrder = ESortOrder::SO_ASCENDING);
514 TSortColumn(const TString& name, ESortOrder sortOrder = ESortOrder::SO_ASCENDING);
515 TSortColumn(const char* name, ESortOrder sortOrder = ESortOrder::SO_ASCENDING);
517
520
522 TNode ToNode() const;
523
525 bool operator==(const TSortColumn& rhs) const = default;
526
535 TSortColumn& operator=(TStringBuf name);
536 TSortColumn& operator=(const TString& name);
537 TSortColumn& operator=(const char* name);
539
540 bool operator==(const TStringBuf rhsName) const;
541 bool operator==(const TString& rhsName) const;
542 bool operator==(const char* rhsName) const;
543
544 // Intentionally implicit conversions.
545 operator TString() const;
546 operator TStringBuf() const;
547 operator std::string() const;
548
549 Y_SAVELOAD_DEFINE(Name_, SortOrder_);
550};
551
557 : public TOneOrMany<TSortColumn, TSortColumns>
558{
559public:
561
564
573 TSortColumns(const TVector<TString>& names);
574 TSortColumns(const TColumnNames& names);
576
577
587 operator TColumnNames() const;
588
591
593 TVector<TString> GetNames() const;
594};
595
597
599NTi::TTypePtr ToTypeV3(EValueType type, bool required);
600
618{
619public:
621 using TSelf = TColumnSchema;
623
630
635 TColumnSchema(const TColumnSchema&) = default;
636 TColumnSchema& operator=(const TColumnSchema&) = default;
638
639
640 FLUENT_FIELD_ENCAPSULATED(TString, Name);
641
648 EValueType Type() const;
649
652 TColumnSchema& Type(const NTi::TTypePtr& type) &;
653 TColumnSchema Type(const NTi::TTypePtr& type) &&;
654
655 TColumnSchema& TypeV3(const NTi::TTypePtr& type) &;
656 TColumnSchema TypeV3(const NTi::TTypePtr& type) &&;
657 NTi::TTypePtr TypeV3() const;
659
662
668
671
674
680
681 // StableName for renamed and deleted columns.
682 FLUENT_FIELD_OPTION_ENCAPSULATED(TString, StableName);
683
689 bool Required() const;
690
695 TColumnSchema& Type(EValueType type, bool required) &;
696 TColumnSchema Type(EValueType type, bool required) &&;
698
704 const TMaybe<TNode>& RawTypeV3() const;
705 TColumnSchema& RawTypeV3(TNode rawTypeV3)&;
706 TColumnSchema RawTypeV3(TNode rawTypeV3)&&;
708
709
710private:
711 friend void Deserialize(TColumnSchema& columnSchema, const TNode& node);
712 NTi::TTypePtr TypeV3_;
713 TMaybe<TNode> RawTypeV3_;
714};
715
717bool operator==(const TColumnSchema& lhs, const TColumnSchema& rhs);
718
735{
736public:
738 using TSelf = TDeletedColumnSchema;
740
747
753 TDeletedColumnSchema& operator=(const TDeletedColumnSchema&) = default;
755
756 // StableName for renamed and deleted columns.
757 FLUENT_FIELD_OPTION_ENCAPSULATED(TString, StableName);
758
759private:
760 friend void Deserialize(TDeletedColumnSchema& columnSchema, const TNode& node);
761};
762
765
771{
772public:
774 using TSelf = TTableSchema;
776
779
787
793 FLUENT_FIELD_DEFAULT_ENCAPSULATED(bool, UniqueKeys, false);
794
799
801 TVector<TColumnSchema>& MutableColumns();
802
804 [[nodiscard]] bool Empty() const;
805
807 TTableSchema& AddColumn(const TString& name, const NTi::TTypePtr& type, ESortOrder sortOrder) &;
809 TTableSchema AddColumn(const TString& name, const NTi::TTypePtr& type, ESortOrder sortOrder) &&;
810
812 TTableSchema& AddColumn(const TString& name, const NTi::TTypePtr& type) &;
814 TTableSchema AddColumn(const TString& name, const NTi::TTypePtr& type) &&;
815
817 TTableSchema& AddColumn(const TString& name, EValueType type, ESortOrder sortOrder) &;
819 TTableSchema AddColumn(const TString& name, EValueType type, ESortOrder sortOrder) &&;
820
822 TTableSchema& AddColumn(const TString& name, EValueType type) &;
824 TTableSchema AddColumn(const TString& name, EValueType type) &&;
825
830 TTableSchema& SortBy(const TSortColumns& columns) &;
831
833 TTableSchema SortBy(const TSortColumns& columns) &&;
834
836 [[nodiscard]] TNode ToNode() const;
837
839 static NYT::TTableSchema FromNode(const TNode& node);
840
841 friend void Deserialize(TTableSchema& tableSchema, const TNode& node);
842};
843
845bool operator==(const TTableSchema& lhs, const TTableSchema& rhs);
846
847// Pretty printer for unittests
848void PrintTo(const TTableSchema& schema, std::ostream* out);
849
852 const ::google::protobuf::Descriptor& messageDescriptor,
853 const TSortColumns& sortColumns = TSortColumns(),
854 bool keepFieldsWithoutExtension = true);
855
857template <class TProtoType, typename = std::enable_if_t<std::is_base_of_v<::google::protobuf::Message, TProtoType>>>
859 const TSortColumns& sortColumns = TSortColumns(),
860 bool keepFieldsWithoutExtension = true)
861{
862 static_assert(
863 std::is_base_of_v<::google::protobuf::Message, TProtoType>,
864 "Template argument must be derived from ::google::protobuf::Message");
865
866 return CreateTableSchema(
867 *TProtoType::descriptor(),
868 sortColumns,
869 keepFieldsWithoutExtension);
870}
871
878TTableSchema CreateTableSchema(NTi::TTypePtr type);
879
881
894enum class ERelation
895{
901 Less /* "<" */,
902
908 LessOrEqual /* "<=" */,
909
915 Greater /* ">" */,
916
922 GreaterOrEqual /* ">=" */,
923};
924
930{
932 using TSelf = TKeyBound;
933
934 explicit TKeyBound(ERelation relation = ERelation::Less, TKey key = TKey{});
935
936 FLUENT_FIELD_DEFAULT_ENCAPSULATED(ERelation, Relation, ERelation::Less);
937 FLUENT_FIELD_DEFAULT_ENCAPSULATED(TKey, Key, TKey{});
939};
940
942bool operator==(const TKeyBound& lhs, const TKeyBound& rhs) noexcept;
943
951{
953 using TSelf = TReadLimit;
955
960 FLUENT_FIELD_OPTION(TKeyBound, KeyBound);
961
966 FLUENT_FIELD_OPTION(TKey, Key);
967
972 FLUENT_FIELD_OPTION(i64, RowIndex);
973
978 FLUENT_FIELD_OPTION(i64, Offset);
979
984 FLUENT_FIELD_OPTION(i64, TabletIndex);
985};
986
988bool operator==(const TReadLimit& lhs, const TReadLimit& rhs) noexcept;
989
995{
996 using TSelf = TReadRange;
997
1002 FLUENT_FIELD(TReadLimit, LowerLimit);
1003
1008 FLUENT_FIELD(TReadLimit, UpperLimit);
1009
1011 FLUENT_FIELD(TReadLimit, Exact);
1012
1014 static TReadRange FromRowIndices(i64 lowerLimit, i64 upperLimit)
1015 {
1016 return TReadRange()
1017 .LowerLimit(TReadLimit().RowIndex(lowerLimit))
1018 .UpperLimit(TReadLimit().RowIndex(upperLimit));
1019 }
1020
1022 static TReadRange FromKeys(const TKey& lowerKeyInclusive, const TKey& upperKeyExclusive)
1023 {
1024 return TReadRange()
1025 .LowerLimit(TReadLimit().Key(lowerKeyInclusive))
1026 .UpperLimit(TReadLimit().Key(upperKeyExclusive));
1027 }
1028};
1029
1031bool operator==(const TReadRange& lhs, const TReadRange& rhs) noexcept;
1032
1040{
1042 using TSelf = TRichYPath;
1044
1046 FLUENT_FIELD(TYPath, Path);
1047
1049 FLUENT_FIELD_OPTION(bool, Append);
1050
1052 FLUENT_FIELD_OPTION(bool, PartiallySorted);
1053
1055 FLUENT_FIELD(TSortColumns, SortedBy);
1056
1059 {
1060 if (!Ranges_) {
1061 Ranges_.ConstructInPlace();
1062 }
1063 Ranges_->push_back(std::move(range));
1064 return *this;
1065 }
1066
1067 TRichYPath& ResetRanges()
1068 {
1069 Ranges_.Clear();
1070 return *this;
1071 }
1072
1081 const TMaybe<TVector<TReadRange>>& GetRanges() const
1082 {
1083 return Ranges_;
1084 }
1085
1086 TMaybe<TVector<TReadRange>>& MutableRanges()
1087 {
1088 return Ranges_;
1089 }
1090
1095 TArrayRef<TReadRange> MutableRangesView()
1096 {
1097 if (Ranges_.Defined()) {
1098 return TArrayRef(Ranges_->data(), Ranges_->size());
1099 } else {
1100 return {};
1101 }
1102 }
1103
1104 TArrayRef<const TReadRange> GetRangesView() const
1105 {
1106 if (Ranges_.Defined()) {
1107 return TArrayRef(Ranges_->data(), Ranges_->size());
1108 } else {
1109 return {};
1110 }
1111 }
1113
1117 const TReadRange& GetRange(ssize_t i) const
1118 {
1119 return Ranges_.GetRef()[i];
1120 }
1121
1122 TReadRange& MutableRange(ssize_t i)
1123 {
1124 return Ranges_.GetRef()[i];
1125 }
1127
1133 FLUENT_FIELD_OPTION(TColumnNames, Columns);
1134
1135 FLUENT_FIELD_OPTION(bool, Teleport);
1136 FLUENT_FIELD_OPTION(bool, Primary);
1137 FLUENT_FIELD_OPTION(bool, Foreign);
1138 FLUENT_FIELD_OPTION(i64, RowCountLimit);
1139
1140 FLUENT_FIELD_OPTION(TString, FileName);
1141
1143 FLUENT_FIELD_OPTION(TYPath, OriginalPath);
1144
1149 FLUENT_FIELD_OPTION(bool, Executable);
1150
1155 FLUENT_FIELD_OPTION(TNode, Format);
1156
1158 FLUENT_FIELD_OPTION(TTableSchema, Schema);
1159
1161 FLUENT_FIELD_OPTION(TString, CompressionCodec);
1162
1164 FLUENT_FIELD_OPTION(EErasureCodecAttr, ErasureCodec);
1165
1168
1170 FLUENT_FIELD_OPTION(EOptimizeForAttr, OptimizeFor);
1171
1178 FLUENT_FIELD_OPTION(bool, BypassArtifactCache);
1179
1185 FLUENT_FIELD_OPTION(i64, Timestamp);
1186
1191 FLUENT_FIELD_OPTION(TTransactionId, TransactionId);
1192
1199 FLUENT_FIELD_OPTION(bool, Create);
1200
1201 using TRenameColumnsDescriptor = THashMap<TString, TString>;
1202
1204 FLUENT_FIELD_OPTION(TRenameColumnsDescriptor, RenameColumns);
1205
1207 FLUENT_FIELD_OPTION(TString, Cluster);
1208
1210 FLUENT_FIELD_OPTION(TString, InputQuery);
1211
1214 { }
1215
1220 TRichYPath(const char* path)
1221 : Path_(path)
1222 { }
1223
1224 TRichYPath(const TYPath& path)
1225 : Path_(path)
1226 { }
1228
1229private:
1230 TMaybe<TVector<TReadRange>> Ranges_;
1231};
1232
1237template <typename TProtoType>
1239{
1240 static_assert(std::is_base_of_v<::google::protobuf::Message, TProtoType>, "TProtoType must be Protobuf message");
1241
1242 auto schemedPath = path;
1243 if (!schemedPath.Schema_) {
1244 schemedPath.Schema(CreateTableSchema<TProtoType>(sortBy));
1245 }
1246 return schemedPath;
1247}
1248
1254template <typename TRowType>
1256{
1257 if constexpr (std::is_base_of_v<::google::protobuf::Message, TRowType>) {
1258 return WithSchema<TRowType>(path, sortBy);
1259 } else {
1260 return path;
1261 }
1262}
1263
1275const TVector<TReadRange>& GetRangesCompat(const TRichYPath& path);
1276
1278
1281{
1283 THashMap<TString, i64> ColumnDataWeight;
1284
1286 THashMap<TString, ui64> ColumnEstimatedUniqueCounts;
1287
1290
1293};
1294
1296
1299{
1301 {
1302 i64 ChunkCount = 0;
1303 i64 DataWeight = 0;
1304 i64 RowCount = 0;
1305 };
1306
1308 TVector<TRichYPath> TableRanges;
1309
1312
1314 TMaybe<TString> Cookie;
1315};
1316
1319{
1321 TVector<TMultiTablePartition> Partitions;
1322};
1323
1325
1328{
1330 using TSelf = TFileReadRange;
1332
1333 FLUENT_FIELD_DEFAULT(i64, Begin, 0);
1334
1336 FLUENT_FIELD_OPTION(i64, End);
1337};
1338
1341{
1343 TString Cookie;
1344
1346 i64 Length = 0;
1347};
1348
1351{
1353 TVector<TFilePartition> Partitions;
1354};
1355
1357
1363{
1369
1375
1383};
1384
1386
1389{
1391 using TSelf = TAttributeFilter;
1393
1395 FLUENT_VECTOR_FIELD(TString, Attribute);
1396};
1397
1399
1404bool IsTrivial(const TReadLimit& readLimit);
1405
1407EValueType NodeTypeToValueType(TNode::EType nodeType);
1408
1410
1415enum class EMasterReadKind : int
1416{
1422 Leader /* "leader" */,
1423
1425 Follower /* "follower" */,
1426 Cache /* "cache" */,
1427 MasterCache /* "master_cache" */,
1428};
1429
1431
1433namespace NDetail {
1434
1435// MUST NOT BE USED BY CLIENTS
1436// TODO: we should use default GENERATE_ENUM_SERIALIZATION
1437TString ToString(EValueType type);
1438
1439} // namespace NDetail
1441
1443
1444} // namespace NYT
Single column description.
Definition common.h:618
const TMaybe< TNode > & RawTypeV3() const
Raw yson representation of column type.
TColumnSchema()
Construct empty column schemas.
TColumnSchema & Type(EValueType type) &
Functions to work with type in old manner.
FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Aggregate)
Aggregating function name.
TColumnSchema & Type(EValueType type, bool required) &
Set type in old-style manner.
FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Lock)
Lock group name.
FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Group)
Storage group name.
FLUENT_FIELD_OPTION_ENCAPSULATED(ESortOrder, SortOrder)
Column sort order.
TColumnSchema & Type(const NTi::TTypePtr &type) &
Set and get column type.
bool Required() const
Column requiredness.
TColumnSchema(const TColumnSchema &)=default
Copy and move constructors are default.
FLUENT_FIELD_OPTION_ENCAPSULATED(TString, Expression)
Expression defining column value.
Single deleted description.
Definition common.h:735
TDeletedColumnSchema(const TDeletedColumnSchema &)=default
Copy and move constructors are default.
TDeletedColumnSchema()=default
Construct empty removed column schemas.
Table key column description.
Definition common.h:494
FLUENT_FIELD_ENCAPSULATED(TString, Name)
Column name.
TSortColumn(TStringBuf name={}, ESortOrder sortOrder=ESortOrder::SO_ASCENDING)
Construct object from name and sort order.
TNode ToNode() const
Convert sort to yson representation as YT API expects it.
const TSortColumn & EnsureAscending() const
Check that sort order is ascending, throw exception otherwise.
FLUENT_FIELD_DEFAULT_ENCAPSULATED(ESortOrder, SortOrder, ESortOrder::SO_ASCENDING)
Sort order.
bool operator==(const TSortColumn &rhs) const =default
Comparison is default and checks both name and sort order.
TSortColumn & operator=(TStringBuf name)
Assign object from column name, and set sort order to ascending.
List of TSortColumn.
Definition common.h:558
const TSortColumns & EnsureAscending() const
Make sure that all columns are of ascending sort order.
TSortColumns(const TVector< TString > &names)
Construct list of ascending sort order columns by their names.
TVector< TString > GetNames() const
Get list of column names.
TSortColumns()
Construct empty list.
Description of table schema.
Definition common.h:771
TTableSchema & AddColumn(const TString &name, EValueType type) &
Add optional column of specified type.
TTableSchema AddColumn(const TString &name, const NTi::TTypePtr &type) &&
Add column.
TTableSchema & AddColumn(const TString &name, const NTi::TTypePtr &type) &
Add column.
FLUENT_FIELD_DEFAULT_ENCAPSULATED(bool, Strict, true)
Strictness of the schema.
TTableSchema AddColumn(const TString &name, const NTi::TTypePtr &type, ESortOrder sortOrder) &&
Add column.
TTableSchema SortBy(const TSortColumns &columns) &&
Make table schema sorted by specified columns.
FLUENT_VECTOR_FIELD_ENCAPSULATED(TDeletedColumnSchema, DeletedColumn)
Deleted column schema.
TTableSchema & SortBy(const TSortColumns &columns) &
Make table schema sorted by specified columns.
FLUENT_FIELD_DEFAULT_ENCAPSULATED(bool, UniqueKeys, false)
Whether keys are unique.
static NYT::TTableSchema FromNode(const TNode &node)
Parse schema from yson node.
FLUENT_VECTOR_FIELD_ENCAPSULATED(TColumnSchema, Column)
Column schema.
TVector< TColumnSchema > & MutableColumns()
Get modifiable column list.
bool Empty() const
Check if schema has any described column.
TTableSchema & AddColumn(const TString &name, const NTi::TTypePtr &type, ESortOrder sortOrder) &
Add column.
TNode ToNode() const
Get yson description of table schema.
TTableSchema AddColumn(const TString &name, EValueType type) &&
Add optional column of specified type.
TTableSchema & AddColumn(const TString &name, EValueType type, ESortOrder sortOrder) &
Add optional column of specified type.
TTableSchema AddColumn(const TString &name, EValueType type, ESortOrder sortOrder) &&
Add optional column of specified type.
Main namespace of YT client.
Definition abortable_stream.h:7
EMasterReadKind
Enumeration for specifying how reading from master is performed.
Definition common.h:1416
@ Leader
Reading from leader.
Definition common.h:1422
@ Follower
Reading from master follower (default).
Definition common.h:1425
EErasureCodecAttr
Value of "erasure_codec" attribute.
Definition common.h:456
bool operator==(const TColumnSchema &lhs, const TColumnSchema &rhs)
Equality check checks all fields of column schema.
TRichYPath MaybeWithSchema(const TRichYPath &path, const TSortColumns &sortBy=TSortColumns())
Create copy of NYT::TRichYPath with schema derived from TRowType if possible.
Definition common.h:1255
TRichYPath WithSchema(const TRichYPath &path, const TSortColumns &sortBy=TSortColumns())
Definition common.h:1238
ESchemaModificationAttr
Value of "schema_modification" attribute.
Definition common.h:472
const TVector< TReadRange > & GetRangesCompat(const TRichYPath &path)
Get the list of ranges related to path in compatibility mode.
EOptimizeForAttr
Value of "optimize_for" attribute.
Definition common.h:443
@ OF_SCAN_ATTR
Optimize for scan.
Definition common.h:445
@ OF_LOOKUP_ATTR
Optimize for lookup.
Definition common.h:448
ERelation
Enumeration describing comparison operation used in key bound.
Definition common.h:895
@ Less
Relation "less".
Definition common.h:901
@ GreaterOrEqual
Relation "greater or equal".
Definition common.h:922
@ Greater
Relation "greater".
Definition common.h:915
@ LessOrEqual
Relation "less or equal".
Definition common.h:908
TTableSchema CreateTableSchema(const ::google::protobuf::Descriptor &messageDescriptor, const TSortColumns &sortColumns=TSortColumns(), bool keepFieldsWithoutExtension=true)
Create table schema by protobuf message descriptor.
bool IsTrivial(const TReadLimit &readLimit)
Check if none of the fields of NYT::TReadLimit is set.
EValueType NodeTypeToValueType(TNode::EType nodeType)
Convert yson node type to table schema type.
ESortOrder
Sort order.
Definition common.h:431
@ SO_DESCENDING
Descending sort order.
Definition common.h:435
@ SO_ASCENDING
Ascending sort order.
Definition common.h:433
NTi::TTypePtr ToTypeV3(EValueType type, bool required)
Helper function to create new style type from old style one.
EValueType
Type of the value that can occur in YT table.
Definition common.h:352
@ VT_UINT16
Uint16, unsigned integer of 16 bits.
Definition common.h:380
@ VT_INTERVAL
Interval, difference between two timestamps (signed).
Definition common.h:399
@ VT_UINT64
Uint64, unsigned integer of 64 bits.
Definition common.h:357
@ VT_ANY
Any, arbitrary yson document.
Definition common.h:368
@ VT_DOUBLE
Double, floating point number of double precision (64 bits).
Definition common.h:360
@ VT_NULL
Null, absence of value (almost never used in schemas).
Definition common.h:388
@ VT_DATE
Date, number of days since Unix epoch (unsigned).
Definition common.h:393
@ VT_UINT32
Uint32, unsigned integer of 32 bits.
Definition common.h:382
@ VT_INT64
Int64, signed integer of 64 bits.
Definition common.h:354
@ VT_DATETIME
Datetime, number of seconds since Unix epoch (unsigned).
Definition common.h:395
@ VT_BOOLEAN
Boolean, true or false.
Definition common.h:362
@ VT_JSON
Json, sequence of bytes that is valid json.
Definition common.h:404
@ VT_TIMESTAMP
Timestamp, number of milliseconds since Unix epoch (unsigned).
Definition common.h:397
@ VT_VOID
Void, absence of value (almost never used in schemas) the difference between null,...
Definition common.h:390
@ VT_UINT8
Uint8, unsigned integer of 8 bits.
Definition common.h:378
@ VT_FLOAT
Float, floating point number (32 bits).
Definition common.h:402
@ VT_INT8
Int8, signed integer of 8 bits.
Definition common.h:371
@ VT_UTF8
Utf8, byte sequence that is valid utf8.
Definition common.h:385
@ VT_INT16
Int16, signed integer of 16 bits.
Definition common.h:373
@ VT_STRING
String, arbitrary byte sequence.
Definition common.h:365
@ VT_INT32
Int32, signed integer of 32 bits.
Definition common.h:375
List of attributes to retrieve in operations like NYT::ICypressClient::Get.
Definition common.h:1389
FLUENT_VECTOR_FIELD(TString, Attribute)
List of attributes.
Description of a file partition.
Definition common.h:1341
TString Cookie
Partition cookie that can be passed to NYT::IClientBase::CreateFilePartitionReader.
Definition common.h:1343
i64 Length
Partition length in bytes.
Definition common.h:1346
File partitions from GetFilePartitions command.
Definition common.h:1351
TVector< TFilePartition > Partitions
Partitions are listed in the order of the requested ranges, one per range.
Definition common.h:1353
Byte range of a file, offsets are uncompressed bytes.
Definition common.h:1328
TSelf & End(i64)
If missing, the range extends to the end of file.
Key with relation specifying interval of keys in lower or upper limit of NYT::TReadRange.
Definition common.h:930
Description of a partition.
Definition common.h:1299
TMaybe< TString > Cookie
Partition cookie that can be passed to NYT::IClientBase::CreatePartitionReader.
Definition common.h:1314
TStatistics AggregateStatistics
Aggregate statistics of all the table ranges in the partition.
Definition common.h:1311
TVector< TRichYPath > TableRanges
Ranges of input tables for this partition.
Definition common.h:1308
Table partitions from GetTablePartitions command.
Definition common.h:1319
TVector< TMultiTablePartition > Partitions
Disjoint partitions into which the input tables were divided.
Definition common.h:1321
TOneOrMany()=default
Initialize with empty sequence.
TOneOrMany(U &&arg, TArgs &&... args)
Put arguments to sequence.
Definition common.h:298
TSelf & Add(U &&part, TArgs &&... args) &
Add all arguments to sequence.
Definition common.h:323
TOneOrMany(TVector< T > args)
Initialize from vector.
Definition common.h:304
TVector< T > Parts_
Content of sequence.
Definition common.h:341
bool operator==(const TOneOrMany &rhs) const
Order is defined the same way as in TVector.
Definition common.h:309
Description of the read limit.
Definition common.h:951
TSelf & Offset(i64)
File offset.
TSelf & Key(TKey)
Table key.
TSelf & TabletIndex(i64)
Tablet index.
TSelf & RowIndex(i64)
Row index.
TSelf & KeyBound(TKeyBound)
KeyBound specifies table key and whether to include it.
Range of a table or a file.
Definition common.h:995
static TReadRange FromKeys(const TKey &lowerKeyInclusive, const TKey &upperKeyExclusive)
Create read range from keys.
Definition common.h:1022
TSelf & UpperLimit(TReadLimit)
Lower limit of the range.
TSelf & Exact(TReadLimit)
Exact key or row index.
TSelf & LowerLimit(TReadLimit)
Lower limit of the range.
static TReadRange FromRowIndices(i64 lowerLimit, i64 upperLimit)
Create read range from row indexes.
Definition common.h:1014
Path with additional attributes.
Definition common.h:1040
TSelf & Schema(TTableSchema)
Specifies table schema that will be set on the path.
TSelf & PartiallySorted(bool)
TSelf & OptimizeFor(EOptimizeForAttr)
Specifies optimize_for attribute that will be set on the path.
TSelf & Format(TNode)
Specify format to use when loading table.
TSelf & SortedBy(TSortColumns)
Specifies that path is expected to be sorted by these columns.
const TReadRange & GetRange(ssize_t i) const
Definition common.h:1117
TSelf & CompressionCodec(TString)
Specifies compression codec that will be set on the path.
TArrayRef< TReadRange > MutableRangesView()
Definition common.h:1095
TSelf & Path(TYPath)
Path itself.
TSelf & Cluster(TString)
Specifies cluster for the YPath.
TSelf & Columns(TColumnNames)
Specifies columns that should be read.
TSelf & RenameColumns(TRenameColumnsDescriptor)
Specifies columnar mapping which will be applied to columns before transfer to job.
TSelf & TransactionId(TTransactionId)
Specify transaction that should be used to access this path.
TSelf & Executable(bool)
Specifies that this path points to executable file.
TSelf & Timestamp(i64)
Timestamp of dynamic table.
TRichYPath(const char *path)
Create path from string.
Definition common.h:1220
TSelf & OriginalPath(TYPath)
Specifies original path to be shown in Web UI.
TSelf & InputQuery(TString)
Specifies input_query for the path.
TSelf & ErasureCodec(EErasureCodecAttr)
Specifies erasure codec that will be set on the path.
TSelf & Create(bool)
Wether to create operation output path.
TSelf & Append(bool)
Specifies that path should be appended not overwritten.
TRichYPath & AddRange(TReadRange range)
Add range to read.
Definition common.h:1058
const TMaybe< TVector< TReadRange > > & GetRanges() const
Definition common.h:1081
TRichYPath()
Create empty path with no attributes.
Definition common.h:1213
TSelf & BypassArtifactCache(bool)
Do not put file used in operation into node cache.
TSelf & SchemaModification(ESchemaModificationAttr)
Specifies schema modification that will be set on the path.
Statistics about table columns.
Definition common.h:1281
TMaybe< i64 > TimestampTotalWeight
Timestamps total weight (only for dynamic tables).
Definition common.h:1292
i64 LegacyChunksDataWeight
Total weight of all old chunks that don't keep columnar statistics.
Definition common.h:1289
THashMap< TString, ui64 > ColumnEstimatedUniqueCounts
Estimated number of unique elements for each column.
Definition common.h:1286
THashMap< TString, i64 > ColumnDataWeight
Total data weight for all chunks for each of requested columns.
Definition common.h:1283
Contains information about tablet.
Definition common.h:1363
ui64 BarrierTimestamp
Tablet cell barrier timestamp, which lags behind the current timestamp.
Definition common.h:1382
i64 TrimmedRowCount
Contains the number of front rows that are trimmed and are not guaranteed to be accessible.
Definition common.h:1374
i64 TotalRowCount
Indicates the total number of rows added to the tablet (including trimmed ones).
Definition common.h:1368