Read some number of record batches from the client, send a metadata message back with the count, then echo the batches back.
| 224 | // Read some number of record batches from the client, send a |
| 225 | // metadata message back with the count, then echo the batches back. |
| 226 | Status TestFlightServer::RunExchangeCounter(std::unique_ptr<FlightMessageReader> reader, |
| 227 | std::unique_ptr<FlightMessageWriter> writer) { |
| 228 | std::vector<std::shared_ptr<RecordBatch>> batches; |
| 229 | FlightStreamChunk chunk; |
| 230 | int chunks = 0; |
| 231 | while (true) { |
| 232 | ARROW_ASSIGN_OR_RAISE(chunk, reader->Next()); |
| 233 | if (!chunk.data && !chunk.app_metadata) { |
| 234 | break; |
| 235 | } |
| 236 | if (chunk.data) { |
| 237 | batches.push_back(chunk.data); |
| 238 | chunks++; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // Echo back the number of record batches read. |
| 243 | std::shared_ptr<Buffer> buf = Buffer::FromString(std::to_string(chunks)); |
| 244 | RETURN_NOT_OK(writer->WriteMetadata(buf)); |
| 245 | // Echo the record batches themselves. |
| 246 | if (chunks > 0) { |
| 247 | ARROW_ASSIGN_OR_RAISE(auto schema, reader->GetSchema()); |
| 248 | RETURN_NOT_OK(writer->Begin(schema)); |
| 249 | |
| 250 | for (const auto& batch : batches) { |
| 251 | RETURN_NOT_OK(writer->WriteRecordBatch(*batch)); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | return Status::OK(); |
| 256 | } |
| 257 | |
| 258 | // Read int64 batches from the client, each time sending back a |
| 259 | // batch with a running sum of columns. |
nothing calls this directly
no test coverage detected