Struct burn::data::dataset::SqliteDataset
pub struct SqliteDataset<I> { /* private fields */ }
Expand description
This struct represents a dataset where all items are stored in an SQLite database. Each instance of this struct corresponds to a specific table within the SQLite database, and allows for interaction with the data stored in the table in a structured and typed manner.
The SQLite database must contain a table with the same name as the split
field. This table should
have a primary key column named row_id
, which is used to index the rows in the table. The row_id
should start at 1, while the corresponding dataset index
should start at 0, i.e., row_id
= index
+ 1.
Table columns can be represented in two ways:
- The table can have a column for each field in the
I
struct. In this case, the column names in the table should match the field names of theI
struct. The field names can be a subset of column names and can be in any order.
For the supported field types, refer to:
- The fields in the
I
struct can be serialized into a single columnitem
in the table. In this case, the table should have a single column nameditem
of typeBLOB
. This is useful when theI
struct contains complex fields that cannot be mapped to a SQLite type, such as nested structs, vectors, etc. The serialization is done using MessagePack.
Note: The code automatically figures out which of the above two cases is applicable, and uses the appropriate method to read the data from the table.
Implementations§
§impl<I> SqliteDataset<I>
impl<I> SqliteDataset<I>
pub fn from_db_file<P>(
db_file: P,
split: &str,
) -> Result<SqliteDataset<I>, SqliteDatasetError>
pub fn from_db_file<P>( db_file: P, split: &str, ) -> Result<SqliteDataset<I>, SqliteDatasetError>
Initializes a SqliteDataset
from a SQLite database file and a split name.
Trait Implementations§
§impl<I> Dataset<I> for SqliteDataset<I>
impl<I> Dataset<I> for SqliteDataset<I>
Auto Trait Implementations§
impl<I> Freeze for SqliteDataset<I>
impl<I> !RefUnwindSafe for SqliteDataset<I>
impl<I> Send for SqliteDataset<I>where
I: Send,
impl<I> Sync for SqliteDataset<I>where
I: Sync,
impl<I> Unpin for SqliteDataset<I>where
I: Unpin,
impl<I> !UnwindSafe for SqliteDataset<I>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T> Windows<I> for Twhere
T: Dataset<I>,
impl<I, T> Windows<I> for Twhere
T: Dataset<I>,
§fn windows(&self, size: usize) -> WindowsIterator<'_, I> ⓘ
fn windows(&self, size: usize) -> WindowsIterator<'_, I> ⓘ
Is empty if the Dataset
is shorter than size
.
§Panics
Panics if size
is 0.
§Examples
use crate::burn_dataset::{
transform::{Windows, WindowsDataset},
Dataset, InMemDataset,
};
let items = [1, 2, 3, 4].to_vec();
let dataset = InMemDataset::new(items.clone());
for window in dataset.windows(2) {
// do sth with window
}