arpadboda commented on a change in pull request #636: Minificpp-780 - Change
GenerateFlowFile to allow 0b content FlowFiles
URL: https://github.com/apache/nifi-minifi-cpp/pull/636#discussion_r320778025
##########
File path: extensions/standard-processors/processors/GenerateFlowFile.cpp
##########
@@ -98,67 +115,32 @@ void GenerateFlowFile::onTrigger(core::ProcessContext
*context, core::ProcessSes
logger_->log_trace("Unique Flow files is configured to be %i",
uniqueFlowFile);
}
- if (uniqueFlowFile) {
- char *data;
- data = new char[fileSize];
- if (!data)
+ for (uint64_t i = 0; i < batchSize; i++) {
+ // For each batch
+ std::shared_ptr<FlowFileRecord> flowFile =
std::static_pointer_cast<FlowFileRecord>(session->create());
+ if (!flowFile) {
+ logger_->log_error("Failed to create flowfile!");
return;
- uint64_t dataSize = fileSize;
- GenerateFlowFile::WriteCallback callback(data, dataSize);
- char *current = data;
- if (textData) {
- for (uint64_t i = 0; i < fileSize; i++) {
- int randValue = random();
- data[i] = TEXT_CHARS[randValue % TEXT_LEN];
- }
- } else {
- for (uint64_t i = 0; i < fileSize; i += sizeof(int)) {
- int randValue = random();
- *(reinterpret_cast<int*>(current)) = randValue;
- current += sizeof(int);
- }
}
- for (uint64_t i = 0; i < batchSize; i++) {
- // For each batch
- std::shared_ptr<FlowFileRecord> flowFile =
std::static_pointer_cast<FlowFileRecord>(session->create());
- if (!flowFile)
- return;
- if (fileSize > 0)
+ if (fileSize > 0) {
+ if (uniqueFlowFile) {
+ std::vector<char> data(fileSize);
Review comment:
Very nice idea, I love it, done!
----------------------------------------------------------------
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]
With regards,
Apache Git Services