fgerlits commented on code in PR #1999:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1999#discussion_r2321994467


##########
extensions/standard-processors/controllers/JsonTreeReader.cpp:
##########
@@ -113,12 +113,12 @@ bool readAsArray(const std::string& content, 
core::RecordSet& record_set) {
   return true;
 }
 
-nonstd::expected<core::RecordSet, std::error_code> JsonTreeReader::read(const 
std::shared_ptr<core::FlowFile>& flow_file, core::ProcessSession& session) {
+nonstd::expected<core::RecordSet, std::error_code> 
JsonTreeReader::read(io::InputStream& input_stream) {
   core::RecordSet record_set{};
-  const auto read_result = session.read(flow_file, [&record_set](const 
std::shared_ptr<io::InputStream>& input_stream) -> int64_t {
+  const auto read_result = [&record_set](io::InputStream& input_stream) -> 
int64_t {
     std::string content;
-    content.resize(input_stream->size());
-    const auto read_ret = 
gsl::narrow<int64_t>(input_stream->read(as_writable_bytes(std::span(content))));
+    content.resize(input_stream.size());
+    const auto read_ret = 
gsl::narrow<int64_t>(input_stream.read(as_writable_bytes(std::span(content))));
     if (io::isError(read_ret)) {
       return -1;
     }

Review Comment:
   I would prefer to keep `read_ret`/`read_result` as a `size_t` and not 
convert it to and from `int64_t`:
   ```c++
     const auto read_result = [&record_set](io::InputStream& input_stream) {
       std::string content;
       content.resize(input_stream.size());
       const auto read_ret = 
input_stream.read(as_writable_bytes(std::span(content)));
       if (io::isError(read_ret)) {
         return io::STREAM_ERROR;
       }
       ...
   ```
   (sorry, github doesn't allow a diff comment here)



-- 
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]

Reply via email to