@@ -190,7 +190,9 @@ void TPathDescriber::DescribeChildren(const TPath& path) {
190
190
pathDescription->MutableChildren ()->Reserve (pathEl->GetAliveChildren ());
191
191
for (const auto & child : pathEl->GetChildren ()) {
192
192
TPathId childId = child.second ;
193
- TPathElement::TPtr childEl = *Self->PathsById .FindPtr (childId);
193
+ const auto * childElPtr = Self->PathsById .FindPtr (childId);
194
+ Y_ASSERT (childElPtr);
195
+ TPathElement::TPtr childEl = *childElPtr;
194
196
if (childEl->Dropped () || childEl->IsMigrated ()) {
195
197
continue ;
196
198
}
@@ -225,18 +227,18 @@ void TPathDescriber::DescribeDir(const TPath& path) {
225
227
226
228
void FillTableBoundaries (
227
229
google::protobuf::RepeatedPtrField<NKikimrSchemeOp::TSplitBoundary>* result,
228
- const TTableInfo::TPtr tableInfo
230
+ const TTableInfo& tableInfo
229
231
) {
230
232
TString errStr;
231
233
// Number of split boundaries equals to number of partitions - 1
232
- result->Reserve (tableInfo-> GetPartitions ().size () - 1 );
233
- for (ui32 pi = 0 ; pi < tableInfo-> GetPartitions ().size () - 1 ; ++pi) {
234
- const auto & p = tableInfo-> GetPartitions ()[pi];
234
+ result->Reserve (tableInfo. GetPartitions ().size () - 1 );
235
+ for (ui32 pi = 0 ; pi < tableInfo. GetPartitions ().size () - 1 ; ++pi) {
236
+ const auto & p = tableInfo. GetPartitions ()[pi];
235
237
TSerializedCellVec endKey (p.EndOfRange );
236
238
auto boundary = result->Add ()->MutableKeyPrefix ();
237
239
for (ui32 ki = 0 ; ki < endKey.GetCells ().size (); ++ki){
238
240
const auto & c = endKey.GetCells ()[ki];
239
- auto type = tableInfo-> Columns [ tableInfo-> KeyColumnIds [ki]] .PType ;
241
+ auto type = tableInfo. Columns . at ( tableInfo. KeyColumnIds [ki]) .PType ;
240
242
bool ok = NMiniKQL::CellToValue (type, c, *boundary->AddTuple (), errStr);
241
243
Y_ABORT_UNLESS (ok, " Failed to build key tuple at position %" PRIu32 " error: %s" , ki, errStr.data ());
242
244
}
@@ -245,12 +247,12 @@ void FillTableBoundaries(
245
247
246
248
void FillTablePartitions (
247
249
google::protobuf::RepeatedPtrField<NKikimrSchemeOp::TTablePartition>* result,
248
- const TTableInfo::TPtr tableInfo,
250
+ const TTableInfo& tableInfo,
249
251
const THashMap<TShardIdx, TShardInfo>& shardInfos,
250
252
bool includeKeys
251
253
) {
252
- result->Reserve (tableInfo-> GetPartitions ().size ());
253
- for (auto & p : tableInfo-> GetPartitions ()) {
254
+ result->Reserve (tableInfo. GetPartitions ().size ());
255
+ for (auto & p : tableInfo. GetPartitions ()) {
254
256
const auto & tabletId = ui64 (shardInfos.at (p.ShardIdx ).TabletID );
255
257
const auto & key = p.EndOfRange ;
256
258
@@ -267,13 +269,13 @@ void FillTablePartitions(
267
269
}
268
270
269
271
const TString& GetSerializedTablePartitions (
270
- const TTableInfo::TPtr tableInfo,
272
+ TTableInfo& tableInfo,
271
273
const THashMap<TShardIdx, TShardInfo>& shardInfos,
272
274
bool returnRangeKey
273
275
) {
274
276
TString& cache = (returnRangeKey
275
- ? tableInfo-> PreserializedTablePartitions
276
- : tableInfo-> PreserializedTablePartitionsNoKeys
277
+ ? tableInfo. PreserializedTablePartitions
278
+ : tableInfo. PreserializedTablePartitionsNoKeys
277
279
);
278
280
279
281
if (cache.empty ()) {
@@ -287,7 +289,9 @@ const TString& GetSerializedTablePartitions(
287
289
288
290
void TPathDescriber::DescribeTable (const TActorContext& ctx, TPathId pathId, TPathElement::TPtr pathEl) {
289
291
const NScheme::TTypeRegistry* typeRegistry = AppData (ctx)->TypeRegistry ;
290
- const TTableInfo::TPtr tableInfo = *Self->Tables .FindPtr (pathId);
292
+ const auto * tableInfoPtr = Self->Tables .FindPtr (pathId);
293
+ Y_ASSERT (tableInfoPtr);
294
+ auto & tableInfo = **tableInfoPtr;
291
295
auto pathDescription = Result->Record .MutablePathDescription ();
292
296
auto entry = pathDescription->MutableTable ();
293
297
@@ -311,13 +315,13 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
311
315
312
316
if (returnBoundaries) {
313
317
// split boundaries (split keys without shard's tablet-ids)
314
- if (tableInfo-> PreserializedTableSplitBoundaries .empty ()) {
318
+ if (tableInfo. PreserializedTableSplitBoundaries .empty ()) {
315
319
NKikimrScheme::TEvDescribeSchemeResult preSerializedResult;
316
320
auto & tableDesc = *preSerializedResult.MutablePathDescription ()->MutableTable ();
317
321
FillTableBoundaries (tableDesc.MutableSplitBoundary (), tableInfo);
318
- Y_PROTOBUF_SUPPRESS_NODISCARD preSerializedResult.SerializeToString (&tableInfo-> PreserializedTableSplitBoundaries );
322
+ Y_PROTOBUF_SUPPRESS_NODISCARD preSerializedResult.SerializeToString (&tableInfo. PreserializedTableSplitBoundaries );
319
323
}
320
- Result->PreSerializedData += tableInfo-> PreserializedTableSplitBoundaries ;
324
+ Result->PreSerializedData += tableInfo. PreserializedTableSplitBoundaries ;
321
325
}
322
326
323
327
if (returnPartitioning) {
@@ -327,18 +331,18 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
327
331
328
332
// KIKIMR-4337: table info is in flux until table is finally created
329
333
if (!pathEl->IsCreateFinished ()) {
330
- tableInfo-> PreserializedTablePartitions .clear ();
331
- tableInfo-> PreserializedTablePartitionsNoKeys .clear ();
332
- tableInfo-> PreserializedTableSplitBoundaries .clear ();
334
+ tableInfo. PreserializedTablePartitions .clear ();
335
+ tableInfo. PreserializedTablePartitionsNoKeys .clear ();
336
+ tableInfo. PreserializedTableSplitBoundaries .clear ();
333
337
}
334
338
335
- FillAggregatedStats (*Result->Record .MutablePathDescription (), tableInfo-> GetStats ());
339
+ FillAggregatedStats (*Result->Record .MutablePathDescription (), tableInfo. GetStats ());
336
340
337
341
if (returnPartitionStats) {
338
342
NKikimrSchemeOp::TPathDescription& pathDescription = *Result->Record .MutablePathDescription ();
339
- pathDescription.MutableTablePartitionStats ()->Reserve (tableInfo-> GetPartitions ().size ());
340
- for (auto & p : tableInfo-> GetPartitions ()) {
341
- const auto * stats = tableInfo-> GetStats ().PartitionStats .FindPtr (p.ShardIdx );
343
+ pathDescription.MutableTablePartitionStats ()->Reserve (tableInfo. GetPartitions ().size ());
344
+ for (auto & p : tableInfo. GetPartitions ()) {
345
+ const auto * stats = tableInfo. GetStats ().PartitionStats .FindPtr (p.ShardIdx );
342
346
Y_ABORT_UNLESS (stats);
343
347
auto pbStats = pathDescription.AddTablePartitionStats ();
344
348
FillTableStats (pbStats, *stats);
@@ -368,7 +372,7 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
368
372
}));
369
373
progress->SetStartTime (txState.StartTime .Seconds ());
370
374
progress->MutableYTSettings ()->CopyFrom (
371
- tableInfo-> BackupSettings .GetYTSettings ());
375
+ tableInfo. BackupSettings .GetYTSettings ());
372
376
progress->SetDataTotalSize (txState.DataTotalSize );
373
377
progress->SetTxId (ui64 (txId));
374
378
@@ -378,7 +382,7 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
378
382
}
379
383
380
384
/* Get information about last completed backup */
381
- for (const auto & iter: tableInfo-> BackupHistory ) {
385
+ for (const auto & iter: tableInfo. BackupHistory ) {
382
386
LOG_TRACE (ctx, NKikimrServices::SCHEMESHARD_DESCRIBE,
383
387
" Add last backup info item to history" );
384
388
auto protoResult = pathDescription->AddLastBackupResult ();
@@ -444,6 +448,8 @@ void TPathDescriber::DescribeTable(const TActorContext& ctx, TPathId pathId, TPa
444
448
}
445
449
446
450
void TPathDescriber::DescribeOlapStore (TPathId pathId, TPathElement::TPtr pathEl) {
451
+ const auto * storeInfoPtr = Self->OlapStores .FindPtr (pathId);
452
+ Y_ASSERT (storeInfoPtr);
447
453
const TOlapStoreInfo::TPtr storeInfo = *Self->OlapStores .FindPtr (pathId);
448
454
449
455
Y_ABORT_UNLESS (storeInfo, " OlapStore not found" );
@@ -475,7 +481,9 @@ void TPathDescriber::DescribeColumnTable(TPathId pathId, TPathElement::TPtr path
475
481
if (tableInfo->IsStandalone ()) {
476
482
FillAggregatedStats (*pathDescription, tableInfo->GetStats ());
477
483
} else {
478
- const TOlapStoreInfo::TPtr storeInfo = *Self->OlapStores .FindPtr (tableInfo->GetOlapStorePathIdVerified ());
484
+ const auto * storeInfoPtr = Self->OlapStores .FindPtr (tableInfo->GetOlapStorePathIdVerified ());
485
+ Y_ASSERT (storeInfoPtr);
486
+ const TOlapStoreInfo::TPtr storeInfo = *storeInfoPtr;
479
487
Y_ABORT_UNLESS (storeInfo, " OlapStore not found" );
480
488
481
489
auto & preset = storeInfo->SchemaPresets .at (description->GetSchemaPresetId ());
@@ -1173,7 +1181,7 @@ THolder<TEvSchemeShard::TEvDescribeSchemeResultBuilder> DescribePath(
1173
1181
}
1174
1182
1175
1183
void TSchemeShard::DescribeTable (
1176
- const TTableInfo::TPtr tableInfo,
1184
+ const TTableInfo& tableInfo,
1177
1185
const NScheme::TTypeRegistry* typeRegistry,
1178
1186
bool fillConfig,
1179
1187
NKikimrSchemeOp::TTableDescription* entry
@@ -1183,9 +1191,9 @@ void TSchemeShard::DescribeTable(
1183
1191
THashMap<ui32, TString> familyNames;
1184
1192
bool familyNamesBuilt = false ;
1185
1193
1186
- entry->SetTableSchemaVersion (tableInfo-> AlterVersion );
1187
- entry->MutableColumns ()->Reserve (tableInfo-> Columns .size ());
1188
- for (auto col : tableInfo-> Columns ) {
1194
+ entry->SetTableSchemaVersion (tableInfo. AlterVersion );
1195
+ entry->MutableColumns ()->Reserve (tableInfo. Columns .size ());
1196
+ for (auto col : tableInfo. Columns ) {
1189
1197
const auto & cinfo = col.second ;
1190
1198
if (cinfo.IsDropped ())
1191
1199
continue ;
@@ -1205,7 +1213,7 @@ void TSchemeShard::DescribeTable(
1205
1213
colDescr->SetFamily (cinfo.Family );
1206
1214
1207
1215
if (!familyNamesBuilt) {
1208
- for (const auto & family : tableInfo-> PartitionConfig ().GetColumnFamilies ()) {
1216
+ for (const auto & family : tableInfo. PartitionConfig ().GetColumnFamilies ()) {
1209
1217
if (family.HasName () && family.HasId ()) {
1210
1218
familyNames[family.GetId ()] = family.GetName ();
1211
1219
}
@@ -1233,28 +1241,28 @@ void TSchemeShard::DescribeTable(
1233
1241
break ;
1234
1242
}
1235
1243
}
1236
- Y_ABORT_UNLESS (!tableInfo-> KeyColumnIds .empty ());
1244
+ Y_ABORT_UNLESS (!tableInfo. KeyColumnIds .empty ());
1237
1245
1238
- entry->MutableKeyColumnNames ()->Reserve (tableInfo-> KeyColumnIds .size ());
1239
- entry->MutableKeyColumnIds ()->Reserve (tableInfo-> KeyColumnIds .size ());
1240
- for (ui32 keyColId : tableInfo-> KeyColumnIds ) {
1241
- entry->AddKeyColumnNames (tableInfo-> Columns [ keyColId] .Name );
1246
+ entry->MutableKeyColumnNames ()->Reserve (tableInfo. KeyColumnIds .size ());
1247
+ entry->MutableKeyColumnIds ()->Reserve (tableInfo. KeyColumnIds .size ());
1248
+ for (ui32 keyColId : tableInfo. KeyColumnIds ) {
1249
+ entry->AddKeyColumnNames (tableInfo. Columns . at ( keyColId) .Name );
1242
1250
entry->AddKeyColumnIds (keyColId);
1243
1251
}
1244
1252
1245
1253
if (fillConfig) {
1246
- FillPartitionConfig (tableInfo-> PartitionConfig (), *entry->MutablePartitionConfig ());
1254
+ FillPartitionConfig (tableInfo. PartitionConfig (), *entry->MutablePartitionConfig ());
1247
1255
}
1248
1256
1249
- if (tableInfo-> HasTTLSettings ()) {
1250
- entry->MutableTTLSettings ()->CopyFrom (tableInfo-> TTLSettings ());
1257
+ if (tableInfo. HasTTLSettings ()) {
1258
+ entry->MutableTTLSettings ()->CopyFrom (tableInfo. TTLSettings ());
1251
1259
}
1252
1260
1253
- if (tableInfo-> HasReplicationConfig ()) {
1254
- entry->MutableReplicationConfig ()->CopyFrom (tableInfo-> ReplicationConfig ());
1261
+ if (tableInfo. HasReplicationConfig ()) {
1262
+ entry->MutableReplicationConfig ()->CopyFrom (tableInfo. ReplicationConfig ());
1255
1263
}
1256
1264
1257
- entry->SetIsBackup (tableInfo-> IsBackup );
1265
+ entry->SetIsBackup (tableInfo. IsBackup );
1258
1266
}
1259
1267
1260
1268
void TSchemeShard::DescribeTableIndex (const TPathId& pathId, const TString& name,
@@ -1288,26 +1296,31 @@ void TSchemeShard::DescribeTableIndex(const TPathId& pathId, const TString& name
1288
1296
*entry.MutableDataColumnNames ()->Add () = dataColumns;
1289
1297
}
1290
1298
1291
- auto indexPath = *PathsById.FindPtr (pathId);
1292
- Y_ABORT_UNLESS (indexPath);
1293
- if (indexInfo->Type == NKikimrSchemeOp::EIndexType::EIndexTypeGlobalVectorKmeansTree) {
1294
- // For vector index we have 4 impl tables on build stage and 2 impl tables when it's ready
1295
- Y_ABORT_UNLESS (indexPath->GetChildren ().size () == 4 || indexPath->GetChildren ().size () == 2 );
1299
+ const auto * indexPathPtr = PathsById.FindPtr (pathId);
1300
+ Y_ABORT_UNLESS (indexPathPtr);
1301
+ const auto & indexPath = **indexPathPtr;
1302
+ if (const auto size = indexPath.GetChildren ().size (); indexInfo->Type == NKikimrSchemeOp::EIndexType::EIndexTypeGlobalVectorKmeansTree) {
1303
+ // For vector index we have 2 impl tables and 2 tmp impl tables
1304
+ Y_VERIFY_S (2 <= size && size <= 4 , size);
1296
1305
} else {
1297
- Y_ABORT_UNLESS (indexPath-> GetChildren (). size () == 1 );
1306
+ Y_VERIFY_S ( size == 1 , size );
1298
1307
}
1299
1308
1300
1309
ui64 dataSize = 0 ;
1301
- for (const auto & indexImplTablePathId : indexPath->GetChildren ()) {
1302
- auto tableInfo = *Tables.FindPtr (indexImplTablePathId.second );
1303
- Y_ABORT_UNLESS (tableInfo);
1310
+ for (const auto & indexImplTablePathId : indexPath.GetChildren ()) {
1311
+ const auto * tableInfoPtr = Tables.FindPtr (indexImplTablePathId.second );
1312
+ if (!tableInfoPtr && NTableIndex::IsTmpImplTable (indexImplTablePathId.first )) {
1313
+ continue ; // it's possible because of dropping tmp index impl tables without dropping index
1314
+ }
1315
+ Y_ABORT_UNLESS (tableInfoPtr);
1316
+ const auto & tableInfo = **tableInfoPtr;
1304
1317
1305
- const auto & tableStats = tableInfo-> GetStats ().Aggregated ;
1318
+ const auto & tableStats = tableInfo. GetStats ().Aggregated ;
1306
1319
dataSize += tableStats.DataSize + tableStats.IndexSize ;
1307
1320
1308
1321
auto * tableDescription = entry.AddIndexImplTableDescriptions ();
1309
1322
if (fillConfig) {
1310
- FillPartitionConfig (tableInfo-> PartitionConfig (), *tableDescription->MutablePartitionConfig ());
1323
+ FillPartitionConfig (tableInfo. PartitionConfig (), *tableDescription->MutablePartitionConfig ());
1311
1324
}
1312
1325
if (fillBoundaries) {
1313
1326
FillTableBoundaries (tableDescription->MutableSplitBoundary (), tableInfo);
0 commit comments