refactor: restructure sparse bit matrix handling and add compressed columns
Release / create-release (push) Successful in 29s
Release / build-linux-x86_64 (push) Successful in 7m5s
Release / build-macos-arm64 (push) Failing after 13s

Refactor the sparse bit matrix implementation by splitting builder logic into dedicated modules and introducing a new `CompressedBitColumn` type for in-memory presence data. This change supports sparse output modes in merge operations, where presence data is compressed in RAM rather than written to disk immediately.

- Move `PersistentSparseBitMatrixBuilder` and related functions from `src/obicompactvec/src/bitmatrix/sparse.rs` to `src/obicompactvec/src/bitmatrix/sparse/builder.rs`
- Move `write_varint` from `src/obicompactvec/src/bitmatrix/sparse.rs` to `src/obicompactvec/src/bitmatrix/sparse/set_dict.rs`
- Add `src/obicompactvec/src/compressed_column.rs` with `CompressedBitColumn` for in-memory compressed presence data
- Add `src/obicompactvec/src/bitmatrix/sparse/append.rs` with `SparseBase`, `Source`, and `write_sparse_presence` functions
- Update `src/obicompactvec/src/matrix_builder.rs` and `src/obicompactvec/src/mem_builder.rs` to support detached memory columns and compression
- Add `src/obikmerge/src/partition_merge/output.rs` with `Target`, `Output`, and `Group` structs for managing merge output states
- Add `MergeSpec` struct in `src/obikmerge/src/partition_merge/mod.rs` and update `merge_partition` to use it
- Add tests in `src/obicompactvec/src/tests/sparse_append.rs` and `src/obikmerge/src/tests.rs` for sparse append and merge operations
- Update `src/obiskim/Cargo.toml` and `src/Cargo.lock` to bump `obiskim` version to 1.4.11
- Add documentation in `DevDocMD/implementation/merge.md` detailing sparse presence output behavior
This commit is contained in:
Eric Coissac committed 2026-12-02 19:52:45 +01:00
1 parent bfb9289abe
commit 93ff24c4dd
22 files changed
+1379 -344

No files matched your search

+15
View File
@@ -101,6 +101,21 @@ Only one group's source layers and destination columns are alive at a time, so t
---
## Sparse presence output: no column files
In presence mode with the sparse output (the default), pass 2 creates no
`col_*.pbiv` file for the added genomes. Each filled column is compressed in
RAM (`CompressedBitColumn`: blocks of 4096 rows, stored as varint gaps between
set bits, or as the raw bitmap when that is not larger). Once all source groups
of a partition are done, `write_sparse_presence` transposes the base columns
and the compressed ones, a window of rows at a time, and writes each layer's
sparse matrix once. `finalize` then finds the layers already packed.
All compressed columns of a partition stay in RAM until its matrices are
written (their size is logged at `debug` level); there is no disk spill. Count
mode and `--dense` still append column files and pack them afterwards. The
sections below that describe column files apply to those two paths.
## `append_genome_column`
Defined on two concrete specialisations of `Layer<D>`: