Skip to content
API REFERENCEUsage guides →

cellpack::store::ReadOptions ​

struct

Module contract · All interfaces

At a glance ​

pub struct ReadOptions {
    pub strategy: ReadStrategy,
    pub max_gap_bytes: usize,
    pub request_cost_bytes: usize,
}

Read planning: strategy, merge threshold and the estimated cost of a read.

strategy picks range reads or a whole-region read, max_gap_bytes merges two ranges separated by at most that many bytes, and request_cost_bytes is the cost of issuing one read (in bytes of I/O it is worth), which only Auto uses.

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(())
}
OUTPUTExpected result
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: 2
Explore how row and column selection works
Explore the selectionInstant illustration in your browser
Keep source columns (click order = output order)
Output · 3 rows × 2 columns
Source rowSource col 2Source col 0
307
000
307

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 ​

strategy ​

strategy: ReadStrategy

max_gap_bytes ​

max_gap_bytes: usize

request_cost_bytes ​

request_cost_bytes: usize

Implemented traits ​

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.

Definition