Skip to main content

ArrowDataset

Struct ArrowDataset 

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

An in-memory dataset backed by Arrow RecordBatches.

This is the primary dataset type for alimentar. It stores data as a collection of RecordBatches and provides efficient access patterns for ML training loops.

§Example

use alimentar::{ArrowDataset, Dataset};

// Load from parquet
let dataset = ArrowDataset::from_parquet("data.parquet").unwrap();
println!("Dataset has {} rows", dataset.len());

Implementations§

Source§

impl ArrowDataset

Source

pub fn new(batches: Vec<RecordBatch>) -> Result<Self>

Creates a new ArrowDataset from a vector of RecordBatches.

§Errors

Returns an error if:

  • The batches vector is empty
  • The batches have inconsistent schemas
Source

pub fn from_batch(batch: RecordBatch) -> Result<Self>

Creates an ArrowDataset from a single RecordBatch.

§Errors

Returns an error if the batch is empty.

Source

pub fn from_parquet(path: impl AsRef<Path>) -> Result<Self>

Loads a dataset from a Parquet file.

§Errors

Returns an error if:

  • The file cannot be opened
  • The file is not valid Parquet
  • The file is empty
Source

pub fn to_parquet(&self, path: impl AsRef<Path>) -> Result<()>

Saves the dataset to a Parquet file.

§Errors

Returns an error if:

  • The file cannot be created
  • Writing fails
Source

pub fn from_ipc(path: impl AsRef<Path>) -> Result<Self>

Loads a dataset from an Arrow IPC file (Issue #2: Enhanced Data Loading)

Arrow IPC (Inter-Process Communication) format enables zero-copy data sharing. This is the native Arrow file format with optimal read performance.

§Arguments
  • path - Path to the Arrow IPC file (typically .arrow or .ipc extension)
§Errors

Returns an error if:

  • The file cannot be opened
  • The file is not valid Arrow IPC format
  • The file is empty
§Example
let dataset = ArrowDataset::from_ipc("data.arrow").unwrap();
Source

pub fn to_ipc(&self, path: impl AsRef<Path>) -> Result<()>

Saves the dataset to an Arrow IPC file (Issue #2: Enhanced Data Loading)

Creates a file in Arrow IPC format, the native Arrow format. This format provides optimal read performance for Arrow-based tools.

§Arguments
  • path - Path for the output file
§Errors

Returns an error if the file cannot be created or writing fails.

§Example
dataset.to_ipc("output.arrow").unwrap();
Source

pub fn from_ipc_stream(path: impl AsRef<Path>) -> Result<Self>

Loads a dataset from an Arrow IPC stream file (Issue #2: Enhanced Data Loading)

Arrow IPC streaming format is designed for streaming scenarios where the schema is sent first, followed by record batches. The file extension is typically .arrows.

§Arguments
  • path - Path to the Arrow IPC stream file
§Errors

Returns an error if parsing fails or the file is empty.

Source

pub fn to_ipc_stream(&self, path: impl AsRef<Path>) -> Result<()>

Saves the dataset to an Arrow IPC stream file (Issue #2: Enhanced Data Loading)

Creates a file in Arrow IPC streaming format. This format is suitable for streaming scenarios and produces slightly smaller files than the standard IPC file format.

§Arguments
  • path - Path for the output file (typically .arrows extension)
§Errors

Returns an error if the file cannot be created or writing fails.

Source

pub fn from_csv(path: impl AsRef<Path>) -> Result<Self>

Loads a dataset from a CSV file.

§Arguments
  • path - Path to the CSV file
§Errors

Returns an error if:

  • The file cannot be opened
  • The file is not valid CSV
  • The file is empty
Source

pub fn from_csv_with_options( path: impl AsRef<Path>, options: CsvOptions, ) -> Result<Self>

Loads a dataset from a CSV file with options.

§Arguments
  • path - Path to the CSV file
  • options - CSV parsing options
§Errors

Returns an error if parsing fails or the file is empty.

Source

pub fn to_csv(&self, path: impl AsRef<Path>) -> Result<()>

Saves the dataset to a CSV file.

§Errors

Returns an error if the file cannot be created or writing fails.

Source

pub fn from_json(path: impl AsRef<Path>) -> Result<Self>

Loads a dataset from a JSON Lines (JSONL) file.

Each line in the file should be a valid JSON object representing a row.

§Errors

Returns an error if the file cannot be opened or parsed.

Source

pub fn from_json_with_options( path: impl AsRef<Path>, options: JsonOptions, ) -> Result<Self>

Loads a dataset from a JSON Lines file with options.

§Errors

Returns an error if parsing fails or the file is empty.

Source

pub fn to_json(&self, path: impl AsRef<Path>) -> Result<()>

Saves the dataset to a JSON Lines (JSONL) file.

Each row is written as a single JSON object on its own line.

§Errors

Returns an error if the file cannot be created or writing fails.

Source

pub fn from_parquet_bytes(data: &[u8]) -> Result<Self>

Loads a dataset from Parquet bytes in memory.

§Errors

Returns an error if the data is not valid Parquet.

Source

pub fn to_parquet_bytes(&self) -> Result<Vec<u8>>

Converts the dataset to Parquet bytes.

§Errors

Returns an error if serialization fails.

Source

pub fn from_csv_str(data: &str) -> Result<Self>

Loads a dataset from a CSV string.

§Errors

Returns an error if the string is not valid CSV.

Source

pub fn from_json_str(data: &str) -> Result<Self>

Loads a dataset from a JSON string.

§Errors

Returns an error if the string is not valid JSON.

Source

pub fn batches(&self) -> &[RecordBatch]

Returns the underlying batches.

Source

pub fn into_batches(self) -> Vec<RecordBatch>

Consumes the dataset and returns the underlying batches.

Source

pub fn with_transform<T: Transform>(&self, transform: &T) -> Result<Self>

Applies a transform to create a new dataset.

§Errors

Returns an error if the transform fails on any batch.

Source

pub fn rows(&self) -> RowIterator<'_>

Returns an iterator over rows as single-row RecordBatches.

Trait Implementations§

Source§

impl Clone for ArrowDataset

Source§

fn clone(&self) -> ArrowDataset

Returns a duplicate 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 Dataset for ArrowDataset

Source§

fn len(&self) -> usize

Returns the total number of rows in the dataset.
Source§

fn get(&self, index: usize) -> Option<RecordBatch>

Returns a single row as a RecordBatch with one row. Read more
Source§

fn schema(&self) -> SchemaRef

Returns the schema of the dataset.
Source§

fn iter(&self) -> Box<dyn Iterator<Item = RecordBatch> + Send + '_>

Returns an iterator over all RecordBatches in the dataset.
Source§

fn num_batches(&self) -> usize

Returns the number of batches in the dataset.
Source§

fn get_batch(&self, index: usize) -> Option<&RecordBatch>

Returns a specific batch by index.
Source§

fn is_empty(&self) -> bool

Returns true if the dataset contains no rows.
Source§

impl Debug for ArrowDataset

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, 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<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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> 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