Skip to main content

Module row

Module row 

Source
Expand description

Bit-packed storage for dataset rows Storage for the rows of a crate::dataset::Dataset.

A feature is the presence or absence of an n-gram, and a sample contains only a tiny fraction of the n-grams in the feature set — a few thousand out of hundreds of thousands or a million. A row is therefore stored as the sorted list of the feature indices that are set, four bytes each, and nothing at all for the features that aren’t.

Because a row records which features are present rather than a value per feature, a dataset value other than zero or one cannot be represented, and is rejected rather than rounded.

crate::row::DataMatrix holds many rows in a handful of large blocks rather than giving each row its own allocation, which avoids allocator rounding per row and keeps rows that are scanned together close in memory. Blocks are used in preference to one flat buffer because growing a single multi-gigabyte buffer by doubling needs half again as much during the copy.

Structs§

DataMatrix
Many rows over the same set of feature columns, stored in a handful of large blocks.
DataRow
One row of features, owning its storage.
RowAccumulator
Builds one row by setting features in any order, any number of times.
RowBuilder
A row being appended to a DataMatrix.
RowSlice
A borrowed view of one row’s set features.

Functions§

bytes_per_row
Bytes a row with nonzeros set features occupies inside a DataMatrix.