nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #917: MINIFICPP-1380 - Batch behavior for CompressContent and MergeContent processors
Date Thu, 01 Oct 2020 11:08:26 GMT

adamdebreceni commented on a change in pull request #917:
URL: https://github.com/apache/nifi-minifi-cpp/pull/917#discussion_r498162629



##########
File path: extensions/libarchive/CompressContent.cpp
##########
@@ -81,86 +101,78 @@ void CompressContent::initialize() {
 }
 
 void CompressContent::onSchedule(core::ProcessContext *context, core::ProcessSessionFactory
*sessionFactory) {
-  std::string value;
   context->getProperty(CompressLevel.getName(), compressLevel_);
   context->getProperty(CompressMode.getName(), compressMode_);
-  context->getProperty(CompressFormat.getName(), compressFormat_);
+
+  {
+    std::string compressFormatStr;
+    context->getProperty(CompressFormat.getName(), compressFormatStr);
+    std::transform(compressFormatStr.begin(), compressFormatStr.end(), compressFormatStr.begin(),
::tolower);
+    compressFormat_ = ExtendedCompressionFormat::parse(compressFormatStr.c_str());
+  }
+
   context->getProperty(UpdateFileName.getName(), updateFileName_);
   context->getProperty(EncapsulateInTar.getName(), encapsulateInTar_);
+  context->getProperty(BatchSize.getName(), batchSize_);
 
-  logger_->log_info("Compress Content: Mode [%s] Format [%s] Level [%d] UpdateFileName
[%d] EncapsulateInTar [%d]",
-      compressMode_, compressFormat_, compressLevel_, updateFileName_, encapsulateInTar_);
-
-  // update the mimeTypeMap
-  compressionFormatMimeTypeMap_["application/gzip"] = COMPRESSION_FORMAT_GZIP;
-  compressionFormatMimeTypeMap_["application/bzip2"] = COMPRESSION_FORMAT_BZIP2;
-  compressionFormatMimeTypeMap_["application/x-bzip2"] = COMPRESSION_FORMAT_BZIP2;
-  compressionFormatMimeTypeMap_["application/x-lzma"] = COMPRESSION_FORMAT_LZMA;
-  compressionFormatMimeTypeMap_["application/x-xz"] = COMPRESSION_FORMAT_XZ_LZMA2;
-  fileExtension_[COMPRESSION_FORMAT_GZIP] = ".gz";
-  fileExtension_[COMPRESSION_FORMAT_LZMA] = ".lzma";
-  fileExtension_[COMPRESSION_FORMAT_BZIP2] = ".bz2";
-  fileExtension_[COMPRESSION_FORMAT_XZ_LZMA2] = ".xz";
+  logger_->log_info("Compress Content: Mode [%s] CompressionFormat [%s] Level [%d] UpdateFileName
[%d] EncapsulateInTar [%d]",
+      compressMode_, toString(compressFormat_), compressLevel_, updateFileName_, encapsulateInTar_);
 }
 
 void CompressContent::onTrigger(const std::shared_ptr<core::ProcessContext> &context,
const std::shared_ptr<core::ProcessSession> &session) {
+  for (size_t i = 0; i < batchSize_; ++i) {
+    if (onTriggerImpl(context, session) != TriggerResult::CONTINUE) {
+      break;
+    }
+  }
+}
+
+CompressContent::TriggerResult CompressContent::onTriggerImpl(const std::shared_ptr<core::ProcessContext>
&context, const std::shared_ptr<core::ProcessSession> &session) {
   std::shared_ptr<core::FlowFile> flowFile = session->get();
 
   if (!flowFile) {
-    return;
+    return TriggerResult::BREAK;
   }
 
   session->remove(flowFile);
 
-  std::string compressFormat = compressFormat_;
-  if (compressFormat_ == COMPRESSION_FORMAT_ATTRIBUTE) {
+  CompressionFormat::Type compressFormat;
+  if (compressFormat_ == ExtendedCompressionFormat::USE_MIME_TYPE) {
     std::string attr;
     flowFile->getAttribute(core::SpecialFlowAttribute::MIME_TYPE, attr);
     if (attr.empty()) {
       logger_->log_error("No %s attribute existed for the flow, route to failure", core::SpecialFlowAttribute::MIME_TYPE);
       session->transfer(flowFile, Failure);
-      return;
+      return TriggerResult::CONTINUE;
     }
     auto search = compressionFormatMimeTypeMap_.find(attr);
     if (search != compressionFormatMimeTypeMap_.end()) {
       compressFormat = search->second;
     } else {
-      logger_->log_info("Mime type of %s is not indicated a support format, route to success",
attr);
+      logger_->log_info("Mime type of %s is not indicated a support CompressionFormat,
route to success", attr);

Review comment:
       Ctrl+R error




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



Mime
View raw message