lance_file::v2::reader

Struct ReaderProjection

Source
pub struct ReaderProjection {
    pub schema: Arc<Schema>,
    pub column_indices: Vec<u32>,
}
Expand description

Selecting columns from a lance file requires specifying both the index of the column and the data type of the column

Partly, this is because it is not strictly required that columns be read into the same type. For example, a string column may be read as a string, large_string or string_view type.

A read will only succeed if the decoder for a column is capable of decoding into the requested type.

Note that this should generally be limited to different in-memory representations of the same semantic type. An encoding could theoretically support “casting” (e.g. int to string, etc.) but there is little advantage in doing so here.

Note: in order to specify a projection the user will need some way to figure out the column indices. In the table format we do this using field IDs and keeping track of the field id->column index mapping.

If users are not using the table format then they will need to figure out some way to do this themselves.

Fields§

§schema: Arc<Schema>

The data types (schema) of the selected columns. The names of the schema are arbitrary and ignored.

§column_indices: Vec<u32>

The indices of the columns to load.

The mapping should be as follows:

  • Primitive: the index of the column in the schema
  • List: the index of the list column in the schema followed by the column indices of the children
  • FixedSizeList (of primitive): the index of the column in the schema (this case is not nested)
  • FixedSizeList (of non-primitive): not yet implemented
  • Dictionary: same as primitive
  • Struct: the index of the struct column in the schema followed by the column indices of the children

In other words, this should be a DFS listing of the desired schema.

For example, if the goal is to load:

x: int32 y: struct<z: int32, w: string> z: list

and the schema originally used to store the data was:

a: struct<x: int32> b: int64 y: struct<z: int32, c: int64, w: string> z: list

Then the column_indices should be [1, 3, 4, 6, 7, 8]

Implementations§

Source§

impl ReaderProjection

Source

pub fn from_field_ids( reader: &FileReader, schema: &Schema, field_id_to_column_index: &BTreeMap<u32, u32>, ) -> Result<Self>

Creates a projection using a mapping from field IDs to column indices

You can obtain such a mapping when the file is written using the crate::v2::writer::FileWriter::field_id_to_column_indices method.

Source

pub fn from_whole_schema(schema: &Schema, version: LanceFileVersion) -> Self

Creates a projection that reads the entire file

If the schema provided is not the schema of the entire file then the projection will be invalid and the read will fail. If the field is a struct datatype with packed set to true in the field metadata, the whole struct has one column index. To support nested packed-struct encoding, this method need to be further adjusted.

Source

pub fn from_column_names(schema: &Schema, column_names: &[&str]) -> Result<Self>

Creates a projection that reads the specified columns provided by name

The syntax for column names is the same as lance_core::datatypes::Schema::project

If the schema provided is not the schema of the entire file then the projection will be invalid and the read will fail.

Trait Implementations§

Source§

impl Clone for ReaderProjection

Source§

fn clone(&self) -> ReaderProjection

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ReaderProjection

Source§

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

Formats the value using the given formatter. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

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

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T