adamdebreceni commented on a change in pull request #917:
URL: https://github.com/apache/nifi-minifi-cpp/pull/917#discussion_r498162379
##########
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;
Review comment:
since this is the only place we return a `BREAK` we could extract the
flowFile in the `onTrigger` and call this something like `processFlowFile` and
eliminate the `TriggerResult`
----------------------------------------------------------------
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]