Skip to main content

ArrayPlugin

Trait ArrayPlugin 

Source
pub trait ArrayPlugin:
    'static
    + Send
    + Sync {
    // Required methods
    fn id(&self) -> ArrayId;
    fn read_ids(&self) -> Vec<ArrayId> ⓘ;
    fn write_ids(&self) -> Vec<ArrayId> ⓘ;
    fn serialize(
        &self,
        array: &ArrayRef,
        session: &VortexSession,
    ) -> VortexResult<Option<ArraySerialization>>;
    fn deserialize(
        &self,
        parts: ArrayDeserialization<'_>,
        session: &VortexSession,
    ) -> VortexResult<ArrayRef>;

    // Provided method
    fn is_supported_encoding(&self, id: &ArrayId) -> bool { ... }
}
Expand description

Registry trait for serializing and deserializing an in-memory array representation.

A plugin writes one in-memory encoding, identified by id. It declares the wire IDs that it reads and writes separately, so it can write another encoding’s wire form without replacing that encoding’s reader. The serialization context validates that the chosen wire ID is permitted before it is written.

A plugin can retain historical read IDs after it stops writing them. A reader that predates a newer ID has no registration for it and reports it as unknown.

Required Methods§

Source

fn id(&self) -> ArrayId

Returns the ID of the in-memory encoding that this plugin writes.

Source

fn read_ids(&self) -> Vec<ArrayId> ⓘ

Returns the wire IDs that deserialize accepts, oldest to newest.

ArraySession::register makes this plugin the reader of each ID. An ID can stay in this list after the plugin stops writing it, so that old files stay readable.

Source

fn write_ids(&self) -> Vec<ArrayId> ⓘ

Returns the wire IDs that serialize may return.

An ID in this list does not have to be in read_ids. A plugin can write its arrays in the wire form of another encoding. The plugin that owns that form reads it. The node must hold the logical values of the array under the dtype of the array.

Source

fn serialize( &self, array: &ArrayRef, session: &VortexSession, ) -> VortexResult<Option<ArraySerialization>>

Serialize array to its wire representation.

This function is called only for arrays whose in-memory encoding matches id. The returned ID must be declared by write_ids. Return Ok(None) when the array cannot be serialized.

Source

fn deserialize( &self, parts: ArrayDeserialization<'_>, session: &VortexSession, ) -> VortexResult<ArrayRef>

Deserialize one recognized wire representation into the current in-memory array.

serialized_id identifies the exact representation encountered on disk. The returned array does not necessarily have to use this plugin’s in-memory ID; this supports legacy representations that are normalized into another current in-memory array. Implementations must validate the contract of that exact ID rather than accepting every form understood by the current in-memory representation under an older ID.

Provided Methods§

Source

fn is_supported_encoding(&self, id: &ArrayId) -> bool

Can this plugin emit an array with the given encoding.

By default, this is just the ID of the plugin, but can be overridden if this plugin instance supports reading/writing multiple arrays.

Trait Implementations§

Source§

impl Debug for dyn ArrayPlugin

Source§

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

Formats the value using the given formatter. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§