aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexvru <alexvru@ydb.tech>2022-08-04 14:36:44 +0300
committeralexvru <alexvru@ydb.tech>2022-08-04 14:36:44 +0300
commit49006889f73404f165d461ffe46a58107df3c5e7 (patch)
tree49c43b551b7294e20edf34eb7c63df75a14b683d
parentcabc63393f59d3b32d4aa1a060043f4cb50763be (diff)
downloadydb-49006889f73404f165d461ffe46a58107df3c5e7.tar.gz
BlobDepot work in progress
-rw-r--r--ydb/core/blob_depot/data.cpp30
-rw-r--r--ydb/core/blob_depot/data.h24
-rw-r--r--ydb/core/blob_depot/op_commit_blob_seq.cpp7
-rw-r--r--ydb/core/protos/blob_depot.proto2
4 files changed, 37 insertions, 26 deletions
diff --git a/ydb/core/blob_depot/data.cpp b/ydb/core/blob_depot/data.cpp
index aa43ca596ab..06e335af3af 100644
--- a/ydb/core/blob_depot/data.cpp
+++ b/ydb/core/blob_depot/data.cpp
@@ -4,11 +4,6 @@ namespace NKikimr::NBlobDepot {
using TData = TBlobDepot::TData;
- std::optional<TData::TValue> TData::FindKey(const TKey& key) {
- const auto it = Data.find(key);
- return it != Data.end() ? std::make_optional(it->second) : std::nullopt;
- }
-
TData::TRecordsPerChannelGroup& TData::GetRecordsPerChannelGroup(TLogoBlobID id) {
TTabletStorageInfo *info = Self->Info();
const ui32 groupId = info->GroupFor(id.Channel(), id.Generation());
@@ -26,12 +21,7 @@ namespace NKikimr::NBlobDepot {
NKikimrBlobDepot::TValue proto;
const bool success = proto.ParseFromString(value);
Y_VERIFY(success);
- PutKey(std::move(key), {
- .Meta = proto.GetMeta(),
- .ValueChain = std::move(*proto.MutableValueChain()),
- .KeepState = proto.GetKeepState(),
- .Public = proto.GetPublic(),
- });
+ PutKey(std::move(key), TValue(std::move(proto)));
}
void TData::AddTrashOnLoad(TLogoBlobID id) {
@@ -67,17 +57,21 @@ namespace NKikimr::NBlobDepot {
(ValueChain.size, data.ValueChain.size()), (ReferencedBytes, referencedBytes),
(KeepState, NKikimrBlobDepot::EKeepState_Name(data.KeepState)));
- Data[std::move(key)] = std::move(data);
+ const auto [it, inserted] = Data.try_emplace(std::move(key), std::move(data));
+ if (!inserted) {
+ it->second = std::move(data);
+ }
}
std::optional<TString> TData::UpdateKeepState(TKey key, NKikimrBlobDepot::EKeepState keepState) {
- const auto it = Data.find(key);
- if (it != Data.end() && keepState <= it->second.KeepState) {
- return std::nullopt;
+ const auto [it, inserted] = Data.try_emplace(std::move(key), TValue(keepState));
+ if (!inserted) {
+ if (keepState <= it->second.KeepState) {
+ return std::nullopt;
+ }
+ it->second.KeepState = keepState;
}
- auto& value = Data[std::move(key)];
- value.KeepState = keepState;
- return ToValueProto(value);
+ return ToValueProto(it->second);
}
void TData::DeleteKey(const TKey& key, const std::function<void(TLogoBlobID)>& updateTrash, void *cookie) {
diff --git a/ydb/core/blob_depot/data.h b/ydb/core/blob_depot/data.h
index 4816dced3ae..a8885506694 100644
--- a/ydb/core/blob_depot/data.h
+++ b/ydb/core/blob_depot/data.h
@@ -212,6 +212,28 @@ namespace NKikimr::NBlobDepot {
TValueChain ValueChain;
NKikimrBlobDepot::EKeepState KeepState;
bool Public;
+ bool Unconfirmed;
+
+ TValue() = delete;
+ TValue(const TValue&) = delete;
+ TValue(TValue&&) = default;
+
+ TValue& operator =(const TValue&) = delete;
+ TValue& operator =(TValue&&) = default;
+
+ explicit TValue(NKikimrBlobDepot::TValue&& proto)
+ : Meta(proto.GetMeta())
+ , ValueChain(std::move(*proto.MutableValueChain()))
+ , KeepState(proto.GetKeepState())
+ , Public(proto.GetPublic())
+ , Unconfirmed(proto.GetUnconfirmed())
+ {}
+
+ explicit TValue(NKikimrBlobDepot::EKeepState keepState)
+ : KeepState(keepState)
+ , Public(false)
+ , Unconfirmed(false)
+ {}
};
enum EScanFlags : ui32 {
@@ -276,8 +298,6 @@ namespace NKikimr::NBlobDepot {
: Self(self)
{}
- std::optional<TValue> FindKey(const TKey& key);
-
template<typename TCallback>
void ScanRange(const TKey *begin, const TKey *end, TScanFlags flags, TCallback&& callback) {
auto beginIt = !begin ? Data.begin()
diff --git a/ydb/core/blob_depot/op_commit_blob_seq.cpp b/ydb/core/blob_depot/op_commit_blob_seq.cpp
index 0f1d3154123..a2d416dc581 100644
--- a/ydb/core/blob_depot/op_commit_blob_seq.cpp
+++ b/ydb/core/blob_depot/op_commit_blob_seq.cpp
@@ -69,12 +69,7 @@ namespace NKikimr::NBlobDepot {
db.Table<Schema::Data>().Key(item.GetKey()).Update<Schema::Data::Value>(valueData);
- Self->Data->PutKey(std::move(key), {
- .Meta = value.GetMeta(),
- .ValueChain = std::move(*value.MutableValueChain()),
- .KeepState = value.GetKeepState(),
- .Public = value.GetPublic(),
- });
+ Self->Data->PutKey(std::move(key), TData::TValue(std::move(value)));
}
return true;
diff --git a/ydb/core/protos/blob_depot.proto b/ydb/core/protos/blob_depot.proto
index cd49115f4ce..ae94e3c8368 100644
--- a/ydb/core/protos/blob_depot.proto
+++ b/ydb/core/protos/blob_depot.proto
@@ -35,6 +35,7 @@ message TValue {
repeated TValueChain ValueChain = 2;
optional EKeepState KeepState = 3;
optional bool Public = 4;
+ optional bool Unconfirmed = 5;
}
message TGivenIdRange {
@@ -150,6 +151,7 @@ message TEvCommitBlobSeq {
optional TBlobLocator BlobLocator = 1; // GroupId and Generation are for validation purposes
optional bytes Key = 2;
optional bytes Meta = 3;
+ optional bool Unconfirmed = 4; // if true, then write to BS hasn't been actually performed yet
}
repeated TItem Items = 1;