@@ -29,6 +29,21 @@ class TPortionInfoConstructor {
2929 YDB_ACCESSOR_DEF (std::vector<TColumnRecord>, Records);
3030 std::vector<TUnifiedBlobId> BlobIds;
3131
32+ class TAddressBlobId {
33+ private:
34+ YDB_READONLY_DEF (TChunkAddress, Address);
35+ YDB_READONLY (TBlobRangeLink16::TLinkId, BlobIdx, 0 );
36+
37+ public:
38+ TAddressBlobId (const TChunkAddress& address, const TBlobRangeLink16::TLinkId blobIdx)
39+ : Address(address)
40+ , BlobIdx(blobIdx)
41+ {
42+
43+ }
44+ };
45+ std::vector<TAddressBlobId> BlobIdxs;
46+
3247public:
3348 void SetPortionId (const ui64 value) {
3449 AFL_VERIFY (value);
@@ -226,19 +241,7 @@ class TPortionInfoConstructor {
226241 }
227242
228243 void RegisterBlobIdx (const TChunkAddress& address, const TBlobRangeLink16::TLinkId blobIdx) {
229- for (auto && i : Records) {
230- if (i.GetColumnId () == address.GetEntityId () && i.GetChunkIdx () == address.GetChunkIdx ()) {
231- i.RegisterBlobIdx (blobIdx);
232- return ;
233- }
234- }
235- for (auto && i : Indexes) {
236- if (i.GetIndexId () == address.GetEntityId () && i.GetChunkIdx () == address.GetChunkIdx ()) {
237- i.RegisterBlobIdx (blobIdx);
238- return ;
239- }
240- }
241- AFL_VERIFY (false )(" problem" , " portion haven't address for blob registration" )(" address" , address.DebugString ());
244+ BlobIdxs.emplace_back (address, blobIdx);
242245 }
243246
244247 TString DebugString () const {
@@ -265,26 +268,37 @@ class TPortionInfoConstructor {
265268 std::sort (Indexes.begin (), Indexes.end (), pred);
266269 CheckChunksOrder (Indexes);
267270 }
271+ {
272+ auto pred = [](const TIndexChunk& l, const TIndexChunk& r) {
273+ return l.GetAddress () < r.GetAddress ();
274+ };
275+ std::sort (BlobIdxs.begin (), BlobIdxs.end (), pred);
276+ }
268277 }
269278
270279 void FullValidation () const {
271280 AFL_VERIFY (Records.size ());
272281 CheckChunksOrder (Records);
273282 CheckChunksOrder (Indexes);
274- std::set<ui32> blobIdxs;
275- for (auto && i : Records) {
276- blobIdxs.emplace (i.GetBlobRange ().GetBlobIdxVerified ());
277- }
278- for (auto && i : Indexes) {
279- if (i.HasBlobRange ()) {
280- blobIdxs.emplace (i.GetBlobRangeVerified ().GetBlobIdxVerified ());
281- }
282- }
283- if (BlobIds.size ()) {
284- AFL_VERIFY (BlobIds.size () == blobIdxs.size ());
285- AFL_VERIFY (BlobIds.size () == *blobIdxs.rbegin () + 1 );
283+ if (BlobIdxs.size ()) {
284+ AFL_VERIFY (BlobIdxs.size () == Records.size () + Indexes.size ())(" blobs" , BlobIdxs.size ())(" records" , Records.size ())(
285+ " indexes" , Indexes.size ());
286286 } else {
287- AFL_VERIFY (blobIdxs.empty ());
287+ std::set<ui32> blobIdxs;
288+ for (auto && i : Records) {
289+ blobIdxs.emplace (i.GetBlobRange ().GetBlobIdxVerified ());
290+ }
291+ for (auto && i : Indexes) {
292+ if (i.HasBlobRange ()) {
293+ blobIdxs.emplace (i.GetBlobRangeVerified ().GetBlobIdxVerified ());
294+ }
295+ }
296+ if (BlobIds.size ()) {
297+ AFL_VERIFY (BlobIds.size () == blobIdxs.size ());
298+ AFL_VERIFY (BlobIds.size () == *blobIdxs.rbegin () + 1 );
299+ } else {
300+ AFL_VERIFY (blobIdxs.empty ());
301+ }
288302 }
289303 }
290304
0 commit comments