@@ -6,8 +6,19 @@ namespace NKikimr::NOlap::NReader::NSysView::NChunks {
6
6
7
7
void TStatsIterator::AppendStats (const std::vector<std::unique_ptr<arrow::ArrayBuilder>>& builders, const TPortionInfo& portion) const {
8
8
auto portionSchema = ReadMetadata->GetLoadSchemaVerified (portion);
9
- const std::string prod = ::ToString (portion.GetMeta ().Produced );
9
+ auto it = PortionType.find (portion.GetMeta ().Produced );
10
+ if (it == PortionType.end ()) {
11
+ it = PortionType.emplace (portion.GetMeta ().Produced , ::ToString (portion.GetMeta ().Produced )).first ;
12
+ }
13
+ const arrow::util::string_view prodView = it->second .GetView ();
10
14
const bool activity = !portion.IsRemovedFor (ReadMetadata->GetRequestSnapshot ());
15
+ static const TString ConstantEntityIsColumn = " COL" ;
16
+ static const arrow::util::string_view ConstantEntityIsColumnView =
17
+ arrow::util::string_view (ConstantEntityIsColumn.data (), ConstantEntityIsColumn.size ());
18
+ static const TString ConstantEntityIsIndex = " IDX" ;
19
+ static const arrow::util::string_view ConstantEntityIsIndexView =
20
+ arrow::util::string_view (ConstantEntityIsIndex.data (), ConstantEntityIsIndex.size ());
21
+ auto & entityStorages = EntityStorageNames[portion.GetMeta ().GetTierName ()];
11
22
{
12
23
std::vector<const TColumnRecord*> records;
13
24
for (auto && r : portion.Records ) {
@@ -16,26 +27,54 @@ void TStatsIterator::AppendStats(const std::vector<std::unique_ptr<arrow::ArrayB
16
27
if (Reverse) {
17
28
std::reverse (records.begin (), records.end ());
18
29
}
30
+ THashMap<ui32, TString> blobsIds;
31
+ std::optional<ui32> lastColumnId;
32
+ arrow::util::string_view lastColumnName;
33
+ arrow::util::string_view lastTierName;
19
34
for (auto && r : records) {
20
35
NArrow::Append<arrow::UInt64Type>(*builders[0 ], portion.GetPathId ());
21
- NArrow::Append<arrow::StringType>(*builders[1 ], prod );
36
+ NArrow::Append<arrow::StringType>(*builders[1 ], prodView );
22
37
NArrow::Append<arrow::UInt64Type>(*builders[2 ], ReadMetadata->TabletId );
23
38
NArrow::Append<arrow::UInt64Type>(*builders[3 ], r->GetMeta ().GetNumRows ());
24
39
NArrow::Append<arrow::UInt64Type>(*builders[4 ], r->GetMeta ().GetRawBytes ());
25
40
NArrow::Append<arrow::UInt64Type>(*builders[5 ], portion.GetPortionId ());
26
41
NArrow::Append<arrow::UInt64Type>(*builders[6 ], r->GetChunkIdx ());
27
- NArrow::Append<arrow::StringType>(*builders[7 ], ReadMetadata->GetColumnNameDef (r->GetColumnId ()).value_or (" undefined" ));
42
+ if (!lastColumnId || *lastColumnId != r->GetColumnId ()) {
43
+ {
44
+ auto it = ColumnNamesById.find (r->GetColumnId ());
45
+ if (it == ColumnNamesById.end ()) {
46
+ it =
47
+ ColumnNamesById.emplace (r->GetColumnId (), portionSchema->GetFieldByColumnIdVerified (r->GetColumnId ())->name ()).first ;
48
+ }
49
+ lastColumnName = it->second .GetView ();
50
+ }
51
+ {
52
+ auto it = entityStorages.find (r->GetColumnId ());
53
+ if (it == entityStorages.end ()) {
54
+ it = entityStorages.emplace (r->GetColumnId (),
55
+ portionSchema->GetIndexInfo ().GetEntityStorageId (r->GetColumnId (), portion.GetMeta ().GetTierName ())).first ;
56
+ }
57
+ lastTierName = it->second .GetView ();
58
+ }
59
+ lastColumnId = r->GetColumnId ();
60
+ }
61
+ NArrow::Append<arrow::StringType>(*builders[7 ], lastColumnName);
28
62
NArrow::Append<arrow::UInt32Type>(*builders[8 ], r->GetColumnId ());
29
- std::string blobIdString = portion.GetBlobId (r->GetBlobRange ().GetBlobIdxVerified ()).ToStringLegacy ();
30
- NArrow::Append<arrow::StringType>(*builders[9 ], blobIdString);
63
+ {
64
+ auto itBlobIdString = blobsIds.find (r->GetBlobRange ().GetBlobIdxVerified ());
65
+ if (itBlobIdString == blobsIds.end ()) {
66
+ itBlobIdString = blobsIds.emplace (
67
+ r->GetBlobRange ().GetBlobIdxVerified (), portion.GetBlobId (r->GetBlobRange ().GetBlobIdxVerified ()).ToStringLegacy ()).first ;
68
+ }
69
+ NArrow::Append<arrow::StringType>(
70
+ *builders[9 ], arrow::util::string_view (itBlobIdString->second .data (), itBlobIdString->second .size ()));
71
+ }
31
72
NArrow::Append<arrow::UInt64Type>(*builders[10 ], r->BlobRange .Offset );
32
73
NArrow::Append<arrow::UInt64Type>(*builders[11 ], r->BlobRange .Size );
33
74
NArrow::Append<arrow::BooleanType>(*builders[12 ], activity);
34
75
35
- const auto tierName = portionSchema->GetIndexInfo ().GetEntityStorageId (r->GetColumnId (), portion.GetMeta ().GetTierName ());
36
- std::string strTierName (tierName.data (), tierName.size ());
37
- NArrow::Append<arrow::StringType>(*builders[13 ], strTierName);
38
- NArrow::Append<arrow::StringType>(*builders[14 ], " COL" );
76
+ NArrow::Append<arrow::StringType>(*builders[13 ], arrow::util::string_view (lastTierName.data (), lastTierName.size ()));
77
+ NArrow::Append<arrow::StringType>(*builders[14 ], ConstantEntityIsColumnView);
39
78
}
40
79
}
41
80
{
@@ -48,7 +87,7 @@ void TStatsIterator::AppendStats(const std::vector<std::unique_ptr<arrow::ArrayB
48
87
}
49
88
for (auto && r : indexes) {
50
89
NArrow::Append<arrow::UInt64Type>(*builders[0 ], portion.GetPathId ());
51
- NArrow::Append<arrow::StringType>(*builders[1 ], prod );
90
+ NArrow::Append<arrow::StringType>(*builders[1 ], prodView );
52
91
NArrow::Append<arrow::UInt64Type>(*builders[2 ], ReadMetadata->TabletId );
53
92
NArrow::Append<arrow::UInt64Type>(*builders[3 ], r->GetRecordsCount ());
54
93
NArrow::Append<arrow::UInt64Type>(*builders[4 ], r->GetRawBytes ());
@@ -70,7 +109,7 @@ void TStatsIterator::AppendStats(const std::vector<std::unique_ptr<arrow::ArrayB
70
109
const auto tierName = portionSchema->GetIndexInfo ().GetEntityStorageId (r->GetIndexId (), portion.GetMeta ().GetTierName ());
71
110
std::string strTierName (tierName.data (), tierName.size ());
72
111
NArrow::Append<arrow::StringType>(*builders[13 ], strTierName);
73
- NArrow::Append<arrow::StringType>(*builders[14 ], " IDX " );
112
+ NArrow::Append<arrow::StringType>(*builders[14 ], ConstantEntityIsIndexView );
74
113
}
75
114
}
76
115
}
0 commit comments