Struct arrow_flight::encode::FlightDataEncoderBuilder
source · pub struct FlightDataEncoderBuilder { /* private fields */ }Expand description
Creates a Stream of FlightDatas from a
Stream of Result<RecordBatch, FlightError>.
This can be used to implement FlightService::do_get in an
Arrow Flight implementation;
Caveats
DictionaryArrays are converted to their underlying types prior to transport, due to https://github.com/apache/arrow-rs/issues/3389.
Example
use arrow_flight::encode::FlightDataEncoderBuilder;
// Get an input stream of Result<RecordBatch, FlightError>
let input_stream = futures::stream::iter(vec![Ok(record_batch)]);
// Build a stream of `Result<FlightData>` (e.g. to return for do_get)
let flight_data_stream = FlightDataEncoderBuilder::new()
.build(input_stream);
// Create a tonic `Response` that can be returned from a Flight server
let response = tonic::Response::new(flight_data_stream);Implementations§
source§impl FlightDataEncoderBuilder
impl FlightDataEncoderBuilder
pub fn new() -> Self
sourcepub fn with_max_flight_data_size(self, max_flight_data_size: usize) -> Self
pub fn with_max_flight_data_size(self, max_flight_data_size: usize) -> Self
Set the (approximate) maximum size, in bytes, of the
FlightData produced by this encoder. Defaults to 2MB.
Since there is often a maximum message size for gRPC messages
(typically around 4MB), this encoder splits up RecordBatchs
(preserving order) into multiple FlightData objects to
limit the size individual messages sent via gRPC.
The size is approximate because of the additional encoding overhead on top of the underlying data buffers themselves.
sourcepub fn with_metadata(self, app_metadata: Bytes) -> Self
pub fn with_metadata(self, app_metadata: Bytes) -> Self
Specify application specific metadata included in the
FlightData::app_metadata field of the the first Schema
message
sourcepub fn with_options(self, options: IpcWriteOptions) -> Self
pub fn with_options(self, options: IpcWriteOptions) -> Self
Set the IpcWriteOptions used to encode the RecordBatches for transport.
sourcepub fn with_schema(self, schema: SchemaRef) -> Self
pub fn with_schema(self, schema: SchemaRef) -> Self
Specify a schema for the RecordBatches being sent. If a schema
is not specified, an encoded Schema message will be sent when
the first RecordBatch, if any, is encoded. Some clients
expect a Schema message even if there is no data sent.
sourcepub fn with_flight_descriptor(
self,
descriptor: Option<FlightDescriptor>
) -> Self
pub fn with_flight_descriptor( self, descriptor: Option<FlightDescriptor> ) -> Self
Specify a flight descriptor in the first FlightData message.
sourcepub fn build<S>(self, input: S) -> FlightDataEncoderwhere
S: Stream<Item = Result<RecordBatch>> + Send + 'static,
pub fn build<S>(self, input: S) -> FlightDataEncoderwhere S: Stream<Item = Result<RecordBatch>> + Send + 'static,
Return a Stream of FlightData,
consuming self. More details on FlightDataEncoder
Trait Implementations§
source§impl Debug for FlightDataEncoderBuilder
impl Debug for FlightDataEncoderBuilder
Auto Trait Implementations§
impl RefUnwindSafe for FlightDataEncoderBuilder
impl Send for FlightDataEncoderBuilder
impl Sync for FlightDataEncoderBuilder
impl Unpin for FlightDataEncoderBuilder
impl UnwindSafe for FlightDataEncoderBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request