nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #807: MINIFICPP-1228 - Resource ownership refactor + flowFile-owning processors.
Date Wed, 01 Jul 2020 10:00:35 GMT

adamdebreceni commented on a change in pull request #807:
URL: https://github.com/apache/nifi-minifi-cpp/pull/807#discussion_r448255306



##########
File path: libminifi/test/BufferReader.h
##########
@@ -0,0 +1,51 @@
+/**
+ *
+ * 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.
+ */
+
+#ifndef NIFI_MINIFI_CPP_BUFFERREADER_H
+#define NIFI_MINIFI_CPP_BUFFERREADER_H
+
+#include "FlowFileRecord.h"
+
+class BufferReader : public org::apache::nifi::minifi::InputStreamCallback {
+ public:
+  explicit BufferReader(std::vector<uint8_t>& buffer) : buffer_(buffer){}
+  template<class Input>
+  int write(Input input, std::size_t len) {
+    uint8_t tmpBuffer[4096]{};
+    int total_read = 0;
+    do {
+      auto ret = input.read(tmpBuffer, std::min(len, sizeof(tmpBuffer)));
+      if (ret == 0) break;
+      if (ret < 0) return ret;
+      len -= ret;
+      total_read += ret;
+      auto prevSize = buffer_.size();
+      buffer_.resize(prevSize + ret);
+      std::move(tmpBuffer, tmpBuffer + ret, buffer_.data() + prevSize);
+    } while (len);

Review comment:
       done




----------------------------------------------------------------
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:
users@infra.apache.org



Mime
View raw message