diff options
author | alexvru <alexvru@ydb.tech> | 2023-11-15 16:12:46 +0300 |
---|---|---|
committer | alexvru <alexvru@ydb.tech> | 2023-11-15 17:53:35 +0300 |
commit | 7d29550ba7d942914ec96a5101e6309148ebce50 (patch) | |
tree | cd5031f0f45aaab5fd4a12d2ebc9d6fe995e0341 | |
parent | d4e107c83f0d67938277a674c87e15494220b357 (diff) | |
download | ydb-7d29550ba7d942914ec96a5101e6309148ebce50.tar.gz |
Tidy up in KeyValue collector code KIKIMR-11082
-rw-r--r-- | ydb/core/keyvalue/keyvalue_collect_operation.cpp | 20 | ||||
-rw-r--r-- | ydb/core/keyvalue/keyvalue_collect_operation.h | 35 | ||||
-rw-r--r-- | ydb/core/keyvalue/keyvalue_helpers.cpp | 20 | ||||
-rw-r--r-- | ydb/core/keyvalue/keyvalue_helpers.h | 2 |
4 files changed, 7 insertions, 70 deletions
diff --git a/ydb/core/keyvalue/keyvalue_collect_operation.cpp b/ydb/core/keyvalue/keyvalue_collect_operation.cpp index 0ed2bdf78b..7573ec8dad 100644 --- a/ydb/core/keyvalue/keyvalue_collect_operation.cpp +++ b/ydb/core/keyvalue/keyvalue_collect_operation.cpp @@ -4,26 +4,10 @@ namespace NKikimr { namespace NKeyValue { -TCollectOperationHeader::TCollectOperationHeader(ui64 collectGeneration, ui64 collectStep, - TVector<TLogoBlobID> &keep, TVector<TLogoBlobID> &doNotKeep) +TCollectOperationHeader::TCollectOperationHeader(ui32 collectGeneration, ui32 collectStep) : CollectGeneration(collectGeneration) , CollectStep(collectStep) - , KeepCount(keep.size()) - , DoNotKeepCount(doNotKeep.size()) -{ - DataHeader.ItemType = EIT_COLLECT; - DataHeader.Checksum = 0; - ui8 sum = 0; - sum = THelpers::Checksum(sum, sizeof(TCollectOperationHeader), (const ui8*)this); - if (KeepCount) { - sum = THelpers::Checksum(sum, sizeof(TLogoBlobID) * KeepCount, (const ui8 *) &keep[0]); - } - if (DoNotKeepCount) { - sum = THelpers::Checksum(sum, sizeof(TLogoBlobID) * DoNotKeepCount, (const ui8 *) &doNotKeep[0]); - } - DataHeader.Checksum = sum; -} - +{} } // NKeyValue } // NKikimr diff --git a/ydb/core/keyvalue/keyvalue_collect_operation.h b/ydb/core/keyvalue/keyvalue_collect_operation.h index 328f6b0b3b..78f183dc05 100644 --- a/ydb/core/keyvalue/keyvalue_collect_operation.h +++ b/ydb/core/keyvalue/keyvalue_collect_operation.h @@ -7,13 +7,9 @@ namespace NKikimr { namespace NKeyValue { -#pragma pack(push, 1) struct TCollectOperationHeader { - TDataHeader DataHeader; - ui64 CollectGeneration; - ui64 CollectStep; - ui64 KeepCount; - ui64 DoNotKeepCount; + ui32 CollectGeneration; + ui32 CollectStep; ui64 GetCollectGeneration() const { return ReadUnaligned<ui64>(&CollectGeneration); @@ -21,30 +17,9 @@ struct TCollectOperationHeader { ui64 GetCollectStep() const { return ReadUnaligned<ui64>(&CollectStep); } - ui64 GetKeepCount() const { - return ReadUnaligned<ui64>(&KeepCount); - } - ui64 GetDoNotKeepCount() const { - return ReadUnaligned<ui64>(&DoNotKeepCount); - } - void SetCollectGeneration(ui64 value) { - WriteUnaligned<ui64>(&CollectGeneration, value); - } - void SetCollectStep(ui64 value) { - WriteUnaligned<ui64>(&CollectStep, value); - } - void SetKeepCount(ui64 value) { - WriteUnaligned<ui64>(&KeepCount, value); - } - void SetDoNotKeepCount(ui64 value) { - WriteUnaligned<ui64>(&DoNotKeepCount, value); - } - - TCollectOperationHeader(ui64 collectGeneration, ui64 collectStep, - TVector<TLogoBlobID> &keep, TVector<TLogoBlobID> &doNotKeep); + TCollectOperationHeader(ui32 collectGeneration, ui32 collectStep); }; -#pragma pack(pop) struct TCollectOperation : public TThrRefBase { TCollectOperationHeader Header; @@ -53,10 +28,10 @@ struct TCollectOperation : public TThrRefBase { TVector<TLogoBlobID> TrashGoingToCollect; const bool AdvanceBarrier; - TCollectOperation(ui64 collectGeneration, ui64 collectStep, + TCollectOperation(ui32 collectGeneration, ui32 collectStep, TVector<TLogoBlobID> &&keep, TVector<TLogoBlobID> &&doNotKeep, TVector<TLogoBlobID>&& trashGoingToCollect, bool advanceBarrier) - : Header(collectGeneration, collectStep, keep, doNotKeep) + : Header(collectGeneration, collectStep) , Keep(std::move(keep)) , DoNotKeep(std::move(doNotKeep)) , TrashGoingToCollect(std::move(trashGoingToCollect)) diff --git a/ydb/core/keyvalue/keyvalue_helpers.cpp b/ydb/core/keyvalue/keyvalue_helpers.cpp index cd4051d8cd..a00b482c83 100644 --- a/ydb/core/keyvalue/keyvalue_helpers.cpp +++ b/ydb/core/keyvalue/keyvalue_helpers.cpp @@ -85,26 +85,6 @@ void THelpers::DbUpdateTrash(const TLogoBlobID &id, ISimpleDb &db, const TActorC db.Update(key, value, ctx); } -void THelpers::DbUpdateCollect(ui64 collectGeneration, ui64 collectStep, - TVector<TLogoBlobID> keep, TVector<TLogoBlobID> doNotKeep, ISimpleDb &db, const TActorContext &ctx) { - TString empty; - TString key = THelpers::GenerateKeyFor(EIT_COLLECT, empty); - TCollectOperationHeader header(collectGeneration, collectStep, keep, doNotKeep); - TString value = TString::Uninitialized( - sizeof(TCollectOperationHeader) + sizeof(TLogoBlobID) * (keep.size() + doNotKeep.size())); - ui8 *data = (ui8*)const_cast<char *>(value.data()); - memcpy(data, &header, sizeof(header)); - data += sizeof(header); - if (keep.size()) { - memcpy(data, (ui8 *) &keep[0], sizeof(TLogoBlobID) * keep.size()); - } - data += sizeof(TLogoBlobID) * keep.size(); - if (doNotKeep.size()) { - memcpy(data, (ui8 *) &doNotKeep[0], sizeof(TLogoBlobID) * doNotKeep.size()); - } - db.Update(key, value, ctx); -} - void THelpers::DbEraseCollect(ISimpleDb &db, const TActorContext &ctx) { TString empty; TString key = THelpers::GenerateKeyFor(EIT_COLLECT, empty); diff --git a/ydb/core/keyvalue/keyvalue_helpers.h b/ydb/core/keyvalue/keyvalue_helpers.h index 68960f3b86..d7c246dd31 100644 --- a/ydb/core/keyvalue/keyvalue_helpers.h +++ b/ydb/core/keyvalue/keyvalue_helpers.h @@ -25,8 +25,6 @@ struct THelpers { static void DbEraseTrash(const TLogoBlobID &id, ISimpleDb &db, const TActorContext &ctx); static void DbUpdateTrash(const TLogoBlobID &id, ISimpleDb &db, const TActorContext &ctx); static void DbEraseCollect(ISimpleDb &db, const TActorContext &ctx); - static void DbUpdateCollect(ui64 collectGeneration, ui64 collectStep, - TVector<TLogoBlobID> keep, TVector<TLogoBlobID> doNotKeep, ISimpleDb &db, const TActorContext &ctx); using TGenerationStep = std::tuple<ui32, ui32>; static TGenerationStep GenerationStep(const TLogoBlobID &id); |