refactor: modernize iteration patterns and add sparse matrix support
Update bitvector and matrix operations to use iterator-based loops, `as_chunks`, and direct references instead of index-based access. Introduce `Sparse` variants for persistent bit and integer matrices, including logic to detect and migrate stale columnar formats. Add `is_empty` methods to various data structures and implement `Default` for `PartitionRunner`. - Add `Sparse` variants to `PersistentBitMatrix` and `PersistentIntMatrix` enums, with auto-detection logic to migrate stale columnar files (`matrix.pbmx`, `matrix.pcmx`) to the new sparse format by rebuilding from columnar data. - Refactor bit manipulation functions (`or_where`, `and_where`, `xor_where`) in `bitvec.rs` to use direct references (`*word`) instead of indexed access (`words[wi]`), and update remainder handling in `set_last_word`. - Update `read_int_window` and `read_bit_window` in sparse matrix modules to use `as_chunks::<8>()` for efficient byte-to-u64 conversion, replacing `chunks_exact` and `try_into`. - Modify `inc_predicate_fast` in `builder.rs` to iterate over `primary.iter_mut().zip(col.primary_bytes())` for incrementing values, avoiding index-based access. - Add `is_empty` methods to `Evidence`, `FamilyScalarAnnex`, and `RopeCursor` to check for zero-length or empty states. - Implement `Default` for `PartitionRunner` in `obisys`, delegating to `Self::new()`. - Refactor multiple test functions across `obicompactvec`, `obikmer`, `obikphylo`, `obikquery`, and `obiskio` to use `enumerate()`, `iter()`, and `take()` instead of index-based loops, improving idiomatic Rust patterns. - Update `merge_partition` in `obikmerge` to use `clamp(4, 16)` for worker count calculation instead of chained `min`/`max` calls. - Add `#[allow(clippy::large_enum_variant)]` to `KmerLayer` and `#[allow(clippy::too_many_arguments)]` to subsample functions, with updated documentation clarifying layer types and argument independence. - Refactor `write_sankoff_phyg` and `write_sample_stats` in `obikmer` to use iterator methods (`take`, `copied`, `enumerate`) for processing matrices and labels. - Update `build_emax` and `build_log_nwords` in `obikentropy` to use `enumerate` and direct cell references, and add `WS_MAX` constant and comments in `table.rs`. - Modify `push_warmup_increments` in `obikentropy` to accept a fixed-size array `[u64; 6]` instead of individual arguments, updating `push` accordingly. - Refactor `resolve_partition_batch` and `query_partition_with` in `obikphylo` and `obikquery` to iterate over `by_layer.iter_mut().enumerate().take(n_layer)`, using direct bucket references. - Update `ascii_histogram` in `obikmer` to use `checked_div` and `unwrap_or(0)` for bar length calculation, replacing conditional checks. - Refactor `from_ascii` in `obikseq` to iterate over references `&base in &ascii[..k]` instead of indices, and update related tests to use `#[test]` attributes and new type aliases.
This commit is contained in:
1 parent
f022d83394
commit
a71e59d6f0
51 files changed
+673
-642
No files matched your search
@@ -93,6 +93,11 @@ pub trait RopeCursor<'a> {
|
||||
self.rope().len().saturating_sub(self.state().offset.get())
|
||||
}
|
||||
|
||||
/// `true` if no byte is visible through this cursor (`len() == 0`).
|
||||
fn is_empty(&self) -> bool {
|
||||
self.len() == 0
|
||||
}
|
||||
|
||||
/// Reset the cursor to its initial state (positioned before the first
|
||||
/// byte of its local view). Equivalent to `seek(0, Absolute)` on a
|
||||
/// fresh cursor, but works even when `current` is `None`.
|
||||
|
||||
Reference in new issue
Block a user