@@ -14,27 +14,29 @@ namespace NKikimr::NPQ {
14
14
ui16 PartNo;
15
15
ui32 Count; // have to be unique for {Partition, Offset, partNo}
16
16
ui16 InternalPartsCount; // have to be unique for {Partition, Offset, partNo}
17
+ char Suffix;
17
18
18
- TBlobId (const TPartitionId& partition, ui64 offset, ui16 partNo, ui32 count, ui16 internalPartsCount)
19
+ TBlobId (const TPartitionId& partition, ui64 offset, ui16 partNo, ui32 count, ui16 internalPartsCount, TMaybe< char > suffix )
19
20
: Partition(partition)
20
21
, Offset(offset)
21
22
, PartNo(partNo)
22
23
, Count(count)
23
24
, InternalPartsCount(internalPartsCount)
25
+ , Suffix(suffix ? *suffix : ' \0 ' )
24
26
{
25
27
}
26
28
27
29
bool operator <(const TBlobId& r) const {
28
30
auto makeTuple = [](const TBlobId& v) {
29
- return std::make_tuple (v.Partition , v.Offset , v.PartNo , v.Count , v.InternalPartsCount );
31
+ return std::make_tuple (v.Partition , v.Offset , v.PartNo , v.Count , v.InternalPartsCount , v. Suffix );
30
32
};
31
33
32
34
return makeTuple (*this ) < makeTuple (r);
33
35
}
34
36
35
37
bool operator ==(const TBlobId& r) const {
36
38
auto makeTuple = [](const TBlobId& v) {
37
- return std::make_tuple (v.Partition , v.Offset , v.PartNo , v.Count , v.InternalPartsCount );
39
+ return std::make_tuple (v.Partition , v.Offset , v.PartNo , v.Count , v.InternalPartsCount , v. Suffix );
38
40
};
39
41
40
42
return makeTuple (*this ) == makeTuple (r);
@@ -44,6 +46,7 @@ namespace NKikimr::NPQ {
44
46
ui64 hash = Hash128to32 ((ui64 (Partition.InternalPartitionId ) << 17 ) + (Partition.IsSupportivePartition () ? 0 : (1 << 16 )) + PartNo, Offset);
45
47
hash = Hash128to32 (hash, Count);
46
48
hash = Hash128to32 (hash, InternalPartsCount);
49
+ hash = Hash128to32 (hash, Suffix);
47
50
return hash;
48
51
}
49
52
};
@@ -58,7 +61,7 @@ struct THash<NKikimr::NPQ::TBlobId> {
58
61
59
62
namespace NKikimr ::NPQ {
60
63
inline TBlobId MakeBlobId (const TPartitionId& partitionId, const TRequestedBlob& blob) {
61
- return {partitionId, blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount };
64
+ return {partitionId, blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , blob. Key . GetSuffix () };
62
65
}
63
66
64
67
struct TKvRequest {
@@ -106,7 +109,7 @@ namespace NKikimr::NPQ {
106
109
for (auto & blob : Blobs) {
107
110
if (blob.Value .empty ()) {
108
111
// add reading command
109
- auto key = TKey::ForBody (TKeyPrefix::TypeData, Partition, blob.Offset , blob. PartNo , blob. Count , blob. InternalPartsCount ) ;
112
+ const auto & key = blob.Key ;
110
113
auto read = request->Record .AddCmdRead ();
111
114
read->SetKey (key.Data (), key.Size ());
112
115
}
@@ -142,9 +145,10 @@ namespace NKikimr::NPQ {
142
145
}
143
146
144
147
void Verify (const TRequestedBlob& blob) const {
145
- auto key = TKey::ForBody (TKeyPrefix::TypeData, TPartitionId (0 ), blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount );
146
- Y_ABORT_UNLESS (blob.Value .size () == blob.Size );
147
- TClientBlob::CheckBlob (key, blob.Value );
148
+ Y_ABORT_UNLESS (blob.Value .size () == blob.Size ,
149
+ " \n blob.Value.size=%" PRISZT " , blob.Size=%" PRIu64 " \n blob.Key=%s" ,
150
+ blob.Value .size (), blob.Size , blob.Key .ToString ().data ());
151
+ TClientBlob::CheckBlob (blob.Key , blob.Value );
148
152
}
149
153
};
150
154
@@ -271,7 +275,7 @@ namespace NKikimr::NPQ {
271
275
for (const auto & blob : kvReq.Blobs ) {
272
276
// Touching blobs in L2. We don't need data here
273
277
auto & blobs = blob.Cached ? reqData->RequestedBlobs : reqData->MissedBlobs ;
274
- blobs.emplace_back (kvReq.Partition , blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , nullptr );
278
+ blobs.emplace_back (kvReq.Partition , blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , blob. Key . GetSuffix (), nullptr );
275
279
}
276
280
277
281
auto l2Request = MakeHolder<TEvPqCache::TEvCacheL2Request>(reqData.Release ());
@@ -298,7 +302,7 @@ namespace NKikimr::NPQ {
298
302
299
303
// there could be a new blob with same id (for big messages)
300
304
if (RemoveExists (ctx, blob)) {
301
- reqData.RemovedBlobs .emplace_back (kvReq.Partition , reqBlob.Offset , reqBlob.PartNo , reqBlob.Count , reqBlob.InternalPartsCount , nullptr );
305
+ reqData.RemovedBlobs .emplace_back (kvReq.Partition , reqBlob.Offset , reqBlob.PartNo , reqBlob.Count , reqBlob.InternalPartsCount , reqBlob. Key . GetSuffix (), nullptr );
302
306
}
303
307
304
308
auto cached = std::make_shared<TCacheValue>(reqBlob.Value , ctx.SelfID , TAppData::TimeProvider->Now ());
@@ -308,7 +312,7 @@ namespace NKikimr::NPQ {
308
312
if (L1Strategy)
309
313
L1Strategy->SaveHeadBlob (blob);
310
314
311
- reqData.StoredBlobs .emplace_back (kvReq.Partition , reqBlob.Offset , reqBlob.PartNo , blob.Count , blob.InternalPartsCount , cached);
315
+ reqData.StoredBlobs .emplace_back (kvReq.Partition , reqBlob.Offset , reqBlob.PartNo , blob.Count , blob.InternalPartsCount , blob. Suffix , cached);
312
316
313
317
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Caching head blob in L1. Partition "
314
318
<< blob.Partition << " offset " << blob.Offset << " count " << blob.Count
@@ -322,10 +326,10 @@ namespace NKikimr::NPQ {
322
326
TPartitionId partitionId;
323
327
partitionId.OriginalPartitionId = FromString<ui32>(s.data () + 1 , 10 );
324
328
partitionId.InternalPartitionId = partitionId.OriginalPartitionId ;
325
- return {partitionId, 0 , 0 , 0 , 0 };
329
+ return {partitionId, 0 , 0 , 0 , 0 , Nothing () };
326
330
} else {
327
331
auto key = TKey::FromString (s);
328
- return {key.GetPartition (), key.GetOffset (), key.GetPartNo (), key.GetCount (), key.GetInternalPartsCount ()};
332
+ return {key.GetPartition (), key.GetOffset (), key.GetPartNo (), key.GetCount (), key.GetInternalPartsCount (), key. GetSuffix () };
329
333
}
330
334
}
331
335
@@ -336,8 +340,8 @@ namespace NKikimr::NPQ {
336
340
TBlobId newBlob = MakeBlobId (newKey);
337
341
if (RenameExists (ctx, oldBlob, newBlob)) {
338
342
reqData.RenamedBlobs .emplace_back (std::piecewise_construct,
339
- std::make_tuple (oldBlob.Partition , oldBlob.Offset , oldBlob.PartNo , oldBlob.Count , oldBlob.InternalPartsCount , nullptr ),
340
- std::make_tuple (newBlob.Partition , newBlob.Offset , newBlob.PartNo , newBlob.Count , newBlob.InternalPartsCount , nullptr ));
343
+ std::make_tuple (oldBlob.Partition , oldBlob.Offset , oldBlob.PartNo , oldBlob.Count , oldBlob.InternalPartsCount , oldBlob. Suffix , nullptr ),
344
+ std::make_tuple (newBlob.Partition , newBlob.Offset , newBlob.PartNo , newBlob.Count , newBlob.InternalPartsCount , newBlob. Suffix , nullptr ));
341
345
342
346
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Renaming head blob in L1. Old partition "
343
347
<< oldBlob.Partition << " old offset " << oldBlob.Offset << " old count " << oldBlob.Count
@@ -357,7 +361,7 @@ namespace NKikimr::NPQ {
357
361
for (auto i = lowerBound; i != upperBound; ++i) {
358
362
const auto & [blob, value] = *i;
359
363
360
- reqData.RemovedBlobs .emplace_back (blob.Partition , blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , nullptr );
364
+ reqData.RemovedBlobs .emplace_back (blob.Partition , blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , blob. Suffix , nullptr );
361
365
Counters.Dec (value);
362
366
363
367
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Deleting head blob in L1. Partition "
@@ -395,7 +399,7 @@ namespace NKikimr::NPQ {
395
399
Cache[blob] = valL1; // weak
396
400
Counters.Inc (valL1);
397
401
398
- reqData->StoredBlobs .emplace_back (kvReq.Partition , reqBlob.Offset , reqBlob.PartNo , reqBlob.Count , reqBlob.InternalPartsCount , cached);
402
+ reqData->StoredBlobs .emplace_back (kvReq.Partition , reqBlob.Offset , reqBlob.PartNo , reqBlob.Count , reqBlob.InternalPartsCount , reqBlob. Key . GetSuffix (), cached);
399
403
400
404
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Prefetched blob in L1. Partition "
401
405
<< blob.Partition << " offset " << blob.Offset << " count " << blob.Count
@@ -450,7 +454,7 @@ namespace NKikimr::NPQ {
450
454
void PrepareTouch (const TActorContext& ctx, THolder<TCacheL2Request>& reqData, const TDeque<TBlobId>& used)
451
455
{
452
456
for (auto & blob : used) {
453
- reqData->ExpectedBlobs .emplace_back (blob.Partition , blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , nullptr );
457
+ reqData->ExpectedBlobs .emplace_back (blob.Partition , blob.Offset , blob.PartNo , blob.Count , blob.InternalPartsCount , blob. Suffix , nullptr );
454
458
455
459
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Touching blob. Partition "
456
460
<< blob.Partition << " offset " << blob.Offset << " count " << blob.Count );
@@ -462,14 +466,18 @@ namespace NKikimr::NPQ {
462
466
const auto it = Cache.find (blobId);
463
467
if (it == Cache.end ()) {
464
468
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " No blob in L1. Partition "
465
- << blobId.Partition << " offset " << blobId.Offset << " actorID " << ctx.SelfID );
469
+ << blobId.Partition << " offset " << blobId.Offset <<
470
+ " partno " << blobId.PartNo << " count " << blobId.Count << " parts_count " << blobId.InternalPartsCount <<
471
+ " actorID " << ctx.SelfID );
466
472
return nullptr ;
467
473
}
468
474
469
475
TCacheValue::TPtr data = it->second .GetBlob ();
470
476
if (!data) {
471
477
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Evicted blob in L1. Partition "
472
- << blobId.Partition << " offset " << blobId.Offset << " actorID " << ctx.SelfID );
478
+ << blobId.Partition << " offset " << blobId.Offset <<
479
+ " partno " << blobId.PartNo << " count " << blobId.Count << " parts_count " << blobId.InternalPartsCount <<
480
+ " actorID " << ctx.SelfID );
473
481
RemoveBlob (it);
474
482
return nullptr ;
475
483
}
@@ -478,7 +486,8 @@ namespace NKikimr::NPQ {
478
486
479
487
const TBlobId& blob = it->first ;
480
488
LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Got data from cache. Partition "
481
- << blob.Partition << " offset " << blob.Offset << " count " << blob.Count
489
+ << blob.Partition << " offset " << blob.Offset <<
490
+ " partno " << blob.PartNo << " count " << blob.Count << " parts_count " << blob.InternalPartsCount
482
491
<< " source " << (ui32)it->second .Source << " size " << data->DataSize ()
483
492
<< " accessed " << data->GetAccessCount () << " times before, last time " << data->GetAccessTime ());
484
493
0 commit comments