From 14e231dde4d774daedb4c85f927c05d6e1188f2a Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Thu, 20 Nov 2025 22:00:08 +0100 Subject: [PATCH 1/7] proposed new design --- Design/NewDesign.dio | 136 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Design/NewDesign.dio diff --git a/Design/NewDesign.dio b/Design/NewDesign.dio new file mode 100644 index 00000000..e45dc1b0 --- /dev/null +++ b/Design/NewDesign.dio @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 558cb58a06757db38b13b7c653ed699800f3484b Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Thu, 18 Dec 2025 00:09:35 +0100 Subject: [PATCH 2/7] new puml design --- Design/Design_puml.puml | 158 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 Design/Design_puml.puml diff --git a/Design/Design_puml.puml b/Design/Design_puml.puml new file mode 100644 index 00000000..8daa013d --- /dev/null +++ b/Design/Design_puml.puml @@ -0,0 +1,158 @@ +@startuml NewDesign + +' Define color schemes matching original design +skinparam class { + BackgroundColor<> LightYellow + BorderColor<> DarkGoldenRod + BackgroundColor<> LightBlue + BorderColor<> DodgerBlue + BackgroundColor<> LightPink + BorderColor<> IndianRed +} + +class IKvsBuilder <> { + - instance_id: InstanceId + - need_defaults : bool + - need_kvs : bool + - directory: string + - OpenedKvs : std::unordered_map > + __ + + KvsBuilder(const InstanceId& instance_id) + + need_defaults_flag(bool flag) : KvsBuilder& + + need_kvs_flag(bool flag) : KvsBuilder& + + dir(std::string&& dir_path) : KvsBuilder& + + backend(IStorageBackend backend) : KvsBuilder& + + build() : std::shared_ptr +} + +IKvsBuilder -[hidden]right- IStorageBackEnd +IStorageBackEnd -[hidden]right- IKvs + +' IStorageBackEnd interface (top middle-right) +interface IStorageBackEnd <> { + + Load_kvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + + Load_default(instance_id:InstanceId) + + Flush(instance_id:InstanceId, kvs:unordered_map + + Snapshot_count(instance_id:InstanceId):Result + + Snapshot_restore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs +} + +' IKvs interface (top right) +interface IKvs <> { + + reset() + + reset_key(string key):Result + + get_all_keys() : Result> + + key_exists(key:string): Result + + get_value(key:string) : Result + + get_default_value(Key:string) : Result + + has_default_value(Key:string) : Result + + set_value(Key:string, value:KvsValue): ResultBlank + + remove_key(Key:string) : ResultBlank + + flush() : ResultBlank + + snapshot_count: Result + + snapshot_max_count() : Result + + snapshot_restore(snapshot_id:SnapshotId): ResultBlank + + get_kvs_file_name(snapshot_id:SnapshotId): Result + + get_hash_filename(snapshot_id:SnapshotId): Result +} + +IStorageBackEnd_Mock -[hidden]right- JsonBackEnd +JsonBackEnd -[hidden]right- IKvs_mock +IKvs_mock -[hidden]right- Kvs + +' IStorageBackEnd_Mock (middle left) +class IStorageBackEnd_Mock <> { + + Load_kvs(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs + + Load_default(instance_id:InstanceId) + + Flush(instance_id:InstanceId, kvs:unordered_map + + Snapshot_count(instance_id:InstanceId):Result + + Snapshot_restore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + + get_kvs_file_name(snapshot_id:SnapshotId): Result + + get_hash_filename(snapshot_id:SnapshotId): Result +} + +' JsonBackEnd (middle right) +class JsonBackEnd <> { + - Instance_id: InstanceId + __ + + Load_kvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + + Load_default(instance_id:InstanceId) + + Flush(instance_id:InstanceId, kvs:unordered_map + + Snapshot_count(instance_id:InstanceId):Result + + Snapshot_restore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + + **get_kvs_file_name(snapshot_id:SnapshotId): Result** + + **get_hash_filename(snapshot_id:SnapshotId): Result** +} + +' IKvs_mock (bottom middle-left) +class IKvs_mock <> { + + reset() + + reset_key(string key):Result + + get_all_keys() : Result> + + key_exists(key:string): Result + + get_value(key:string) : Result + + get_default_value(Key:string) : Result + + has_default_value(Key:string) : Result + + set_value(Key:string, value:KvsValue): ResultBlank + + remove_key(Key:string) : ResultBlank + + flush() : ResultBlank + + snapshot_count: Result + + snapshot_max_count() : Result + + snapshot_restore(snapshot_id:SnapshotId): ResultBlank + + get_kvs_file_name(snapshot_id:SnapshotId): Result + + get_hash_filename(snapshot_id:SnapshotId): Result +} + +' Kvs (bottom right) +class Kvs <> { + + kvs : unordered_map + + default_kvs : unordered_map + + filename_prefix : score::filesystem::path + + filesystem : score::filesystem + + parser : unique_ptr parser + + writer : unique_ptr writer + + logger : unique_ptr logger + + Storage_backend : IStorageBackEnd + __ + + reset() + + reset_key(string key):Result + + get_all_keys() : Result> + + key_exists(key:string): Result + + get_value(key:string) : Result + + get_default_value(Key:string) : Result + + has_default_value(Key:string) : Result + + set_value(Key:string, value:KvsValue): ResultBlank + + remove_key(Key:string) : ResultBlank + + flush() : ResultBlank + + snapshot_count: Result + + snapshot_max_count() : Result + + snapshot_restore(snapshot_id:SnapshotId): ResultBlank + + get_kvs_file_name(snapshot_id:SnapshotId): Result + + get_hash_filename(snapshot_id:SnapshotId): Result +} + +' Relationships +IStorageBackEnd_Mock -up-|> IStorageBackEnd : implements +JsonBackEnd -up-|> IStorageBackEnd : implements +IKvs_mock -up-|> IKvs : implements +Kvs -up-|> IKvs : implements + +' Dependencies +IKvsBuilder ..> IStorageBackEnd : uses +IKvsBuilder ..> IKvs : uses +IStorageBackEnd o-- IKvs : aggregates + +' Notes matching original design +note left of IKvsBuilder + builder will contain static map for opened instances + single tone should be applied to the builder + builder should contains cached opened KVSs +end note + +note right of IKvsBuilder + by default json backend is used but other backends + can be implemented and passed to the builder through + **backend()** method +end note + +@enduml From 0e91d66effd700f680635e67ae11c1d2df67560a Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Thu, 18 Dec 2025 00:11:14 +0100 Subject: [PATCH 3/7] update dio design --- Design/NewDesign.dio | 52 +++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/Design/NewDesign.dio b/Design/NewDesign.dio index e45dc1b0..07881a82 100644 --- a/Design/NewDesign.dio +++ b/Design/NewDesign.dio @@ -1,22 +1,13 @@ - + - - - - - - - - - - + - + @@ -25,29 +16,14 @@ - - - - - - - - - - - - - - - - + - - + + @@ -70,7 +46,7 @@ - + @@ -112,24 +88,32 @@ - + + - + - + + + + + + + + From 698e7ffb919a7e7e5ef1963d17135f40df718a75 Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Wed, 14 Jan 2026 14:50:45 +0100 Subject: [PATCH 4/7] update class diagram for kvs - class diagram represent new design of score kvs. --- Design/Design_puml.puml | 158 ----------------------------- Design/NewDesign.dio | 120 ---------------------- docs/Design/class_diagram_cpp.puml | 147 +++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 278 deletions(-) delete mode 100644 Design/Design_puml.puml delete mode 100644 Design/NewDesign.dio create mode 100644 docs/Design/class_diagram_cpp.puml diff --git a/Design/Design_puml.puml b/Design/Design_puml.puml deleted file mode 100644 index 8daa013d..00000000 --- a/Design/Design_puml.puml +++ /dev/null @@ -1,158 +0,0 @@ -@startuml NewDesign - -' Define color schemes matching original design -skinparam class { - BackgroundColor<> LightYellow - BorderColor<> DarkGoldenRod - BackgroundColor<> LightBlue - BorderColor<> DodgerBlue - BackgroundColor<> LightPink - BorderColor<> IndianRed -} - -class IKvsBuilder <> { - - instance_id: InstanceId - - need_defaults : bool - - need_kvs : bool - - directory: string - - OpenedKvs : std::unordered_map > - __ - + KvsBuilder(const InstanceId& instance_id) - + need_defaults_flag(bool flag) : KvsBuilder& - + need_kvs_flag(bool flag) : KvsBuilder& - + dir(std::string&& dir_path) : KvsBuilder& - + backend(IStorageBackend backend) : KvsBuilder& - + build() : std::shared_ptr -} - -IKvsBuilder -[hidden]right- IStorageBackEnd -IStorageBackEnd -[hidden]right- IKvs - -' IStorageBackEnd interface (top middle-right) -interface IStorageBackEnd <> { - + Load_kvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs - + Load_default(instance_id:InstanceId) - + Flush(instance_id:InstanceId, kvs:unordered_map - + Snapshot_count(instance_id:InstanceId):Result - + Snapshot_restore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs -} - -' IKvs interface (top right) -interface IKvs <> { - + reset() - + reset_key(string key):Result - + get_all_keys() : Result> - + key_exists(key:string): Result - + get_value(key:string) : Result - + get_default_value(Key:string) : Result - + has_default_value(Key:string) : Result - + set_value(Key:string, value:KvsValue): ResultBlank - + remove_key(Key:string) : ResultBlank - + flush() : ResultBlank - + snapshot_count: Result - + snapshot_max_count() : Result - + snapshot_restore(snapshot_id:SnapshotId): ResultBlank - + get_kvs_file_name(snapshot_id:SnapshotId): Result - + get_hash_filename(snapshot_id:SnapshotId): Result -} - -IStorageBackEnd_Mock -[hidden]right- JsonBackEnd -JsonBackEnd -[hidden]right- IKvs_mock -IKvs_mock -[hidden]right- Kvs - -' IStorageBackEnd_Mock (middle left) -class IStorageBackEnd_Mock <> { - + Load_kvs(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs - + Load_default(instance_id:InstanceId) - + Flush(instance_id:InstanceId, kvs:unordered_map - + Snapshot_count(instance_id:InstanceId):Result - + Snapshot_restore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs - + get_kvs_file_name(snapshot_id:SnapshotId): Result - + get_hash_filename(snapshot_id:SnapshotId): Result -} - -' JsonBackEnd (middle right) -class JsonBackEnd <> { - - Instance_id: InstanceId - __ - + Load_kvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs - + Load_default(instance_id:InstanceId) - + Flush(instance_id:InstanceId, kvs:unordered_map - + Snapshot_count(instance_id:InstanceId):Result - + Snapshot_restore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs - + **get_kvs_file_name(snapshot_id:SnapshotId): Result** - + **get_hash_filename(snapshot_id:SnapshotId): Result** -} - -' IKvs_mock (bottom middle-left) -class IKvs_mock <> { - + reset() - + reset_key(string key):Result - + get_all_keys() : Result> - + key_exists(key:string): Result - + get_value(key:string) : Result - + get_default_value(Key:string) : Result - + has_default_value(Key:string) : Result - + set_value(Key:string, value:KvsValue): ResultBlank - + remove_key(Key:string) : ResultBlank - + flush() : ResultBlank - + snapshot_count: Result - + snapshot_max_count() : Result - + snapshot_restore(snapshot_id:SnapshotId): ResultBlank - + get_kvs_file_name(snapshot_id:SnapshotId): Result - + get_hash_filename(snapshot_id:SnapshotId): Result -} - -' Kvs (bottom right) -class Kvs <> { - + kvs : unordered_map - + default_kvs : unordered_map - + filename_prefix : score::filesystem::path - + filesystem : score::filesystem - + parser : unique_ptr parser - + writer : unique_ptr writer - + logger : unique_ptr logger - + Storage_backend : IStorageBackEnd - __ - + reset() - + reset_key(string key):Result - + get_all_keys() : Result> - + key_exists(key:string): Result - + get_value(key:string) : Result - + get_default_value(Key:string) : Result - + has_default_value(Key:string) : Result - + set_value(Key:string, value:KvsValue): ResultBlank - + remove_key(Key:string) : ResultBlank - + flush() : ResultBlank - + snapshot_count: Result - + snapshot_max_count() : Result - + snapshot_restore(snapshot_id:SnapshotId): ResultBlank - + get_kvs_file_name(snapshot_id:SnapshotId): Result - + get_hash_filename(snapshot_id:SnapshotId): Result -} - -' Relationships -IStorageBackEnd_Mock -up-|> IStorageBackEnd : implements -JsonBackEnd -up-|> IStorageBackEnd : implements -IKvs_mock -up-|> IKvs : implements -Kvs -up-|> IKvs : implements - -' Dependencies -IKvsBuilder ..> IStorageBackEnd : uses -IKvsBuilder ..> IKvs : uses -IStorageBackEnd o-- IKvs : aggregates - -' Notes matching original design -note left of IKvsBuilder - builder will contain static map for opened instances - single tone should be applied to the builder - builder should contains cached opened KVSs -end note - -note right of IKvsBuilder - by default json backend is used but other backends - can be implemented and passed to the builder through - **backend()** method -end note - -@enduml diff --git a/Design/NewDesign.dio b/Design/NewDesign.dio deleted file mode 100644 index 07881a82..00000000 --- a/Design/NewDesign.dio +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/Design/class_diagram_cpp.puml b/docs/Design/class_diagram_cpp.puml new file mode 100644 index 00000000..b4640dcc --- /dev/null +++ b/docs/Design/class_diagram_cpp.puml @@ -0,0 +1,147 @@ +@startuml ScorePersistencyKvsDesign + +' Define color schemes matching original design +skinparam class { + BackgroundColor<> LightYellow + BorderColor<> DarkGoldenRod + BackgroundColor<> LightBlue + BorderColor<> DodgerBlue + BackgroundColor<> LightPink + BorderColor<> IndianRed +} + +class KvsBuilder <> { + - instance_id: InstanceId + - need_defaults : bool + - need_kvs : bool + - directory: string + - {static} OpenedKvs : std::unordered_map > + __ + + KvsBuilder(const InstanceId& instance_id) + + NeedDefaultsFlag(bool flag) : KvsBuilder& + + NeedKvsFlag(bool flag) : KvsBuilder& + + Dir(std::string&& dir_path) : KvsBuilder& + + Backend(IStorageBackend backend) : KvsBuilder& + + Build() : std::shared_ptr +} + +KvsBuilder -[hidden]right- IStorageBackEnd +IStorageBackEnd -[hidden]right- IKvs + +' IStorageBackEnd interface (top middle-right) +interface IStorageBackEnd <> { + + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + + LoadDefault(instance_id:InstanceId):IKvs + + Flush(instance_id:InstanceId, kvs:unordered_map + + SnapshotCount(instance_id:InstanceId):Result + + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs +} + +' IKvs interface (top right) +interface IKvs <> { + + Reset() + + ResetKey(string key):Result + + GetAllKeys() : Result> + + KeyExists(key:string): Result + + GetValue(key:string) : Result + + GetDefaultValue(Key:string) : Result + + HasDefaultValue(Key:string) : Result + + SetValue(Key:string, value:KvsValue): ResultBlank + + RemoveKey(Key:string) : ResultBlank + + Flush() : ResultBlank + + SnapshotCount: Result + + SnapshotMaxCount() : Result + + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank + + GetHashFilename(snapshot_id:SnapshotId): Result +} + +IStorageBackEnd_Mock -[hidden]right- JsonBackEnd +JsonBackEnd -[hidden]right- IKvs_mock +IKvs_mock -[hidden]right- Kvs + +' IStorageBackEnd_Mock (middle left) +class IStorageBackEnd_Mock <> { + + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs + + LoadDefault(instance_id:InstanceId) + + Flush(instance_id:InstanceId, kvs:unordered_map + + SnapshotCount(instance_id:InstanceId):Result + + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + + GetHashFilename(snapshot_id:SnapshotId): Result +} + +' JsonBackEnd (middle right) +class JsonBackEnd <> { + - Instance_id: InstanceId + - filename_prefix : score::filesystem::path + - filesystem : score::filesystem + - parser : unique_ptr parser + - writer : unique_ptr writer + __ + + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + + LoadDefault(instance_id:InstanceId) + + Flush(instance_id:InstanceId, kvs:unordered_map + + SnapshotCount(instance_id:InstanceId):Result + + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + + GetHashFilename(snapshot_id:SnapshotId): Result +} + +' IKvs_mock (bottom middle-left) +class IKvs_mock <> { + + Reset() + + ResetKey(string key):Result + + GetAllKeys() : Result> + + KeyExists(key:string): Result + + GetValue(key:string) : Result + + GetDefaultValue(Key:string) : Result + + HasDefaultValue(Key:string) : Result + + SetValue(Key:string, value:KvsValue): ResultBlank + + RemoveKey(Key:string) : ResultBlank + + Flush() : ResultBlank + + SnapshotCount: Result + + SnapshotMaxCount() : Result + + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank + + GetHashFilename(snapshot_id:SnapshotId): Result +} + +' Kvs (bottom right) +class Kvs <> { + + kvs : unordered_map + + default_kvs : unordered_map + + logger : unique_ptr logger + + Storage_backend : IStorageBackEnd + __ + + Reset() + + ResetKey(string key):Result + + GetAllKeys() : Result> + + KeyExists(key:string): Result + + GetValue(key:string) : Result + + GetDefaultValue(Key:string) : Result + + HasDefaultValue(Key:string) : Result + + SetValue(Key:string, value:KvsValue): ResultBlank + + RemoveKey(Key:string) : ResultBlank + + Flush() : ResultBlank + + SnapshotCount: Result + + SnapshotMaxCount() : Result + + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank + + GetHashFilename(snapshot_id:SnapshotId): Result +} + +' Relationships +IStorageBackEnd_Mock -up-|> IStorageBackEnd : implements +JsonBackEnd -up-|> IStorageBackEnd : implements +IKvs_mock -up-|> IKvs : implements +Kvs -up-|> IKvs : implements + +' Dependencies +KvsBuilder ..> IStorageBackEnd : uses +KvsBuilder ..> IKvs : uses +IStorageBackEnd *-- IKvs : Composes + + +note right of KvsBuilder + by default json backend is used but other backends + can be implemented and passed to the builder through + **Backend()** method +end note + +@enduml From f8831cf2cf16c7df3125477a822e23380f79c751 Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Wed, 21 Jan 2026 16:00:35 +0100 Subject: [PATCH 5/7] fix review points --- docs/Design/class_diagram_cpp.puml | 62 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/docs/Design/class_diagram_cpp.puml b/docs/Design/class_diagram_cpp.puml index b4640dcc..fd8d59ef 100644 --- a/docs/Design/class_diagram_cpp.puml +++ b/docs/Design/class_diagram_cpp.puml @@ -12,32 +12,30 @@ skinparam class { class KvsBuilder <> { - instance_id: InstanceId - - need_defaults : bool - - need_kvs : bool - - directory: string + - need_defaults : KvsDefaults + - need_kvs : KvsLoad + - backend: IStorageBackend - {static} OpenedKvs : std::unordered_map > __ + KvsBuilder(const InstanceId& instance_id) + NeedDefaultsFlag(bool flag) : KvsBuilder& + NeedKvsFlag(bool flag) : KvsBuilder& - + Dir(std::string&& dir_path) : KvsBuilder& + Backend(IStorageBackend backend) : KvsBuilder& + Build() : std::shared_ptr } -KvsBuilder -[hidden]right- IStorageBackEnd -IStorageBackEnd -[hidden]right- IKvs -' IStorageBackEnd interface (top middle-right) -interface IStorageBackEnd <> { + +interface IStorageBackend <> { + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + LoadDefault(instance_id:InstanceId):IKvs + Flush(instance_id:InstanceId, kvs:unordered_map + SnapshotCount(instance_id:InstanceId):Result + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + + SnapshotMaxCount() : Result + + SetSnapshotMaxCount(count:size_t) : ResultBlank } -' IKvs interface (top right) interface IKvs <> { + Reset() + ResetKey(string key):Result @@ -55,37 +53,44 @@ interface IKvs <> { + GetHashFilename(snapshot_id:SnapshotId): Result } -IStorageBackEnd_Mock -[hidden]right- JsonBackEnd -JsonBackEnd -[hidden]right- IKvs_mock + +IStorageBackend -[hidden]right- IKvs +IStorageBackend_Mock -[hidden]right- JsonBackend +JsonBackend -[hidden]right- IKvs_mock IKvs_mock -[hidden]right- Kvs -' IStorageBackEnd_Mock (middle left) -class IStorageBackEnd_Mock <> { - + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs - + LoadDefault(instance_id:InstanceId) + +class IStorageBackend_Mock <> { + + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + + LoadDefault(instance_id:InstanceId):IKvs + Flush(instance_id:InstanceId, kvs:unordered_map + SnapshotCount(instance_id:InstanceId):Result + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs - + GetHashFilename(snapshot_id:SnapshotId): Result + + SnapshotMaxCount() : Result + + SetSnapshotMaxCount(count:size_t) : ResultBlank } -' JsonBackEnd (middle right) -class JsonBackEnd <> { +class JsonBackend <> { - Instance_id: InstanceId - filename_prefix : score::filesystem::path - filesystem : score::filesystem - parser : unique_ptr parser - writer : unique_ptr writer + - Directory : string __ + + JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, Directory:string) + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs - + LoadDefault(instance_id:InstanceId) + + LoadDefault(instance_id:InstanceId):IKvs + Flush(instance_id:InstanceId, kvs:unordered_map + SnapshotCount(instance_id:InstanceId):Result + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + GetHashFilename(snapshot_id:SnapshotId): Result + + Dir(std::string&& dir_path) : Void + + SnapshotMaxCount() : Result + + SetSnapshotMaxCount(count:size_t) : ResultBlank + } -' IKvs_mock (bottom middle-left) class IKvs_mock <> { + Reset() + ResetKey(string key):Result @@ -103,12 +108,11 @@ class IKvs_mock <> { + GetHashFilename(snapshot_id:SnapshotId): Result } -' Kvs (bottom right) class Kvs <> { + kvs : unordered_map + default_kvs : unordered_map + logger : unique_ptr logger - + Storage_backend : IStorageBackEnd + + Storage_backend : IStorageBackend __ + Reset() + ResetKey(string key):Result @@ -127,21 +131,15 @@ class Kvs <> { } ' Relationships -IStorageBackEnd_Mock -up-|> IStorageBackEnd : implements -JsonBackEnd -up-|> IStorageBackEnd : implements +IStorageBackend_Mock -up-|> IStorageBackend : implements +JsonBackend -up-|> IStorageBackend : implements IKvs_mock -up-|> IKvs : implements Kvs -up-|> IKvs : implements ' Dependencies -KvsBuilder ..> IStorageBackEnd : uses +KvsBuilder ..> IStorageBackend : uses KvsBuilder ..> IKvs : uses -IStorageBackEnd *-- IKvs : Composes - +IStorageBackend *-- IKvs : Composes -note right of KvsBuilder - by default json backend is used but other backends - can be implemented and passed to the builder through - **Backend()** method -end note @enduml From bccdd6ace783b32dc1a087918f0f1b0f82cdbd3b Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Thu, 29 Jan 2026 08:46:31 +0100 Subject: [PATCH 6/7] fix review points --- docs/Design/class_diagram_cpp.puml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/Design/class_diagram_cpp.puml b/docs/Design/class_diagram_cpp.puml index fd8d59ef..b8128cc9 100644 --- a/docs/Design/class_diagram_cpp.puml +++ b/docs/Design/class_diagram_cpp.puml @@ -33,7 +33,6 @@ interface IStorageBackend <> { + SnapshotCount(instance_id:InstanceId):Result + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + SnapshotMaxCount() : Result - + SetSnapshotMaxCount(count:size_t) : ResultBlank } interface IKvs <> { @@ -67,7 +66,6 @@ class IStorageBackend_Mock <> { + SnapshotCount(instance_id:InstanceId):Result + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs + SnapshotMaxCount() : Result - + SetSnapshotMaxCount(count:size_t) : ResultBlank } class JsonBackend <> { @@ -77,8 +75,9 @@ class JsonBackend <> { - parser : unique_ptr parser - writer : unique_ptr writer - Directory : string + - max_snapshot_count : size_t __ - + JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, Directory:string) + + JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, Directory:string, max_snapshot_count:size_t) + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + LoadDefault(instance_id:InstanceId):IKvs + Flush(instance_id:InstanceId, kvs:unordered_map @@ -87,7 +86,6 @@ class JsonBackend <> { + GetHashFilename(snapshot_id:SnapshotId): Result + Dir(std::string&& dir_path) : Void + SnapshotMaxCount() : Result - + SetSnapshotMaxCount(count:size_t) : ResultBlank } From 868c5ca7bfade05b86a34620f4401b7bb63c853e Mon Sep 17 00:00:00 2001 From: Ahmed elsaka Date: Thu, 29 Jan 2026 14:01:48 +0100 Subject: [PATCH 7/7] fix review points --- docs/Design/class_diagram_cpp.puml | 120 ++++++++++++++--------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/docs/Design/class_diagram_cpp.puml b/docs/Design/class_diagram_cpp.puml index b8128cc9..b61ddf3f 100644 --- a/docs/Design/class_diagram_cpp.puml +++ b/docs/Design/class_diagram_cpp.puml @@ -15,12 +15,12 @@ class KvsBuilder <> { - need_defaults : KvsDefaults - need_kvs : KvsLoad - backend: IStorageBackend - - {static} OpenedKvs : std::unordered_map > + - {static} Kvs_pool : std::unordered_map > __ - + KvsBuilder(const InstanceId& instance_id) - + NeedDefaultsFlag(bool flag) : KvsBuilder& - + NeedKvsFlag(bool flag) : KvsBuilder& - + Backend(IStorageBackend backend) : KvsBuilder& + + KvsBuilder(instance_id:InstanceId) + + NeedDefaultsFlag(flag:bool) : KvsBuilder& + + NeedKvsFlag(flag:bool) : KvsBuilder& + + Backend(backend:IStorageBackend) : KvsBuilder& + Build() : std::shared_ptr } @@ -29,27 +29,27 @@ class KvsBuilder <> { interface IStorageBackend <> { + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + LoadDefault(instance_id:InstanceId):IKvs - + Flush(instance_id:InstanceId, kvs:unordered_map + + Flush(instance_id:InstanceId, kvs:unordered_map):ResultBlank + SnapshotCount(instance_id:InstanceId):Result - + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs - + SnapshotMaxCount() : Result + + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs + + SnapshotMaxCount():Result } interface IKvs <> { - + Reset() - + ResetKey(string key):Result - + GetAllKeys() : Result> - + KeyExists(key:string): Result - + GetValue(key:string) : Result - + GetDefaultValue(Key:string) : Result - + HasDefaultValue(Key:string) : Result - + SetValue(Key:string, value:KvsValue): ResultBlank - + RemoveKey(Key:string) : ResultBlank - + Flush() : ResultBlank - + SnapshotCount: Result - + SnapshotMaxCount() : Result - + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank - + GetHashFilename(snapshot_id:SnapshotId): Result + + Reset():ResultBlank + + ResetKey(key:string):ResultBlank + + GetAllKeys():Result> + + KeyExists(key:string):Result + + GetValue(key:string):Result + + GetDefaultValue(key:string):Result + + IsDefaultValue(key:string):Result + + SetValue(key:string, value:KvsValue):ResultBlank + + RemoveKey(key:string):ResultBlank + + Flush():ResultBlank + + SnapshotCount():Result + + SnapshotMaxCount():Result + + SnapshotRestore(snapshot_id:SnapshotId):ResultBlank + + GetHashFilename(snapshot_id:SnapshotId):Result } @@ -62,10 +62,10 @@ IKvs_mock -[hidden]right- Kvs class IStorageBackend_Mock <> { + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + LoadDefault(instance_id:InstanceId):IKvs - + Flush(instance_id:InstanceId, kvs:unordered_map + + Flush(instance_id:InstanceId, kvs:unordered_map):ResultBlank + SnapshotCount(instance_id:InstanceId):Result - + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs - + SnapshotMaxCount() : Result + + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs + + SnapshotMaxCount():Result } class JsonBackend <> { @@ -74,36 +74,36 @@ class JsonBackend <> { - filesystem : score::filesystem - parser : unique_ptr parser - writer : unique_ptr writer - - Directory : string + - directory : string - max_snapshot_count : size_t __ - + JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, Directory:string, max_snapshot_count:size_t) + + JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, directory:string, max_snapshot_count:size_t) + LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs + LoadDefault(instance_id:InstanceId):IKvs - + Flush(instance_id:InstanceId, kvs:unordered_map + + Flush(instance_id:InstanceId, kvs:unordered_map):ResultBlank + SnapshotCount(instance_id:InstanceId):Result - + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId) : Kvs - + GetHashFilename(snapshot_id:SnapshotId): Result - + Dir(std::string&& dir_path) : Void - + SnapshotMaxCount() : Result + + SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs + + GetHashFilename(snapshot_id:SnapshotId):Result + + Dir(dir_path:string):ResultBlank + + SnapshotMaxCount():Result } class IKvs_mock <> { - + Reset() - + ResetKey(string key):Result - + GetAllKeys() : Result> - + KeyExists(key:string): Result - + GetValue(key:string) : Result - + GetDefaultValue(Key:string) : Result - + HasDefaultValue(Key:string) : Result - + SetValue(Key:string, value:KvsValue): ResultBlank - + RemoveKey(Key:string) : ResultBlank - + Flush() : ResultBlank - + SnapshotCount: Result - + SnapshotMaxCount() : Result - + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank - + GetHashFilename(snapshot_id:SnapshotId): Result + + Reset():ResultBlank + + ResetKey(key:string):ResultBlank + + GetAllKeys():Result> + + KeyExists(key:string):Result + + GetValue(key:string):Result + + GetDefaultValue(key:string):Result + + IsDefaultValue(key:string):Result + + SetValue(key:string, value:KvsValue):ResultBlank + + RemoveKey(key:string):ResultBlank + + Flush():ResultBlank + + SnapshotCount():Result + + SnapshotMaxCount():Result + + SnapshotRestore(snapshot_id:SnapshotId):ResultBlank + + GetHashFilename(snapshot_id:SnapshotId):Result } class Kvs <> { @@ -112,20 +112,20 @@ class Kvs <> { + logger : unique_ptr logger + Storage_backend : IStorageBackend __ - + Reset() - + ResetKey(string key):Result - + GetAllKeys() : Result> - + KeyExists(key:string): Result - + GetValue(key:string) : Result - + GetDefaultValue(Key:string) : Result - + HasDefaultValue(Key:string) : Result - + SetValue(Key:string, value:KvsValue): ResultBlank - + RemoveKey(Key:string) : ResultBlank - + Flush() : ResultBlank - + SnapshotCount: Result - + SnapshotMaxCount() : Result - + SnapshotRestore(snapshot_id:SnapshotId): ResultBlank - + GetHashFilename(snapshot_id:SnapshotId): Result + + Reset():ResultBlank + + ResetKey(key:string):Result + + GetAllKeys():Result> + + KeyExists(key:string):Result + + GetValue(key:string):Result + + GetDefaultValue(key:string):Result + + IsDefaultValue(key:string):Result + + SetValue(key:string, value:KvsValue):ResultBlank + + RemoveKey(key:string):ResultBlank + + Flush():ResultBlank + + SnapshotCount():Result + + SnapshotMaxCount():Result + + SnapshotRestore(snapshot_id:SnapshotId):ResultBlank + + GetHashFilename(snapshot_id:SnapshotId):Result } ' Relationships