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


##########
extensions/standard-processors/processors/GenerateFlowFile.cpp:
##########
@@ -58,57 +58,69 @@ void generateData(std::vector<char>& data, bool textData = 
false) {
 }
 
 void GenerateFlowFile::onSchedule(core::ProcessContext& context, 
core::ProcessSessionFactory&) {
-  if (context.getProperty(FileSize.name, fileSize_)) {
-    logger_->log_trace("File size is configured to be {}", fileSize_);
+  if (context.getProperty(FileSize.name, file_size_)) {
+    logger_->log_trace("File size is configured to be {}", file_size_);
   }
 
-  if (context.getProperty(BatchSize.name, batchSize_)) {
-    logger_->log_trace("Batch size is configured to be {}", batchSize_);
+  if (context.getProperty(BatchSize.name, batch_size_)) {
+    logger_->log_trace("Batch size is configured to be {}", batch_size_);
   }
 
-  std::string value;
-  if (context.getProperty(DataFormat.name, value)) {
-    textData_ = (value == GenerateFlowFile::DATA_FORMAT_TEXT);
+  if (auto data_format = context.getProperty(DataFormat)) {
+    textData_ = (*data_format == DATA_FORMAT_TEXT);
   }
-  if (context.getProperty(UniqueFlowFiles.name, uniqueFlowFile_)) {
-    logger_->log_trace("Unique Flow files is configured to be {}", 
uniqueFlowFile_);
+  if (context.getProperty(UniqueFlowFiles.name, unique_flow_file_)) {
+    logger_->log_trace("Unique Flow files is configured to be {}", 
unique_flow_file_);
   }
 
   std::string custom_text;
   context.getProperty(CustomText, custom_text, nullptr);
   if (!custom_text.empty()) {
-    if (textData_ && !uniqueFlowFile_) {
-      data_.assign(custom_text.begin(), custom_text.end());
+    if (textData_ && !unique_flow_file_) {
+      non_unique_data_.assign(custom_text.begin(), custom_text.end());
       return;
-    } else {
-      logger_->log_warn("Custom Text property is set, but not used!");
     }
+    logger_->log_warn("Custom Text property is set, but not used!");
   }
 
-  if (!uniqueFlowFile_) {
-    data_.resize(gsl::narrow<size_t>(fileSize_));
-    generateData(data_, textData_);
+  if (!unique_flow_file_) {
+    non_unique_data_.resize(gsl::narrow<size_t>(file_size_));
+    generateData(non_unique_data_, textData_);
+  }
+}
+
+// If the Data Format is text and if Unique FlowFiles is false, the custom 
text has to be evaluated once per batch
+void GenerateFlowFile::regenerateNonUniqueData(core::ProcessContext& context) {
+  std::string custom_text;
+  context.getProperty(CustomText, custom_text, nullptr);
+  if (!custom_text.empty()) {
+    if (textData_ && !unique_flow_file_) {
+      non_unique_data_.assign(custom_text.begin(), custom_text.end());
+      return;
+    }
+    logger_->log_warn("Custom Text property is set, but not used!");

Review Comment:
   
https://github.com/apache/nifi-minifi-cpp/pull/1706/commits/89c76dc4a13ab07d6a73385f5eda37aafc2dc31b#diff-45136a0df5089a3527479406b275001e601b5a9e02fa3a345be89e18e141b03bR96-R98
   
   I've also fixed the cut off description of Unique FlowFiles 
https://github.com/apache/nifi-minifi-cpp/pull/1706/commits/89c76dc4a13ab07d6a73385f5eda37aafc2dc31b#diff-fd2410931e7fdc4bf8b3ce23f5f7a27c7aacdf9337320626d86d806448c90b9bR1138
   
   And simplified the tests so they don't rely on PutFile (also speeds things 
up a bit because we dont have to wait for filesystem io)



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