Skip to main content

VTable

Trait VTable 

Source
pub trait VTable:
    'static
    + Sized
    + Send
    + Sync
    + Debug {
    type Layout: 'static + Send + Sync + Clone + Debug + Deref<Target = dyn Layout> + IntoLayout;
    type Encoding: 'static + Send + Sync + Deref<Target = dyn LayoutEncoding>;
    type Metadata: SerializeMetadata + DeserializeMetadata + Debug;

    // Required methods
    fn id(encoding: &Self::Encoding) -> LayoutId;
    fn encoding(layout: &Self::Layout) -> LayoutEncodingRef;
    fn row_count(layout: &Self::Layout) -> u64;
    fn dtype(layout: &Self::Layout) -> &DType;
    fn metadata(layout: &Self::Layout) -> Self::Metadata;
    fn segment_ids(layout: &Self::Layout) -> Vec<SegmentId>;
    fn nchildren(layout: &Self::Layout) -> usize;
    fn child(layout: &Self::Layout, idx: usize) -> VortexResult<LayoutRef>;
    fn child_type(layout: &Self::Layout, idx: usize) -> LayoutChildType;
    fn new_reader(
        layout: &Self::Layout,
        name: Arc<str>,
        segment_source: Arc<dyn SegmentSource>,
        session: &VortexSession,
        ctx: &LayoutReaderContext,
    ) -> VortexResult<LayoutReaderRef>;
    fn build(
        encoding: &Self::Encoding,
        dtype: &DType,
        row_count: u64,
        metadata: &<Self::Metadata as DeserializeMetadata>::Output,
        segment_ids: Vec<SegmentId>,
        children: &dyn LayoutChildren,
        build_ctx: &LayoutBuildContext<'_>,
    ) -> VortexResult<Self::Layout>;

    // Provided method
    fn with_children(
        _layout: &mut Self::Layout,
        _children: Vec<LayoutRef>,
    ) -> VortexResult<()> { ... }
}
Expand description

Typed implementation contract for a layout encoding.

A layout vtable connects a concrete layout node type, its registered encoding object, and the metadata representation used for serialization. The object-safe Layout and LayoutEncoding APIs delegate to this trait through adapters.

Required Associated Types§

Source

type Layout: 'static + Send + Sync + Clone + Debug + Deref<Target = dyn Layout> + IntoLayout

Concrete layout node type for this encoding.

Source

type Encoding: 'static + Send + Sync + Deref<Target = dyn LayoutEncoding>

Concrete encoding object registered in the session.

Source

type Metadata: SerializeMetadata + DeserializeMetadata + Debug

Serialized layout metadata type.

Required Methods§

Source

fn id(encoding: &Self::Encoding) -> LayoutId

Returns the ID of the layout encoding.

Source

fn encoding(layout: &Self::Layout) -> LayoutEncodingRef

Returns the encoding for the layout.

Source

fn row_count(layout: &Self::Layout) -> u64

Returns the row count for the layout.

Source

fn dtype(layout: &Self::Layout) -> &DType

Returns the dtype for the layout reader.

Source

fn metadata(layout: &Self::Layout) -> Self::Metadata

Returns the metadata for the layout.

Source

fn segment_ids(layout: &Self::Layout) -> Vec<SegmentId>

Returns the segment IDs for the layout.

Source

fn nchildren(layout: &Self::Layout) -> usize

Returns the number of children for the layout.

Source

fn child(layout: &Self::Layout, idx: usize) -> VortexResult<LayoutRef>

Return the child at the given index.

Source

fn child_type(layout: &Self::Layout, idx: usize) -> LayoutChildType

Return the type of the child at the given index.

Source

fn new_reader( layout: &Self::Layout, name: Arc<str>, segment_source: Arc<dyn SegmentSource>, session: &VortexSession, ctx: &LayoutReaderContext, ) -> VortexResult<LayoutReaderRef>

Create a new reader for the layout.

Layouts with children MUST propagate ctx to descendants by passing it through Layout::new_reader (or LazyReaderChildren::new) when constructing child readers. If ctx is dropped at any link in the chain, ancestor-published values won’t reach affected descendants — a silent runtime regression for any descendant that looked up an ancestor-published value via ctx.get::<T>(). There is no compile-time check that catches this; reviewer discipline + the integration tests in vortex-layout are the only safety net.

Source

fn build( encoding: &Self::Encoding, dtype: &DType, row_count: u64, metadata: &<Self::Metadata as DeserializeMetadata>::Output, segment_ids: Vec<SegmentId>, children: &dyn LayoutChildren, build_ctx: &LayoutBuildContext<'_>, ) -> VortexResult<Self::Layout>

Construct a new Layout from deserialized parts.

Implementations should validate child count, child types, row counts, segment references, and dtype consistency for their encoding. The generic adapter checks the returned layout’s top-level dtype and row count, but encoding-specific invariants belong here.

Provided Methods§

Source

fn with_children( _layout: &mut Self::Layout, _children: Vec<LayoutRef>, ) -> VortexResult<()>

Replaces the children of the layout with the given layout references.

The count and types of children must match the layout’s requirements. This method is used for transforming layout trees by replacing child layouts.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§