@@ -841,14 +841,25 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
841
841
}
842
842
}
843
843
844
+ static std::unordered_set<TTabletId> BuildIndex (const ::google::protobuf::RepeatedField<::NProtoBuf::uint64>& array) {
845
+ std::unordered_set<TTabletId> result;
846
+ result.reserve (array.size ());
847
+ for (auto id : array) {
848
+ result.insert (id);
849
+ }
850
+ return result;
851
+ }
852
+
844
853
void Handle (TEvWhiteboard::TEvTabletStateRequest::TPtr &ev, const TActorContext &ctx) {
845
854
auto now = TMonotonic::Now ();
846
855
const auto & request = ev->Get ()->Record ;
847
856
auto matchesFilter = [
848
857
changedSince = request.has_changedsince () ? request.changedsince () : 0 ,
858
+ filterTabletId = BuildIndex (request.filtertabletid ()),
849
859
filterTenantId = request.has_filtertenantid () ? NKikimr::TSubDomainKey (request.filtertenantid ()) : NKikimr::TSubDomainKey ()
850
860
](const NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo) {
851
861
return tabletStateInfo.changetime () >= changedSince
862
+ && (filterTabletId.empty () || filterTabletId.count (tabletStateInfo.tabletid ()))
852
863
&& (!filterTenantId || filterTenantId == NKikimr::TSubDomainKey (tabletStateInfo.tenantid ()));
853
864
};
854
865
std::unique_ptr<TEvWhiteboard::TEvTabletStateResponse> response = std::make_unique<TEvWhiteboard::TEvTabletStateResponse>();
@@ -871,22 +882,10 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
871
882
}
872
883
} else {
873
884
if (request.groupby ().empty ()) {
874
- if (request.filtertabletid_size () == 0 ) {
875
- for (const auto & pr : TabletStateInfo) {
876
- if (matchesFilter (pr.second )) {
877
- NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo = *record.add_tabletstateinfo ();
878
- Copy (tabletStateInfo, pr.second , request);
879
- }
880
- }
881
- } else {
882
- for (auto tabletId : request.filtertabletid ()) {
883
- auto it = TabletStateInfo.find ({tabletId, 0 });
884
- if (it != TabletStateInfo.end ()) {
885
- if (matchesFilter (it->second )) {
886
- NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo = *record.add_tabletstateinfo ();
887
- Copy (tabletStateInfo, it->second , request);
888
- }
889
- }
885
+ for (const auto & pr : TabletStateInfo) {
886
+ if (matchesFilter (pr.second )) {
887
+ NKikimrWhiteboard::TTabletStateInfo& tabletStateInfo = *record.add_tabletstateinfo ();
888
+ Copy (tabletStateInfo, pr.second , request);
890
889
}
891
890
}
892
891
} else if (request.groupby () == " Type,State" || request.groupby () == " NodeId,Type,State" ) { // the only supported group-by for now
0 commit comments