Struct burn_core::data::dataset::SqliteDataset
source · 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
Istruct. In this case, the column names in the table should match the field names of theIstruct. 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
Istruct can be serialized into a single columnitemin the table. In this case, the table should have a single column nameditemof typeBLOB. This is useful when theIstruct 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§
source§impl<I> SqliteDataset<I>
impl<I> SqliteDataset<I>
sourcepub 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§
source§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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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