lidavidm commented on a change in pull request #12465:
URL: https://github.com/apache/arrow/pull/12465#discussion_r813974385



##########
File path: cpp/src/arrow/flight/transport_server_impl.cc
##########
@@ -0,0 +1,327 @@
+// 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.
+
+#include "arrow/flight/transport_impl.h"
+
+#include <unordered_map>
+
+#include "arrow/buffer.h"
+#include "arrow/flight/serialization_internal.h"
+#include "arrow/flight/server.h"
+#include "arrow/flight/types.h"
+#include "arrow/ipc/reader.h"
+#include "arrow/result.h"
+#include "arrow/status.h"
+
+namespace arrow {
+namespace flight {
+namespace internal {
+
+namespace {
+class TransportIpcMessageReader : public ipc::MessageReader {
+ public:
+  explicit TransportIpcMessageReader(
+      std::shared_ptr<internal::PeekableFlightDataReader> peekable_reader,
+      std::shared_ptr<MemoryManager> memory_manager,
+      std::shared_ptr<Buffer>* app_metadata)
+      : peekable_reader_(peekable_reader),
+        memory_manager_(std::move(memory_manager)),
+        app_metadata_(app_metadata) {}
+
+  ::arrow::Result<std::unique_ptr<ipc::Message>> ReadNextMessage() override {
+    if (stream_finished_) {
+      return nullptr;
+    }
+    internal::FlightData* data;
+    peekable_reader_->Next(&data);
+    if (!data) {
+      stream_finished_ = true;
+      if (first_message_) {

Review comment:
       Ah, basically, this can only happen on the first message on DoPut since 
in all other cases, we peek at the stream before sending it to the IPC message 
reader - so it will never not have data. So in general if we were called and we 
don't get any data here, then it's an error.




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