martinzink commented on a change in pull request #1248:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1248#discussion_r791826948
##########
File path: extensions/standard-processors/processors/DefragmentText.cpp
##########
@@ -297,29 +297,34 @@ 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 base_name_attribute =
flow_file.getAttribute(textfragmentutils::BASE_NAME_ATTRIBUTE))
+ base_name_attribute_ = *base_name_attribute;
+ if (auto post_name_attribute =
flow_file.getAttribute(textfragmentutils::POST_NAME_ATTRIBUTE))
+ post_name_attribute_ = *post_name_attribute;
+}
+
+namespace {
+template <typename T, typename... Rest>
+void hash_combine(size_t& seed, const T& v, Rest... rest) {
+ std::hash<T> hasher;
+ seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
+ (hash_combine(seed, rest), ...);
+}
+}
Review comment:
you are right and I even found invalid indents in the file (e.g. line
325) which should also set off the linter.
So I checked but it is indeed running, and if I remove the comment in the
last line `} // namespace org::apache::nifi::minifi::processors` it does
complain...
I also ran the linter directly on this file, and still no errors
`python ../thirdparty/google-styleguide/cpplint.py --linelength=200
../extensions/standard-processors/processors/DefragmentText.cpp`
I even tried it with the up-to-date version from
https://github.com/cpplint/cpplint/blob/develop/cpplint.py but it still doesnt
catch this style violation
--
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]