@@ -253,7 +253,7 @@ void TSourceIdStorage::DeregisterSourceId(const TString& sourceId) {
253
253
ExplicitSourceIds.erase (sourceId);
254
254
}
255
255
256
- SourceIdsByOffset.erase (std::make_pair (it->second .Offset , sourceId));
256
+ SourceIdsByOffset[it-> second . Explicit ] .erase (std::make_pair (it->second .Offset , sourceId));
257
257
InMemorySourceIds.erase (it);
258
258
259
259
auto jt = SourceIdOwners.find (sourceId);
@@ -277,7 +277,7 @@ bool TSourceIdStorage::DropOldSourceIds(TEvKeyValue::TEvRequest* request, TInsta
277
277
const auto ttl = TDuration::Seconds (config.GetSourceIdLifetimeSeconds ());
278
278
ui32 size = request->Record .ByteSize ();
279
279
280
- for (const auto & [offset, sourceId] : SourceIdsByOffset) {
280
+ for (const auto & [offset, sourceId] : SourceIdsByOffset[ 0 ] ) {
281
281
if (offset >= startOffset && toDelOffsets.size () >= maxDeleteSourceIds) {
282
282
break ;
283
283
}
@@ -323,7 +323,7 @@ bool TSourceIdStorage::DropOldSourceIds(TEvKeyValue::TEvRequest* request, TInsta
323
323
size_t res = InMemorySourceIds.erase (t.second );
324
324
Y_ABORT_UNLESS (res == 1 );
325
325
// delete sourceID from offsets
326
- res = SourceIdsByOffset.erase (t);
326
+ res = SourceIdsByOffset[ 0 ] .erase (t);
327
327
Y_ABORT_UNLESS (res == 1 );
328
328
// save owners to drop and delete records from map
329
329
auto it = SourceIdOwners.find (t.second );
@@ -372,14 +372,14 @@ void TSourceIdStorage::RegisterSourceIdInfo(const TString& sourceId, TSourceIdIn
372
372
auto it = InMemorySourceIds.find (sourceId);
373
373
if (it != InMemorySourceIds.end ()) {
374
374
if (!load || it->second .Offset < sourceIdInfo.Offset ) {
375
- const auto res = SourceIdsByOffset.erase (std::make_pair (it->second .Offset , sourceId));
375
+ const auto res = SourceIdsByOffset[sourceIdInfo. Explicit ] .erase (std::make_pair (it->second .Offset , sourceId));
376
376
Y_ABORT_UNLESS (res == 1 );
377
377
} else {
378
378
return ;
379
379
}
380
380
}
381
381
382
- const bool res = SourceIdsByOffset.emplace (sourceIdInfo.Offset , sourceId).second ;
382
+ const bool res = SourceIdsByOffset[sourceIdInfo. Explicit ] .emplace (sourceIdInfo.Offset , sourceId).second ;
383
383
Y_ABORT_UNLESS (res);
384
384
385
385
if (sourceIdInfo.Explicit ) {
@@ -421,10 +421,12 @@ void TSourceIdStorage::MarkOwnersForDeletedSourceId(THashMap<TString, TOwnerInfo
421
421
422
422
TInstant TSourceIdStorage::MinAvailableTimestamp (TInstant now) const {
423
423
TInstant ds = now;
424
- if (!SourceIdsByOffset.empty ()) {
425
- auto it = InMemorySourceIds.find (SourceIdsByOffset.begin ()->second );
426
- Y_ABORT_UNLESS (it != InMemorySourceIds.end ());
427
- ds = Min (ds, it->second .WriteTimestamp );
424
+ for (ui32 i = 0 ; i < 2 ; ++i) {
425
+ if (!SourceIdsByOffset[i].empty ()) {
426
+ auto it = InMemorySourceIds.find (SourceIdsByOffset[i].begin ()->second );
427
+ Y_ABORT_UNLESS (it != InMemorySourceIds.end ());
428
+ ds = Min (ds, it->second .WriteTimestamp );
429
+ }
428
430
}
429
431
430
432
return ds;
0 commit comments