adamdebreceni commented on a change in pull request #932:
URL: https://github.com/apache/nifi-minifi-cpp/pull/932#discussion_r514063453



##########
File path: 
libminifi/src/controllers/keyvalue/PersistableKeyValueStoreService.cpp
##########
@@ -29,20 +29,31 @@ 
PersistableKeyValueStoreService::PersistableKeyValueStoreService(const std::stri
 
 PersistableKeyValueStoreService::~PersistableKeyValueStoreService() = default;
 
-bool PersistableKeyValueStoreService::setImpl(const std::string& key, const 
std::string& value) {
-  return set(key, value);
+bool PersistableKeyValueStoreService::setImpl(const utils::Identifier& key, 
const std::string& value) {
+  return set(key.to_string(), value);
 }
 
-bool PersistableKeyValueStoreService::getImpl(const std::string& key, 
std::string& value) {
-  return get(key, value);
+bool PersistableKeyValueStoreService::getImpl(const utils::Identifier& key, 
std::string& value) {
+  return get(key.to_string(), value);
 }
 
-bool PersistableKeyValueStoreService::getImpl(std::unordered_map<std::string, 
std::string>& kvs) {
-  return get(kvs);
+bool PersistableKeyValueStoreService::getImpl(std::map<utils::Identifier, 
std::string>& kvs) {
+  std::unordered_map<std::string, std::string> states;
+  if (!get(states)) {
+    return false;
+  }
+  kvs.clear();
+  for (const auto& state : states) {
+    utils::optional<utils::Identifier> optional_uuid = 
utils::Identifier::parse(state.first);
+    if (optional_uuid) {
+      kvs[optional_uuid.value()] = state.second;
+    }

Review comment:
       since a `PerisistableKeyValueStoreService (PKVSS)` ISA 
`KeyValueStoreService (KVSS)` (publicly inherits) which can store arbitrary 
`std::string` keys, it is not impossible to cast a `PKVSS` to a `KVSS`, add 
some "invalid" key, and "mess up" the `PKVSS`, I would refactor this to not 
inherit from `KVSS` but contain an instance of it, for now I will add a log 
message




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to