szaszm commented on a change in pull request #926:
URL: https://github.com/apache/nifi-minifi-cpp/pull/926#discussion_r507726059
##########
File path: libminifi/include/utils/Id.h
##########
@@ -65,10 +67,11 @@ class Identifier {
bool operator!=(const Identifier& other) const;
bool operator==(const Identifier& other) const;
+ bool operator<(const Identifier& other) const;
bool isNil() const;
- std::string to_string() const;
+ SmallString<36> to_string() const;
Review comment:
This should get a comment explaining the reason for using
`SmallString<36>` instead of `std::string` to avoid a future refactoring
changing it back to `std::string`.
##########
File path: libminifi/include/utils/SmallString.h
##########
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <array>
+#include <ostream>
+#include <string>
+#include <utility>
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace utils {
+
+template<size_t N>
+class SmallString : public std::array<char, N + 1> {
+ public:
+ operator std::string() const { // NOLINT
Review comment:
I would make this `explicit`, or maybe even create a separate conversion
function, e.g. a `to_string` free function mimicking `std::to_string` with ADL.
I'm not 100% sure that the example is a good idea, but it seems to be useful.
The important part is to avoid implicit conversion to `std::string`.
##########
File path: libminifi/src/core/ProcessSession.cpp
##########
@@ -66,10 +66,12 @@ ProcessSession::~ProcessSession() {
}
void ProcessSession::add(const std::shared_ptr<core::FlowFile> &record) {
- if (_updatedFlowFiles.find(record->getUUIDStr()) != _updatedFlowFiles.end())
{
+ utils::Identifier uuid;
+ record->getUUID(uuid);
+ if (_updatedFlowFiles.find(uuid) != _updatedFlowFiles.end()) {
Review comment:
I would consider adding a version of `getUUID` that returns the result
as a return value. It looks like `Identifier` can hold `Nil`, so that is
something to keep in mind and something that makes returning even an `optional`
unnecessary. I don't understand why the current version returns a bool of false
in the return value instead of just returning a `Nil` UUID.
----------------------------------------------------------------
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]