@@ -76,10 +76,10 @@ void CalculateGroupUsageStats(NKikimrSysView::TGroupInfo *info, const std::vecto
76
76
77
77
class TSystemViewsCollector : public TActorBootstrapped <TSystemViewsCollector> {
78
78
TControllerSystemViewsState State;
79
- std::vector<std::pair< TPDiskId, const NKikimrSysView::TPDiskInfo*> > PDiskIndex;
80
- std::vector<std::pair< TVSlotId, const NKikimrSysView::TVSlotInfo*> > VSlotIndex;
81
- std::vector<std::pair< TGroupId, const NKikimrSysView::TGroupInfo*> > GroupIndex;
82
- std::vector<std::pair< TBoxStoragePoolId, const NKikimrSysView::TStoragePoolInfo*> > StoragePoolIndex;
79
+ std::map< TPDiskId, const NKikimrSysView::TPDiskInfo*> PDiskIndex;
80
+ std::map< TVSlotId, const NKikimrSysView::TVSlotInfo*> VSlotIndex;
81
+ std::map< TGroupId, const NKikimrSysView::TGroupInfo*> GroupIndex;
82
+ std::map< TBoxStoragePoolId, const NKikimrSysView::TStoragePoolInfo*> StoragePoolIndex;
83
83
TBlobStorageController::THostRecordMap HostRecords;
84
84
ui32 GroupReserveMin = 0 ;
85
85
ui32 GroupReservePart = 0 ;
@@ -143,52 +143,49 @@ class TSystemViewsCollector : public TActorBootstrapped<TSystemViewsCollector> {
143
143
144
144
template <typename TDest, typename TSrc, typename TDeleted, typename TIndex>
145
145
void Merge (TDest& dest, TSrc& src, const TDeleted& deleted, TIndex& index) {
146
- if (!src.empty () || !deleted.empty ()) {
147
- index .clear ();
148
- }
149
146
for (const auto & key : deleted) {
150
147
dest.erase (key);
148
+ index .erase (key);
151
149
}
152
- for (auto & [key, _ ] : src) {
150
+ for (auto & [key, value ] : src) {
153
151
dest.erase (key);
152
+ index [key] = &value;
154
153
}
155
154
dest.merge (std::move (src));
155
+
156
+ #ifndef NDEBUG
157
+ for (const auto & [key, value] : dest) {
158
+ Y_DEBUG_ABORT_UNLESS (index .contains (key) && index [key] == &value);
159
+ }
160
+ Y_DEBUG_ABORT_UNLESS (index .size () == dest.size ());
161
+ #endif
156
162
}
157
163
158
- template <typename TResponse, typename TRequest, typename TMap, typename TIndex>
159
- void Reply (TRequest& request, const TMap& entries, TIndex& index) {
164
+ template <typename TResponse, typename TRequest, typename TIndex>
165
+ void Reply (TRequest& request, TIndex& index) {
160
166
const auto & record = request->Get ()->Record ;
161
167
auto response = MakeHolder<TResponse>();
162
168
163
- if (index .empty () && !entries.empty ()) {
164
- index .reserve (entries.size ());
165
- for (const auto & [key, value] : entries) {
166
- index .emplace_back (key, &value);
167
- }
168
- std::sort (index .begin (), index .end ());
169
- }
170
-
171
169
auto begin = index .begin ();
172
170
auto end = index .end ();
173
- auto comp = [](const auto & kv, const auto & key) { return kv.first < key; };
174
171
175
172
if (record.HasFrom ()) {
176
173
auto from = TransformKey (record.GetFrom ());
177
- begin = std::lower_bound ( index .begin (), index . end (), from, comp );
174
+ begin = index .lower_bound ( from);
178
175
if (begin != index .end () && begin->first == from && record.HasInclusiveFrom () && !record.GetInclusiveFrom ()) {
179
176
++begin;
180
177
}
181
178
}
182
179
183
180
if (record.HasTo ()) {
184
181
auto to = TransformKey (record.GetTo ());
185
- end = std::lower_bound ( index .begin (), index . end (), to, comp );
182
+ end = index .lower_bound (to );
186
183
if (end != index .end () && end->first == to && record.GetInclusiveTo ()) {
187
184
++end;
188
185
}
189
186
}
190
187
191
- for (; begin < end; ++begin) {
188
+ for (; begin != end; ++begin) {
192
189
auto * entry = response->Record .AddEntries ();
193
190
FillKey (entry->MutableKey (), begin->first );
194
191
entry->MutableInfo ()->CopyFrom (*begin->second );
@@ -198,19 +195,19 @@ class TSystemViewsCollector : public TActorBootstrapped<TSystemViewsCollector> {
198
195
}
199
196
200
197
void Handle (TEvSysView::TEvGetPDisksRequest::TPtr& ev) {
201
- Reply<TEvSysView::TEvGetPDisksResponse>(ev, State. PDisks , PDiskIndex);
198
+ Reply<TEvSysView::TEvGetPDisksResponse>(ev, PDiskIndex);
202
199
}
203
200
204
201
void Handle (TEvSysView::TEvGetVSlotsRequest::TPtr& ev) {
205
- Reply<TEvSysView::TEvGetVSlotsResponse>(ev, State. VSlots , VSlotIndex);
202
+ Reply<TEvSysView::TEvGetVSlotsResponse>(ev, VSlotIndex);
206
203
}
207
204
208
205
void Handle (TEvSysView::TEvGetGroupsRequest::TPtr& ev) {
209
- Reply<TEvSysView::TEvGetGroupsResponse>(ev, State. Groups , GroupIndex);
206
+ Reply<TEvSysView::TEvGetGroupsResponse>(ev, GroupIndex);
210
207
}
211
208
212
209
void Handle (TEvSysView::TEvGetStoragePoolsRequest::TPtr& ev) {
213
- Reply<TEvSysView::TEvGetStoragePoolsResponse>(ev, State. StoragePools , StoragePoolIndex);
210
+ Reply<TEvSysView::TEvGetStoragePoolsResponse>(ev, StoragePoolIndex);
214
211
}
215
212
216
213
void Handle (TEvSysView::TEvGetStorageStatsRequest::TPtr& ev) {
0 commit comments