Rename PersistentCompactIntMatrix to PersistentIntMatrix
Update all matrix type references, imports, and instantiations across the codebase to use the new PersistentIntMatrix name. The change also includes standardizing code formatting, such as multi-line statements and import ordering, without altering any behavioral logic or public API contracts.
This commit is contained in:
1 parent
6bdc9354d3
commit
4b6005962e
14 files changed
+779
-369
No files matched your search
@@ -13,20 +13,30 @@ use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::time::Instant;
|
||||
|
||||
use obicompactvec::{PersistentCompactIntMatrix, PersistentSparseCompactIntMatrix, PersistentSparseCompactIntMatrixBuilder};
|
||||
use obicompactvec::{
|
||||
PersistentIntMatrix, PersistentSparseCompactIntMatrix, PersistentSparseCompactIntMatrixBuilder,
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let layer_dir = std::env::args().nth(1).expect("usage: compare_sparse_dense_count <layer_dir>");
|
||||
let layer_dir = std::env::args()
|
||||
.nth(1)
|
||||
.expect("usage: compare_sparse_dense_count <layer_dir>");
|
||||
let layer_dir = Path::new(&layer_dir);
|
||||
|
||||
let t0 = Instant::now();
|
||||
let dense = PersistentCompactIntMatrix::open(layer_dir)?;
|
||||
println!("dense ouverte en {:?} ({} lignes x {} colonnes)", t0.elapsed(), dense.n(), dense.n_cols());
|
||||
let dense = PersistentIntMatrix::open(layer_dir)?;
|
||||
println!(
|
||||
"dense ouverte en {:?} ({} lignes x {} colonnes)",
|
||||
t0.elapsed(),
|
||||
dense.n(),
|
||||
dense.n_cols()
|
||||
);
|
||||
|
||||
let out_dir = tempfile::tempdir()?;
|
||||
|
||||
let t0 = Instant::now();
|
||||
let sparse = PersistentSparseCompactIntMatrixBuilder::build_from_dense(&dense, out_dir.path())?.finish()?;
|
||||
let sparse = PersistentSparseCompactIntMatrixBuilder::build_from_dense(&dense, out_dir.path())?
|
||||
.finish()?;
|
||||
println!("build_from_dense: {:?}", t0.elapsed());
|
||||
|
||||
compare(&dense, &sparse)?;
|
||||
@@ -36,7 +46,10 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn compare(dense: &PersistentCompactIntMatrix, sparse: &PersistentSparseCompactIntMatrix) -> Result<(), Box<dyn Error>> {
|
||||
fn compare(
|
||||
dense: &PersistentIntMatrix,
|
||||
sparse: &PersistentSparseCompactIntMatrix,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let n = dense.n();
|
||||
let n_cols = dense.n_cols();
|
||||
assert_eq!(n, sparse.n(), "n mismatch");
|
||||
@@ -63,7 +76,10 @@ fn compare(dense: &PersistentCompactIntMatrix, sparse: &PersistentSparseCompactI
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("comparaison case-a-case: {:?} ({total_cells} cellules)", t0.elapsed());
|
||||
println!(
|
||||
"comparaison case-a-case: {:?} ({total_cells} cellules)",
|
||||
t0.elapsed()
|
||||
);
|
||||
|
||||
if let Some((slot, col, d, s)) = first_mismatch {
|
||||
eprintln!("PREMIER MISMATCH: slot={slot} col={col} dense={d} sparse={s}");
|
||||
@@ -78,7 +94,7 @@ fn compare(dense: &PersistentCompactIntMatrix, sparse: &PersistentSparseCompactI
|
||||
/// for what's actually stored) — sparsity, singleton-row fraction, and the
|
||||
/// value-magnitude buckets this crate's overflow encoding is tuned around
|
||||
/// (< 127, < 255, >= 255).
|
||||
fn content_stats(dense: &PersistentCompactIntMatrix) {
|
||||
fn content_stats(dense: &PersistentIntMatrix) {
|
||||
let n = dense.n();
|
||||
let n_cols = dense.n_cols();
|
||||
let total_cells = n as u64 * n_cols as u64;
|
||||
@@ -128,7 +144,10 @@ fn content_stats(dense: &PersistentCompactIntMatrix) {
|
||||
100.0 * singleton_rows as f64 / n as f64
|
||||
);
|
||||
if nonzero_cells > 0 {
|
||||
println!("valeur moyenne (non-nulles): {:.2}", sum as f64 / nonzero_cells as f64);
|
||||
println!(
|
||||
"valeur moyenne (non-nulles): {:.2}",
|
||||
sum as f64 / nonzero_cells as f64
|
||||
);
|
||||
println!("valeur max: {max_value}");
|
||||
println!(
|
||||
"valeurs < 127: {under_127} ({:.3}% des non-nulles)",
|
||||
@@ -162,7 +181,7 @@ fn dir_size(dir: &Path) -> std::io::Result<u64> {
|
||||
fn compaction_stats(
|
||||
dense_layer_dir: &Path,
|
||||
sparse_dir: &Path,
|
||||
dense: &PersistentCompactIntMatrix,
|
||||
dense: &PersistentIntMatrix,
|
||||
_sparse: &PersistentSparseCompactIntMatrix,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let dense_size = dir_size(&dense_layer_dir.join("counts"))?;
|
||||
|
||||
Reference in new issue
Block a user