Skip to main content

Layout

Struct Layout 

Source
pub struct Layout { /* private fields */ }
Expand description

A facet’s field layout: names in wire order, with the type each binds as.

Learned once. The names are the metadata’s own, in the order the records carry them, and that order is the position a binder addresses fields by for the rest of the run.

Obtain one with Layout::resolve, which prefers what the dataset declares over what one record happens to show.

Implementations§

Source§

impl Layout

Source

pub fn resolve<V>(view: &V) -> Result<Layout, BindError>
where V: TestDataView + ?Sized,

The layout of a profile’s metadata_content records, from the strongest source the dataset offers.

In order: the metadata_layout facet, the content slab’s layout namespace, its schema namespace, and last the first record. source says which was used, and unproven names the fields whose type the source could not establish.

A declared layout is then checked against the facet’s first record: the same field names in the same order, and no value of a type its field does not have. A layout that does not describe the records it is published beside is refused here, by name, rather than discovered as wrong values on a later cycle.

Costs the tail of each container consulted and one page of the content facet; nothing is downloaded whole.

use vectordata::binding::{BindType, Layout, LayoutSource};
use vectordata::formats::mnode::{MNode, MValue, TypeTag};
// The first record has no `note`; the layout says it is text.
let mut first = MNode::new();
first.insert("id".into(), MValue::Int(1));
first.insert("note".into(), MValue::Null);
write("metadata_content.slab", &[first.to_bytes()]);
let mut declared = MNode::new();
declared.insert("id".into(), MValue::default_for(TypeTag::Int));
declared.insert("note".into(), MValue::default_for(TypeTag::Text));
write("metadata_layout.slab", &[declared.to_bytes()]);
std::fs::write(dir.join("dataset.yaml"),
    "name: d\nprofiles:\n  default:\n    metadata_content: metadata_content.slab\n    metadata_layout: metadata_layout.slab\n")?;

let view = vectordata::TestDataGroup::load(dir.to_str().unwrap())?.profile("default").unwrap();
let layout = Layout::resolve(&*view)?;
assert_eq!(layout.source(), LayoutSource::LayoutFacet);
assert_eq!(layout.types(), [BindType::Int64, BindType::Text]);
assert!(layout.unproven().is_empty());
Source

pub fn from_exemplar( record: &[u8], source: LayoutSource, ) -> Result<Layout, BindError>

A layout from a layout record: one record in which every field is present at its type’s default value — a record’s fingerprint — as the metadata_layout facet and the layout namespace hold it. Any record of the facet serves: it is fingerprinted here.

Source

pub fn from_schema(schema: &MetadataSchema) -> Result<Layout, BindError>

A layout from a metadata schema descriptor: the column names and type names a converter recorded.

A type name no tag has is refused naming the field, since a descriptor this build cannot read must not become a layout with a guessed type in it.

Source

pub fn discover(facet: &RecordFacet) -> Result<Layout, BindError>

Learn a facet’s layout from its first record.

The weakest source, and the one resolve falls back to when a dataset declares nothing: a field that is null in the first record gets no type, a field that record lacks is not in the layout at all, and an empty container gets no element type. unproven names the fields affected.

Source

pub fn source(&self) -> LayoutSource

Where this layout was learned from.

Source

pub fn names(&self) -> &[String]

Field names, in wire order.

Source

pub fn types(&self) -> &[BindType]

What each field binds as, by position.

Source

pub fn exemplar(&self) -> ANode

The layout as a record: every field present, in order, at its type’s default value — the layout record the dataset publishes, or the one this layout was learned as.

What a rendering codec is applied to — encoded with anode::encode — to produce the text one record stands for (a column list, a values tuple of markers) before any record is read. A container whose element type is not stated appears empty.

Source

pub fn nullability(&self) -> &[Nullability]

Whether each field may hold a null, by position, as the dataset declares it. See Nullability.

Source

pub fn position_of(&self, field: &str) -> Option<usize>

The position of a named field.

Source

pub fn unproven(&self) -> Vec<&str>

The fields whose bind type this layout does not establish, by name: a container with no element type, and — in a layout inferred from a record — a field that was null there.

A declared layout may type a field as null on purpose, for a column that holds nothing; that is a statement, not a gap, and is not listed. Empty means every parameter’s type is known before the first record is bound.

Source

pub fn check_record(&self, record: &[u8]) -> Result<(), BindError>

Check that record has this layout: the same field names in the same order, each value of a type its field admits.

A null value agrees with any field not declared never null, and a container whose element type is open on either side agrees with a container of the same kind.

Trait Implementations§

Source§

impl Clone for Layout

Source§

fn clone(&self) -> Layout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Layout

Source§

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

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

impl PartialEq for Layout

Source§

fn eq(&self, other: &Layout) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Layout

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

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 T
where U: From<T>,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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