Appearance
CellPack
CellPack is a Rust library for matrix storage and bounded data loading. It compresses each row into an independently decodable record, packs records onto pages, and delivers requested rows through a fixed-capacity output ring. It is designed for single-cell training pipelines that need random row access, explicit column mapping, multiple outputs, and planned reuse of input data.
This manual covers the Rust crate cellpack. The Python distribution and import package are named pycellpack and have separate documentation. The examples here use the Rust core directly and require neither Python bindings nor a GPU.
Start here
Start with a matrix
Install the crate and write, reopen and select your first matrix.
Build a loading pipeline
Register data sources, map columns and deliver ordered batches.
Plan input reuse
Choose cache planning and inspect memory and execution costs.
Compose lower-level codecs
Work with record buffers, metadata and explicit ownership.
Browse the public API
Find interfaces, parameter types and ownership contracts.
See installation for setup, access sequences and loading for delivery, performance and profiling for measurement, and process functions, file format and architecture for integration.
Read a guide or look up an API?
The quickstart creates its own small matrix and checks the decoded result. Follow the guides when assembling a workflow: each explains the objects you need and the order in which to use them. Switch to the API reference when you need an exact signature, buffer size, return value or ownership rule. The reference links generated declarations to their source.
For ordered delivery, learn the identity spaces before creating sources and accesses. For custom containers or native callbacks, read the data contracts before composing lower-level interfaces.
What the library provides
| Task | Entry point |
|---|---|
Stream CSR or dense rows into a .cpk file | store::CpkWriter |
| Read ranges, gathers, and repeated rows into owned buffers | store::CpkFile, ReadSelection |
| Encode and decode chunks or records in caller buffers | scans |
| Combine matrices with an explicit shared column vocabulary | loader::DataSourceBuilder |
| Produce multiple fixed-size outputs per sequence position | loader::Loader, OutputSchema |
| Plan reuse of compressed pages and decoded input rows | opt |
| Inspect event counters and selected timing sites | loader::RunStats, prof |
A .cpk stream contains a matrix, without row labels, column labels, or annotations. The application owns names, vocabulary construction, sampling, training, and device transfers. Compression preserves value bit patterns; requesting a different output dtype introduces that conversion's precision limits.