fn create_flight_data(
    schema: SchemaRef,
    results: Vec<RecordBatch>,
) -> Vec<Result<FlightData, Status>> {
    // add an initial FlightData message that sends schema
    let options = arrow::ipc::writer::IpcWriteOptions::default();
    let schema_flight_data =
        arrow_flight::utils::flight_data_from_arrow_schema(schema.as_ref(), &options);

    let mut flights: Vec<Result<FlightData, Status>> = vec![Ok(schema_flight_data)];

    let mut batches: Vec<Result<FlightData, Status>> = results
        .iter()
        .flat_map(|batch| {
            let (flight_dictionaries, flight_batch) =
                arrow_flight::utils::flight_data_from_arrow_batch(batch, &options);
            flight_dictionaries
                .into_iter()
                .chain(std::iter::once(flight_batch))
                .map(Ok)
        })
        .collect();

    // append batch vector to schema vector, so that the first message sent is the schema
    flights.append(&mut batches);

    flights
}
/// Convert a result set into flight data
Convert a result set into flight data
Convert a result set into flight data
fn create_flight_data(
    schema: SchemaRef,
    results: Vec<RecordBatch>,
) -> Vec<Result<FlightData, Status>> {
    // add an initial FlightData message that sends schema
    let options = arrow::ipc::writer::IpcWriteOptions::default();
    let schema_flight_data =
        arrow_flight::utils::flight_data_from_arrow_schema(schema.as_ref(), &options);
    let mut flights: Vec<Result<FlightData, Status>> = vec![Ok(schema_flight_data)];
    let mut batches: Vec<Result<FlightData, Status>> = results
        .iter()
        .flat_map(|batch| {
            let (flight_dictionaries, flight_batch) =
                arrow_flight::utils::flight_data_from_arrow_batch(batch, &options);
            flight_dictionaries
                .into_iter()
                .chain(std::iter::once(flight_batch))
                .map(Ok)
        })
        .collect();
    // append batch vector to schema vector, so that the first message sent is the schema
    flights.append(&mut batches);
    flights
}
fn create_flight_data ( schema : SchemaRef , results : Vec < RecordBatch > , ) -> Vec < Result < FlightData , Status > > { // add an initial FlightData message that sends schema let options = arrow :: ipc :: writer :: IpcWriteOptions :: default ( ) ; let schema_flight_data = arrow_flight :: utils :: flight_data_from_arrow_schema ( schema . as_ref ( ) , & options ) ; let mut flights : Vec < Result < FlightData , Status > > = vec ! [ Ok ( schema_flight_data ) ] ; let mut batches : Vec < Result < FlightData , Status > > = results . iter ( ) . flat_map ( | batch | { let ( flight_dictionaries , flight_batch ) = arrow_flight :: utils :: flight_data_from_arrow_batch ( batch , & options ) ; flight_dictionaries . into_iter ( ) . chain ( std :: iter :: once ( flight_batch ) ) . map ( Ok ) } ) . collect ( ) ; // append batch vector to schema vector, so that the first message sent is the schema flights . append ( & mut batches ) ; flights }
Convert a result set into flight data
Convert a result set into flight data
schema
SchemaRef
results
Vec<RecordBatch>
schema
SchemaRef
results
Vec<RecordBatch>