hunyadi-dev commented on a change in pull request #870:
URL: https://github.com/apache/nifi-minifi-cpp/pull/870#discussion_r470052761



##########
File path: extensions/libarchive/MergeContent.cpp
##########
@@ -342,6 +352,50 @@ std::shared_ptr<core::FlowFile> 
ZipMerge::merge(core::ProcessContext *context, c
   return flowFile;
 }
 
+void AttributeMerger::mergeAttributes(core::ProcessSession *session, 
std::shared_ptr<core::FlowFile> &merge_flow) {
+  for (const auto& pair : getMergedAttributes()) {
+    session->putAttribute(merge_flow, pair.first, pair.second);
+  }
+}
+
+std::map<std::string, std::string> AttributeMerger::getMergedAttributes() {
+  std::map<std::string, std::string> merged_attributes;
+  bool is_first = true;
+  for (const auto& flow : flows_) {
+    if (is_first) {
+      merged_attributes = flow->getAttributes();
+      is_first = false;
+    } else {
+      processFlowFile(flow, merged_attributes);
+    }
+  }
+  return merged_attributes;
+}
+
+void KeepOnlyCommonAttributesMerger::processFlowFile(const 
std::shared_ptr<core::FlowFile> &flow_file, std::map<std::string, std::string>& 
merged_attributes) {
+  auto flow_attributes = flow_file->getAttributes();
+  std::map<std::string, std::string> tmp_merged;
+  std::set_intersection(std::make_move_iterator(merged_attributes.begin()), 
std::make_move_iterator(merged_attributes.end()),

Review comment:
       👍 




----------------------------------------------------------------
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