fgerlits commented on a change in pull request #1248:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1248#discussion_r797578093
##########
File path: extensions/standard-processors/processors/DefragmentText.cpp
##########
@@ -297,29 +297,21 @@ void DefragmentText::Buffer::store(core::ProcessSession*
session, const std::sha
}
}
-bool DefragmentText::Buffer::isCompatible(const core::FlowFile& fragment)
const {
+std::optional<size_t> DefragmentText::Buffer::getNextFragmentOffset() const {
if (empty())
- return true;
- if (buffered_flow_file_->getAttribute(textfragmentutils::BASE_NAME_ATTRIBUTE)
- != fragment.getAttribute(textfragmentutils::BASE_NAME_ATTRIBUTE)) {
- return false;
- }
- if (buffered_flow_file_->getAttribute(textfragmentutils::POST_NAME_ATTRIBUTE)
- != fragment.getAttribute(textfragmentutils::POST_NAME_ATTRIBUTE)) {
- return false;
- }
- std::string current_offset_str, append_offset_str;
- if (buffered_flow_file_->getAttribute(textfragmentutils::OFFSET_ATTRIBUTE,
current_offset_str)
- != fragment.getAttribute(textfragmentutils::OFFSET_ATTRIBUTE,
append_offset_str)) {
- return false;
- }
- if (!current_offset_str.empty() && !append_offset_str.empty()) {
- size_t current_offset = std::stoi(current_offset_str);
- size_t append_offset = std::stoi(append_offset_str);
- if (current_offset + buffered_flow_file_->getSize() != append_offset)
- return false;
- }
- return true;
+ return std::nullopt;
+ if (auto offset_attribute =
buffered_flow_file_->getAttribute(textfragmentutils::OFFSET_ATTRIBUTE))
+ return std::stoi(*offset_attribute) + buffered_flow_file_->getSize();
+ return std::nullopt;
+}
+
+DefragmentText::FragmentSource::Id::Id(const core::FlowFile& flow_file) {
+ if (auto absolute_path =
flow_file.getAttribute(core::SpecialFlowAttribute::ABSOLUTE_PATH))
+ absolute_path_ = *absolute_path;
+}
+
+size_t DefragmentText::FragmentSource::Id::hash::operator() (const Id&
fragment_id) const {
+ return std::hash<std::optional<std::string>>{}(fragment_id.absolute_path_);
}
REGISTER_RESOURCE(DefragmentText, "DefragmentText splits and merges incoming
flowfiles so cohesive messages are not split between them");
Review comment:
Sorry, just one more thing: the text of the description should be
updated here, too, so the new text is available in the manifest and C2.
--
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]