raulcd commented on code in PR #47115: URL: https://github.com/apache/arrow/pull/47115#discussion_r2224854056
########## cpp/src/arrow/flight/server.cc: ########## @@ -275,78 +277,137 @@ Status FlightServerBase::GetSchema(const ServerCallContext& context, class RecordBatchStream::RecordBatchStreamImpl { public: - // Stages of the stream when producing payloads - enum class Stage { - NEW, // The stream has been created, but Next has not been called yet - DICTIONARY, // Dictionaries have been collected, and are being sent - RECORD_BATCH // Initial have been sent - }; - RecordBatchStreamImpl(const std::shared_ptr<RecordBatchReader>& reader, const ipc::IpcWriteOptions& options) - : reader_(reader), mapper_(*reader_->schema()), ipc_options_(options) {} + : reader_(reader), options_(options) {} std::shared_ptr<Schema> schema() { return reader_->schema(); } Status GetSchemaPayload(FlightPayload* payload) { - return ipc::GetSchemaPayload(*reader_->schema(), ipc_options_, mapper_, - &payload->ipc_message); + if (!writer_) { + // Create the IPC writer on first call + auto payload_writer = + std::make_unique<ServerRecordBatchPayloadWriter>(&payload_list_); + auto writer_result = ipc::internal::OpenRecordBatchWriter( + std::move(payload_writer), reader_->schema(), options_); + + if (!writer_result.ok()) { + return writer_result.status(); + } + writer_ = std::move(writer_result).ValueOrDie(); Review Comment: Because I am still learning C++ :) -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org