refactor: streamline I/O handling and remove deprecated codec module

Removes the `codec` and `limits` modules, eliminating manual serialization logic and OS file descriptor limit queries. Introduces a shared `append_path_suffix` utility to standardize path manipulation across `meta.rs` and `unitig_index.rs`. Refactors the file pool to dynamically size based on available file descriptors and optimizes descriptor lifecycle to prevent leaks. Enhances `SKFileReader` with LRU eviction, consumption tracking, and seek-on-reopen support. Migrates related round-trip and EOF tests to the reader module and updates chunking logic in the unitig index.
This commit is contained in:
Eric Coissac
2026-05-09 19:19:33 +08:00
parent 9e5af6b5a5
commit 92cda13ae4
10 changed files with 91 additions and 202 deletions
+3 -9
View File
@@ -25,14 +25,7 @@ use crate::error::{SKError, SKResult};
const MAGIC: [u8; 4] = *b"UIDX";
fn idx_path(path: &Path) -> PathBuf {
let mut s = path.as_os_str().to_owned();
s.push(".idx");
PathBuf::from(s)
}
// Extract a sub-sequence [start, end) nucleotides from a unitig.
fn sub_unitig(unitig: &Unitig, start: usize, end: usize) -> Unitig {
unitig.sub(start, end)
crate::append_path_suffix(path, ".idx")
}
// ── Writer ────────────────────────────────────────────────────────────────────
@@ -88,7 +81,7 @@ impl UnitigFileWriter {
let mut start = 0;
while start < seql {
let end = (start + chunk_nucl).min(seql);
self.write_chunk(&sub_unitig(unitig, start, end))?;
self.write_chunk(&unitig.sub(start, end))?;
if end == seql {
break;
}
@@ -102,6 +95,7 @@ impl UnitigFileWriter {
let byte_len = (seql + 3) / 4;
// Header is 1 byte (u8: n_kmers 1 = seql k); packed bytes follow.
debug_assert!(seql - self.k <= u8::MAX as usize, "chunk exceeds MAX_KMERS_PER_CHUNK");
self.packed_offsets.push(self.next_offset + 1);
self.seqls.push((seql - self.k) as u8);