szaszm commented on code in PR #1945:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1945#discussion_r2031000661
##########
libminifi/src/core/repository/VolatileContentRepository.cpp:
##########
@@ -17,142 +16,133 @@
*/
#include "core/repository/VolatileContentRepository.h"
+#include "core/logging/LoggerFactory.h"
-#include <cstdio>
-#include <memory>
-#include <string>
-#include <thread>
+namespace org::apache::nifi::minifi::core::repository {
-#include "core/expect.h"
-#include "io/FileStream.h"
-#include "utils/StringUtils.h"
+namespace {
-using namespace std::literals::chrono_literals;
+class StringRefStream : public io::BaseStream {
+ public:
+ StringRefStream(std::shared_ptr<std::string> data, std::mutex&
data_store_mtx, std::shared_ptr<std::string>& data_store, std::atomic<size_t>&
total_size)
+ : data_(std::move(data)), data_store_mtx_(data_store_mtx),
data_store_(data_store), total_size_(total_size) {}
-namespace org::apache::nifi::minifi::core::repository {
+ [[nodiscard]] size_t size() const override {
+ return data_->size();
+ }
+
+ size_t read(std::span<std::byte> out_buffer) override {
+ auto read_size = std::min(data_->size() - read_offset_, out_buffer.size());
+ std::copy_n(reinterpret_cast<const std::byte*>(data_->data()) +
read_offset_, read_size, out_buffer.data());
Review Comment:
I think it would be better to use span operations instead of pointer
arithmetic.
```suggestion
const auto source_span =
as_bytes(std::span{*data_}.subspan(read_offset_, read_size));
std::copy_n(source_span.data(), source_span.size(), out_buffer.data());
```
##########
libminifi/test/unit/performance/VolatileRepositoryPerfTests.cpp:
##########
Review Comment:
Could you add a section to the README or somewhere else about how to run
these tests and get some numbers?
--
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]