Skip to main content

RelationFileExt

Trait RelationFileExt 

Source
pub trait RelationFileExt: Relation {
    // Required methods
    fn from_parquet<P: AsRef<Path>>(filepath: P) -> Result<Self, RelationError>
       where Self: Sized;
    fn from_csv<P: AsRef<Path>>(filepath: P) -> Result<Self, RelationError>
       where Self: Sized;
}
Expand description

Loads a Relation from a CSV or Parquet file.

Defined as an extension trait (with a blanket impl over every Relation) so file-loading is added without bloating the core trait or requiring each concrete data structure to reimplement it. Anything that implements Relation automatically gains from_csv and from_parquet.

Required Methods§

Source

fn from_parquet<P: AsRef<Path>>(filepath: P) -> Result<Self, RelationError>
where Self: Sized,

Creates a new relation from a Parquet file.

Column names are extracted from the Parquet schema and the relation name is taken from the file stem. All columns must be Int64 and every value must be non-negative so it fits in usize.

§Errors

Returns a RelationError if any of the following occur:

Source

fn from_csv<P: AsRef<Path>>(filepath: P) -> Result<Self, RelationError>
where Self: Sized,

Creates a new relation from a CSV file.

The first row is treated as a header providing attribute names; each subsequent row is one tuple. Every field must parse as a usize. The relation name is taken from the file stem.

§Errors

Returns a RelationError if any of the following occur:

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<R> RelationFileExt for R
where R: Relation,

Blanket implementation of RelationFileExt for any type that implements Relation.