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.