You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2019/11/11 09:57:35 UTC

[GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request #664: WIP: MINIFICPP-1062 - Improve FlowFile repository performance by leveraging batching

bakaid commented on a change in pull request #664: WIP: MINIFICPP-1062 - Improve FlowFile repository performance by leveraging batching
URL: https://github.com/apache/nifi-minifi-cpp/pull/664#discussion_r344622750
 
 

 ##########
 File path: extensions/rocksdb-repos/FlowFileRepository.cpp
 ##########
 @@ -32,25 +33,34 @@ namespace repository {
 
 void FlowFileRepository::flush() {
   rocksdb::WriteBatch batch;
-  std::string key;
-  std::string value;
+  uint64_t decrement_total = 0;
   rocksdb::ReadOptions options;
 
   std::vector<std::shared_ptr<FlowFileRecord>> purgeList;
 
-  uint64_t decrement_total = 0;
+  std::vector<rocksdb::Slice> keys;
+  std::vector<std::string> values;
+
   while (keys_to_delete.size_approx() > 0) {
+    std::string key;
     if (keys_to_delete.try_dequeue(key)) {
-      db_->Get(options, key, &value);
-      decrement_total += value.size();
-      std::shared_ptr<FlowFileRecord> eventRead = std::make_shared<FlowFileRecord>(shared_from_this(), content_repo_);
-      if (eventRead->DeSerialize(reinterpret_cast<const uint8_t *>(value.data()), value.size())) {
-        purgeList.push_back(eventRead);
-      }
-      logger_->log_debug("Issuing batch delete, including %s, Content path %s", eventRead->getUUIDStr(), eventRead->getContentFullPath());
-      batch.Delete(key);
+      keys.push_back(key);
     }
   }
+
+  db_->MultiGet(options, keys, &values);
+
+  for(size_t i=0; i<keys.size() && i<values.size(); ++i) {
+    decrement_total += values[i].size();
+    std::shared_ptr<FlowFileRecord> eventRead = std::make_shared<FlowFileRecord>(shared_from_this(), content_repo_);
 
 Review comment:
   MultiGet returns a vector of statuses, indicating for each individual key whether it was found. If it was not, the corresponding value `will be set to some arbitrary value (often "")` (https://github.com/facebook/rocksdb/blob/master/include/rocksdb/db.h#L430).
   While I assume that not finding a key in this case would indicate some kind of inconsistency in the database caused by us, I am unfortunately not at all sure that this can not happen. In this case we would be trying to `DeSerialize` an arbitrary string as an event, which is not too good.
   I would prefer this to be rewritten to take into account `MultiGet`'s return value and log an error if a key was not found, but do not try to do anything with the corresponding value.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services