| 84 | memory_manager_(std::move(memory_manager)) {} |
| 85 | |
| 86 | Status Init() { |
| 87 | // Peek the first message to get the descriptor. |
| 88 | internal::FlightData* data; |
| 89 | peekable_reader_->Peek(&data); |
| 90 | if (!data) { |
| 91 | return Status::IOError("Stream finished before first message sent"); |
| 92 | } |
| 93 | if (!data->descriptor) { |
| 94 | return Status::IOError("Descriptor missing on first message"); |
| 95 | } |
| 96 | descriptor_ = *data->descriptor; |
| 97 | // If there's a schema (=DoPut), also Open(). |
| 98 | if (data->metadata) { |
| 99 | return EnsureDataStarted(); |
| 100 | } |
| 101 | peekable_reader_->Next(&data); |
| 102 | return Status::OK(); |
| 103 | } |
| 104 | |
| 105 | const FlightDescriptor& descriptor() const override { return descriptor_; } |
| 106 | |