martinzink commented on code in PR #2246:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2246#discussion_r3892654926


##########
minifi_rust/minifi_native/src/api/processor_wrappers/flow_file_transform.rs:
##########
@@ -24,50 +23,68 @@ use crate::api::property::{GetControllerService, 
GetProperty};
 use crate::api::raw_processor::{MultiThreadedTrigger, SingleThreadedTrigger};
 use crate::{
     GetAttribute, LogLevel, Logger, MinifiError, MultiThreaded, 
OnTriggerResult, ProcessContext,
-    ProcessSession, Relationship, Schedule, SingleThreaded, info,
+    ProcessError, ProcessSession, Relationship, Schedule, SingleThreaded, 
impl_with_attributes,
+    info,
 };
-use std::collections::HashMap;
+
+use minifi_native::InputStream;
+use std::borrow::Cow;
+
+pub type FlowFileAttribute = (Cow<'static, str>, Cow<'static, str>);
 
 #[derive(Debug)]
 pub struct TransformedFlowFile<'a> {
-    target_relationship_name: &'static str,
+    target_relationship_name: Cow<'static, str>,
     new_content: Option<Content<'a>>, // If None, the content doesn't change
-    attributes_to_add: HashMap<String, String>,
+    attributes_to_add: Vec<FlowFileAttribute>,
 }
 
 impl<'a> TransformedFlowFile<'a> {
     pub fn route_without_changes(target_relationship: &Relationship) -> Self {
+        
Self::route_without_changes_by_name(Cow::Borrowed(target_relationship.name))
+    }
+
+    pub fn route_without_changes_by_name(relationship: Cow<'static, str>) -> 
Self {
         Self {
-            target_relationship_name: target_relationship.name,
+            target_relationship_name: relationship,
             new_content: None,
-            attributes_to_add: HashMap::new(),
+            attributes_to_add: Vec::new(),
         }
     }
 
-    pub fn new(
-        target_relationship: &Relationship,
-        new_content: Option<Vec<u8>>,
-        attributes_to_add: HashMap<String, String>,
-    ) -> Self {
+    pub fn new(target_relationship: &Relationship, new_content: 
Option<Vec<u8>>) -> Self {
         Self {
-            target_relationship_name: target_relationship.name,
+            target_relationship_name: Cow::Borrowed(target_relationship.name),
             new_content: new_content.map(Content::Buffer),
-            attributes_to_add,
+            attributes_to_add: Vec::new(),
         }
     }
 
+    #[must_use]
+    pub fn with_content(mut self, content: Vec<u8>) -> Self {

Review Comment:
   yeah, so we can chain this (similar to the with_attribute(s) functions) ive 
added some unit tests here [tests for 
with_attribute(s)](https://github.com/apache/nifi-minifi-cpp/pull/2246/commits/cd5732cd7a2085f99252b5e11699b9b5cecfa627)



##########
minifi_rust/minifi_native/src/api/processor_wrappers/utils/with_attributes.rs:
##########


Review Comment:
   good idea, ive added tests, [tests for 
with_attribute(s)](https://github.com/apache/nifi-minifi-cpp/pull/2246/commits/cd5732cd7a2085f99252b5e11699b9b5cecfa627)



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

To unsubscribe, e-mail: [email protected]

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

Reply via email to