Alex-PLACET commented on code in PR #50407:
URL: https://github.com/apache/arrow/pull/50407#discussion_r4323798038


##########
cpp/src/arrow/flight/transport_server_internal.h:
##########
@@ -0,0 +1,304 @@
+// 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 <atomic>
+#include <chrono>
+#include <memory>
+#include <thread>
+#include <utility>
+#include <vector>
+
+#include "arrow/flight/platform.h"
+#include "arrow/flight/server.h"
+#include "arrow/flight/visibility.h"
+#include "arrow/result.h"
+#include "arrow/status.h"
+#include "arrow/util/io_util.h"
+#include "arrow/util/logging.h"
+#include "arrow/util/uri.h"
+
+namespace arrow::flight::internal {
+
+class ServerDataStream;
+class PeekableFlightDataReader;
+
+/// \brief Adapt TransportDataStream to the FlightMessageReader
+///   interface for DoPut.
+class TransportMessageReader final : public FlightMessageReader {
+ public:
+  TransportMessageReader(ServerDataStream* stream,
+                         std::shared_ptr<MemoryManager> memory_manager);
+
+  Status Init();
+
+  const FlightDescriptor& descriptor() const override;
+
+  arrow::Result<std::shared_ptr<Schema>> GetSchema() override;
+
+  arrow::Result<FlightStreamChunk> Next() override;
+
+  ipc::ReadStats stats() const override;
+
+ private:
+  /// Ensure we are set up to read data.
+  Status EnsureDataStarted();
+
+  FlightDescriptor descriptor_;
+  std::shared_ptr<PeekableFlightDataReader> peekable_reader_;
+  std::shared_ptr<MemoryManager> memory_manager_;
+  std::shared_ptr<ipc::RecordBatchStreamReader> batch_reader_;
+  std::shared_ptr<Buffer> app_metadata_;
+};
+
+/// \brief A writer for IPC payloads to a ServerDataStream.
+class TransportMessageWriter final : public FlightMessageWriter {
+ public:
+  explicit TransportMessageWriter(ServerDataStream* stream);
+
+  Status Begin(const std::shared_ptr<Schema>& schema,
+               const ipc::IpcWriteOptions& options) override;
+
+  Status WriteRecordBatch(const RecordBatch& batch) override;
+
+  Status WriteMetadata(std::shared_ptr<Buffer> app_metadata) override;
+
+  Status WriteWithMetadata(const RecordBatch& batch,
+                           std::shared_ptr<Buffer> app_metadata) override;
+
+  Status Close() override;
+
+  ipc::WriteStats stats() const override;
+
+ private:
+  Status CheckStarted();
+
+  ServerDataStream* stream_;
+  std::unique_ptr<ipc::RecordBatchWriter> batch_writer_;
+  std::shared_ptr<Buffer> app_metadata_;
+  ::arrow::ipc::IpcWriteOptions ipc_options_;
+};
+
+/// \brief A writer for application-defined metadata to a ServerDataStream.
+class TransportMetadataWriter final : public FlightMetadataWriter {
+ public:
+  explicit TransportMetadataWriter(ServerDataStream* stream);
+
+  Status WriteMetadata(const Buffer& buffer) override;
+
+ private:
+  ServerDataStream* stream_;
+};
+
+/// \brief Base class for server transport implementations.
+///
+/// Provides shared helpers for constructing message readers/writers from a
+/// transport-level data stream, and for writing a FlightDataStream to a
+/// transport-level stream (used by DoGet/DoExchange).
+class ARROW_FLIGHT_EXPORT ServerTransportBase {

Review Comment:
   Base class deleted, `WriteDataStream` is a free function now



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