MCPcopy Create free account
hub / github.com/apache/arrow / RunExchangeCounter

Method RunExchangeCounter

cpp/src/arrow/flight/test_flight_server.cc:226–256  ·  view source on GitHub ↗

Read some number of record batches from the client, send a metadata message back with the count, then echo the batches back.

Source from the content-addressed store, hash-verified

224// Read some number of record batches from the client, send a
225// metadata message back with the count, then echo the batches back.
226Status 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.

Callers

nothing calls this directly

Calls 9

FromStringFunction · 0.85
to_stringFunction · 0.85
push_backMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
OKFunction · 0.50
NextMethod · 0.45
WriteMetadataMethod · 0.45
BeginMethod · 0.45
WriteRecordBatchMethod · 0.45

Tested by

no test coverage detected