pub struct Handler { /* private fields */ }Expand description
Converts between serialized protobuf messages and Arrow record batches for a single message type, exchanging Arrow data through the C Data Interface.
Descriptors are passed as serialized bytes and Arrow data as
ArrowArray/ArrowSchema pairs, so this type works with any arrow
version on the caller’s side.
Implementations§
Source§impl Handler
impl Handler
Sourcepub fn try_new(
file_descriptor_set: &[u8],
message_name: &str,
config: PtarsConfig,
) -> Result<Self, PtarsError>
pub fn try_new( file_descriptor_set: &[u8], message_name: &str, config: PtarsConfig, ) -> Result<Self, PtarsError>
Create a handler from a serialized google.protobuf.FileDescriptorSet
(e.g. the output of protoc --descriptor_set_out) and a fully
qualified message name.
Sourcepub fn try_new_from_file_descriptor_protos(
file_descriptor_protos: &[&[u8]],
message_name: &str,
config: PtarsConfig,
) -> Result<Self, PtarsError>
pub fn try_new_from_file_descriptor_protos( file_descriptor_protos: &[&[u8]], message_name: &str, config: PtarsConfig, ) -> Result<Self, PtarsError>
Create a handler from serialized google.protobuf.FileDescriptorProto
messages and a fully qualified message name.
Files must be ordered so that imports appear before the files that depend on them.
Sourcepub fn arrow_schema(&self) -> Result<ArrowSchema, PtarsError>
pub fn arrow_schema(&self) -> Result<ArrowSchema, PtarsError>
The Arrow schema of the record batches produced by Handler::decode,
exported as a C Data Interface struct-typed schema.
Sourcepub fn decode(
&self,
array: ArrowArray,
schema: &ArrowSchema,
) -> Result<(ArrowArray, ArrowSchema), PtarsError>
pub fn decode( &self, array: ArrowArray, schema: &ArrowSchema, ) -> Result<(ArrowArray, ArrowSchema), PtarsError>
Decode an Arrow binary array of serialized protobuf messages into a record batch, returned as a struct-typed array over the C Data Interface.
The input must be a Binary, LargeBinary or BinaryView array where
each value is one serialized message; nulls decode to null rows.
Sourcepub fn decode_bytes(
&self,
messages: &[Option<&[u8]>],
) -> Result<(ArrowArray, ArrowSchema), PtarsError>
pub fn decode_bytes( &self, messages: &[Option<&[u8]>], ) -> Result<(ArrowArray, ArrowSchema), PtarsError>
Decode serialized protobuf messages into a record batch, returned as a struct-typed array over the C Data Interface.
Convenience over Handler::decode for callers that do not already
hold the messages in an Arrow array; None decodes to a null row.
Sourcepub fn encode(
&self,
array: ArrowArray,
schema: &ArrowSchema,
) -> Result<(ArrowArray, ArrowSchema), PtarsError>
pub fn encode( &self, array: ArrowArray, schema: &ArrowSchema, ) -> Result<(ArrowArray, ArrowSchema), PtarsError>
Encode a record batch (passed as a struct-typed array over the C Data Interface) into a Binary array of serialized protobuf messages, returned over the C Data Interface.