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

  1. 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

source

pub fn new() -> Self

source

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.

source

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

source

pub fn with_options(self, options: IpcWriteOptions) -> Self

Set the IpcWriteOptions used to encode the RecordBatches for transport.

source

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.

source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for FlightDataEncoderBuilder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere
    V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
    S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> Allocation for Twhere
    T: RefUnwindSafe + Send + Sync,