arpadboda commented on a change in pull request #1054:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1054#discussion_r618652706



##########
File path: extensions/standard-processors/processors/GenerateFlowFile.cpp
##########
@@ -61,6 +62,13 @@ core::Property GenerateFlowFile::UniqueFlowFiles(
     core::PropertyBuilder::createProperty("Unique 
FlowFiles")->withDescription("If true, each FlowFile that is generated will be 
unique. If false, a random value will be generated and all FlowFiles")
         ->isRequired(false)->withDefaultValue<bool>(true)->build());
 
+core::Property GenerateFlowFile::CustomText(
+    core::PropertyBuilder::createProperty("Custom Text")
+      ->withDescription("If Data Format is text and if Unique FlowFiles is 
false, then this custom text will be used as content of the generated FlowFiles 
and the File Size will be ignored. "
+                        "Finally, if Expression Language is used, evaluation 
will be performed only once per batch of generated FlowFiles")
+      ->supportsExpressionLanguage(true)

Review comment:
       +1

##########
File path: extensions/standard-processors/processors/GenerateFlowFile.cpp
##########
@@ -110,6 +119,15 @@ void GenerateFlowFile::onSchedule(const 
std::shared_ptr<core::ProcessContext> &c
     logger_->log_trace("Unique Flow files is configured to be %i", 
uniqueFlowFile_);
   }
 
+  if (textData_ && !uniqueFlowFile_) {
+    std::string custom_text;
+    context->getProperty(CustomText, custom_text, nullptr);
+    if (!custom_text.empty()) {
+      std::copy(custom_text.begin(), custom_text.end(), 
std::back_inserter(data_));

Review comment:
       ```
   data_.assign(custom_text.begin(), custom_text.end());
   ```
   
   For me this feels like a bit shorter and more efficient, but I may missed 
some constraints here when using this. 




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


Reply via email to