1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
|
#pragma once
#include <yt/yt/client/chunk_client/public.h>
#include <yt/yt/client/cypress_client/public.h>
#include <yt/yt/client/transaction_client/public.h>
#include <yt/yt/core/misc/range.h>
#include <library/cpp/yt/misc/enum.h>
#include <util/generic/size_literals.h>
#include <initializer_list>
namespace NYT::NTableClient {
////////////////////////////////////////////////////////////////////////////////
namespace NProto {
class TNameTableExt;
class TLogicalType;
class TColumnSchema;
class TDeletedColumn;
class TTableSchemaExt;
class TKeyColumnsExt;
class TSortColumnsExt;
class TBoundaryKeysExt;
class TBlockIndexesExt;
class TDataBlockMetaExt;
class TColumnGroupInfosExt;
class TSystemBlockMetaExt;
class TColumnarStatisticsExt;
class TDataBlockMeta;
class TSimpleVersionedBlockMeta;
class TSlimVersionedBlockMeta;
class TSchemaDictionary;
class TColumnFilter;
class TReqLookupRows;
class TColumnRenameDescriptor;
class THunkChunkRef;
class TColumnMetaExt;
class TVersionedRowDigestExt;
class TCompressionDictionaryExt;
} // namespace NProto
////////////////////////////////////////////////////////////////////////////////
using TRefCountedDataBlockMeta = TRefCountedProto<NProto::TDataBlockMetaExt>;
using TRefCountedDataBlockMetaPtr = TIntrusivePtr<TRefCountedDataBlockMeta>;
////////////////////////////////////////////////////////////////////////////////
using TRefCountedColumnGroupInfosExt = TRefCountedProto<NProto::TColumnGroupInfosExt>;
using TRefCountedColumnGroupInfosExtPtr = TIntrusivePtr<TRefCountedColumnGroupInfosExt>;
////////////////////////////////////////////////////////////////////////////////
using TRefCountedColumnMeta = TRefCountedProto<NProto::TColumnMetaExt>;
using TRefCountedColumnMetaPtr = TIntrusivePtr<TRefCountedColumnMeta>;
////////////////////////////////////////////////////////////////////////////////
using NTransactionClient::TTimestamp;
using NTransactionClient::NullTimestamp;
using NTransactionClient::MinTimestamp;
using NTransactionClient::MaxTimestamp;
using NTransactionClient::SyncLastCommittedTimestamp;
using NTransactionClient::AsyncLastCommittedTimestamp;
using NTransactionClient::AllCommittedTimestamp;
using NTransactionClient::NotPreparedTimestamp;
using TKeyColumns = std::vector<TString>;
////////////////////////////////////////////////////////////////////////////////
// Keep values below consistent with https://wiki.yandex-team.ru/yt/userdoc/tables.
constexpr int MaxKeyColumnCount = 256;
constexpr int TypicalColumnCount = 64;
constexpr int MaxColumnLockCount = 32;
constexpr int MaxColumnNameLength = 256;
constexpr int MaxColumnLockLength = 256;
constexpr int MaxColumnGroupLength = 256;
// Only for dynamic tables.
constexpr int MaxValuesPerRow = 1024;
constexpr int MaxRowsPerRowset = 5 * 1024 * 1024;
constexpr i64 MaxStringValueLength = 16_MB;
constexpr i64 MaxAnyValueLength = 16_MB;
constexpr i64 MaxCompositeValueLength = 16_MB;
constexpr i64 MaxServerVersionedRowDataWeight = 512_MB;
constexpr i64 MaxClientVersionedRowDataWeight = 128_MB;
constexpr int MaxKeyColumnCountInDynamicTable = 64;
constexpr int MaxTimestampCountPerRow = std::numeric_limits<ui16>::max();
static_assert(
MaxTimestampCountPerRow <= std::numeric_limits<ui16>::max(),
"Max timestamp count cannot be larger than UINT16_MAX");
// Only for static tables.
constexpr i64 MaxRowWeightLimit = 128_MB;
constexpr i64 MaxKeyWeightLimit = 256_KB;
// NB(psushin): increasing this parameter requires rewriting all chunks,
// so one probably should never want to do it.
constexpr int MaxSampleSize = 64_KB;
// This is a hard limit for static tables,
// imposed by Id field size (16-bit) in TUnversionedValue.
constexpr int MaxColumnId = 32 * 1024;
constexpr int MaxSchemaTotalTypeComplexity = MaxColumnId;
constexpr int MaxSchemaDepth = 32;
extern const TString SystemColumnNamePrefix;
extern const TString TableIndexColumnName;
extern const TString RowIndexColumnName;
extern const TString RangeIndexColumnName;
extern const TString TabletIndexColumnName;
extern const TString TimestampColumnName;
extern const TString CumulativeDataWeightColumnName;
extern const TString EmptyValueColumnName;
extern const TString PrimaryLockName;
constexpr int TypicalHunkColumnCount = 8;
////////////////////////////////////////////////////////////////////////////////
DEFINE_ENUM_WITH_UNDERLYING_TYPE(EHunkValueTag, ui8,
((Inline) (0))
((LocalRef) (1))
((GlobalRef)(2))
);
// Do not change these values since they are stored in the master snapshot.
DEFINE_ENUM(ETableSchemaMode,
((Weak) (0))
((Strong) (1))
);
DEFINE_ENUM(EOptimizeFor,
((Lookup) (0))
((Scan) (1))
);
YT_DEFINE_ERROR_ENUM(
((SortOrderViolation) (301))
((InvalidDoubleValue) (302))
((IncomparableTypes) (303))
((UnhashableType) (304))
// E.g. name table with more than #MaxColumnId columns (may come from legacy chunks).
((CorruptedNameTable) (305))
((UniqueKeyViolation) (306))
((SchemaViolation) (307))
((RowWeightLimitExceeded) (308))
((InvalidColumnFilter) (309))
((InvalidColumnRenaming) (310))
((IncompatibleKeyColumns) (311))
((ReaderDeadlineExpired) (312))
((TimestampOutOfRange) (313))
((InvalidSchemaValue) (314))
((FormatCannotRepresentRow) (315))
((IncompatibleSchemas) (316))
((InvalidPartitionedBy) (317))
((MisconfiguredPartitions) (318))
((TooManyRowsInRowset) (319))
((TooManyColumnsInKey) (320))
((TooManyValuesInRow) (321))
((DuplicateColumnInSchema) (322))
((MissingRequiredColumnInSchema) (323))
((IncomparableComplexValues) (324))
((KeyCannotBeNan) (325))
((StringLikeValueLengthLimitExceeded)(326))
((NameTableUpdateFailed) (327))
((InvalidTableChunkFormat) (328))
);
DEFINE_ENUM(EControlAttribute,
(TableIndex)
(KeySwitch)
(RangeIndex)
(RowIndex)
(TabletIndex)
(EndOfStream)
);
DEFINE_ENUM(EUnavailableChunkStrategy,
((ThrowError) (0))
((Restore) (1))
((Skip) (2))
);
DEFINE_ENUM(ETableSchemaModification,
((None) (0))
((UnversionedUpdate) (1))
((UnversionedUpdateUnsorted) (2))
);
DEFINE_ENUM(EColumnarStatisticsFetcherMode,
((FromNodes) (0))
((FromMaster) (1))
((Fallback) (2))
);
DEFINE_ENUM(ETablePartitionMode,
((Sorted) (0))
((Ordered) (1))
((Unordered) (2))
);
DEFINE_ENUM(EMisconfiguredPartitionTactics,
((Fail) (0))
((Skip) (1))
);
//! NB: This enum is part of the persistent state.
DEFINE_ENUM(EDictionaryCompressionPolicy,
// Placeholder representing null dictionary.
((None) (0))
// Sample chunks according to weight.
((LargeChunkFirst) (1))
// Sample chunks according to creation time.
((FreshChunkFirst) (2))
);
using TTableId = NCypressClient::TNodeId;
using TTableCollocationId = NObjectClient::TObjectId;
using TMasterTableSchemaId = NObjectClient::TObjectId;
//! NB: |int| is important since we use negative values to indicate that
//! certain values need to be dropped. Cf. #TRowBuffer::CaptureAndPermuteRow.
using TNameTableToSchemaIdMapping = TCompactVector<int, TypicalColumnCount>;
using TIdMapping = TCompactVector<int, TypicalColumnCount>;
using THunkColumnIds = TCompactVector<int, TypicalHunkColumnCount>;
union TUnversionedValueData;
enum class ESortOrder;
enum class EValueType : ui8;
enum class ESimpleLogicalValueType : ui32;
enum class ELogicalMetatype;
using TKeyColumnTypes = TCompactVector<EValueType, 16>;
class TColumnFilter;
struct TUnversionedValue;
using TUnversionedValueRange = TRange<TUnversionedValue>;
using TMutableUnversionedValueRange = TMutableRange<TUnversionedValue>;
struct TVersionedValue;
using TVersionedValueRange = TRange<TVersionedValue>;
using TMutableVersionedValueRange = TMutableRange<TVersionedValue>;
using TTimestampRange = TRange<TTimestamp>;
using TMutableTimestampRange = TMutableRange<TTimestamp>;
class TUnversionedOwningValue;
struct TUnversionedRowHeader;
struct TVersionedRowHeader;
class TUnversionedRow;
class TMutableUnversionedRow;
class TUnversionedOwningRow;
class TVersionedRow;
class TMutableVersionedRow;
class TVersionedOwningRow;
class TKey;
using TKeyRef = TUnversionedValueRange;
using TLegacyKey = TUnversionedRow;
using TLegacyMutableKey = TMutableUnversionedRow;
using TLegacyOwningKey = TUnversionedOwningRow;
// TODO(babenko): replace with TRange<TUnversionedRow>.
using TRowRange = std::pair<TUnversionedRow, TUnversionedRow>;
class TUnversionedRowBuilder;
class TUnversionedOwningRowBuilder;
struct TTypeErasedRow;
class TKeyBound;
class TOwningKeyBound;
class TKeyComparer;
struct TColumnRenameDescriptor;
using TColumnRenameDescriptors = std::vector<TColumnRenameDescriptor>;
class TStableName;
class TColumnSchema;
struct TColumnSortSchema;
using TSortColumns = std::vector<TColumnSortSchema>;
struct TColumnarStatistics;
class TTableSchema;
using TTableSchemaPtr = TIntrusivePtr<TTableSchema>;
class TLegacyLockMask;
using TLegacyLockBitmap = ui64;
class TLockMask;
using TLockBitmap = TCompactVector<ui64, 1>;
class TComparator;
DECLARE_REFCOUNTED_CLASS(TNameTable)
class TNameTableReader;
class TNameTableWriter;
DECLARE_REFCOUNTED_CLASS(TRowBuffer)
DECLARE_REFCOUNTED_STRUCT(ISchemalessUnversionedReader)
DECLARE_REFCOUNTED_STRUCT(ISchemafulUnversionedReader)
DECLARE_REFCOUNTED_STRUCT(IUnversionedWriter)
DECLARE_REFCOUNTED_STRUCT(IUnversionedRowsetWriter)
using TSchemalessWriterFactory = std::function<IUnversionedRowsetWriterPtr(
TNameTablePtr,
TTableSchemaPtr)>;
DECLARE_REFCOUNTED_STRUCT(IVersionedReader)
DECLARE_REFCOUNTED_STRUCT(IVersionedWriter)
DECLARE_REFCOUNTED_CLASS(THashTableChunkIndexWriterConfig)
DECLARE_REFCOUNTED_CLASS(TChunkIndexesWriterConfig)
DECLARE_REFCOUNTED_CLASS(TSlimVersionedWriterConfig)
DECLARE_REFCOUNTED_CLASS(TChunkWriterTestingOptions)
DECLARE_REFCOUNTED_CLASS(TChunkReaderConfig)
DECLARE_REFCOUNTED_CLASS(TChunkWriterConfig)
DECLARE_REFCOUNTED_CLASS(TKeyFilterWriterConfig)
DECLARE_REFCOUNTED_CLASS(TKeyPrefixFilterWriterConfig)
DECLARE_REFCOUNTED_CLASS(TDictionaryCompressionConfig)
DECLARE_REFCOUNTED_CLASS(TBatchHunkReaderConfig)
DECLARE_REFCOUNTED_CLASS(TTableReaderConfig)
DECLARE_REFCOUNTED_CLASS(TTableWriterConfig)
DECLARE_REFCOUNTED_CLASS(TRetentionConfig)
DECLARE_REFCOUNTED_CLASS(TTypeConversionConfig)
DECLARE_REFCOUNTED_CLASS(TInsertRowsFormatConfig)
DECLARE_REFCOUNTED_CLASS(TChunkReaderOptions)
DECLARE_REFCOUNTED_CLASS(TChunkWriterOptions)
DECLARE_REFCOUNTED_CLASS(TVersionedRowDigestConfig)
class TSaveContext;
class TLoadContext;
using TPersistenceContext = TCustomPersistenceContext<TSaveContext, TLoadContext>;
struct IWireProtocolReader;
struct IWireProtocolWriter;
using TSchemaData = std::vector<ui32>;
DECLARE_REFCOUNTED_STRUCT(IWireProtocolRowsetReader)
DECLARE_REFCOUNTED_STRUCT(IWireProtocolRowsetWriter)
DECLARE_REFCOUNTED_STRUCT(IUnversionedRowBatch)
DECLARE_REFCOUNTED_STRUCT(IUnversionedColumnarRowBatch)
DECLARE_REFCOUNTED_STRUCT(IVersionedRowBatch)
struct IValueConsumer;
struct IFlushableValueConsumer;
class TComplexTypeFieldDescriptor;
DECLARE_REFCOUNTED_CLASS(TLogicalType)
class TSimpleLogicalType;
class TDecimalLogicalType;
class TOptionalLogicalType;
class TListLogicalType;
class TStructLogicalType;
class TTupleLogicalType;
class TVariantTupleLogicalType;
class TVariantStructLogicalType;
class TDictLogicalType;
class TTaggedLogicalType;
struct TStructField;
struct IRecordDescriptor;
//! Enumeration is used to describe compatibility of two schemas (or logical types).
//! Such compatibility tests are performed before altering table schema or before merge operation.
DEFINE_ENUM(ESchemaCompatibility,
// Values are incompatible.
// E.g. Int8 and String.
(Incompatible)
// Values that satisfy old schema MIGHT satisfy new schema, dynamic check is required.
// E.g. Optional<Int8> and Int8, in this case we must check that value of old type is not NULL.
(RequireValidation)
// Values that satisfy old schema ALWAYS satisfy new schema.
// E.g. Int32 and Int64
(FullyCompatible)
);
static constexpr TMasterTableSchemaId NullTableSchemaId = TMasterTableSchemaId();
using TDynamicTableKeyMask = ui64;
static_assert(sizeof(TDynamicTableKeyMask) * 8 == MaxKeyColumnCountInDynamicTable);
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NTableClient
|