Appearance
cellpack::store::RowSelection
Module contract · All interfaces
At a glance
Cells to read: a contiguous range, or a gather in output order whose ids may repeat.
Range uses a half-open interval of file-row IDs. List gathers exactly the requested order and permits repeated rows; it does not sort or deduplicate.
Try it
FIXED EXAMPLE RUST / CPU
Gather rows and map columns
Rows [3, 0, 3] preserve order and repetition. The source → output map keeps source column 2 first and column 0 second.
mod common;
use std::error::Error;
use cellpack::scans::UNMAPPED;
use cellpack::store::{CpkFile, ReadOptions, ReadWorkspace, RowSelection};
fn main() -> Result<(), Box<dyn Error>> {
let file = CpkFile::open(common::fixture()?)?;
let rows = [3, 0, 3];
// Each entry maps a source column to its output position.
let map = [1, UNMAPPED, 0, UNMAPPED];
let selection = file.prepare_selection(
RowSelection::List(&rows), Some(&map), 2, ReadOptions::default(),
)?;
let spec = selection.spec();
let mut workspace = ReadWorkspace::default();
let mut out = vec![0.0f64; spec.dense_len()?];
selection.read_dense_into(&mut out, &mut workspace, 1)?;
let mut offsets = vec![0u64; spec.rows + 1];
let mut columns = vec![0u32; spec.nnz];
let mut values = vec![0.0f64; spec.nnz];
let nnz = selection.read_csr_into(
&mut offsets, &mut columns, &mut values, &mut workspace, 1,
)?;
println!("rows: {rows:?}");
println!("output: {out:?}");
println!("CSR offsets: {offsets:?}");
println!("actual nnz: {nnz}");
Ok(())
}
rows: [3, 0, 3]
output: [0.0, 7.0, 0.0, 0.0, 0.0, 7.0]
CSR offsets: [0, 1, 1, 2]
actual nnz: 2Explore how row and column selection works
Explore the selectionInstant illustration in your browser
| Source row | Source col 2 | Source col 0 |
|---|---|---|
| 3 | 0 | 7 |
| 0 | 0 | 0 |
| 3 | 0 | 7 |
source → output: [1, UNMAPPED, 0, UNMAPPED]
This illustration runs in the browser. The fixed server example always uses rows [3, 0, 3].
Fields and variants
Range
List
List(&'a [u64])Implemented traits
impl<'a> Clone for RowSelection<'a>impl<'a> Debug for RowSelection<'a>Contract reference
See the module reference for semantic input/output rules, units, allocation, mutation, failure behavior, and lifetime requirements. Declarations and documented members are synchronized from the crate source.