pub fn write_segment(
dir: &Path,
name: &str,
dim: usize,
vectors: &[&[f32]],
surrogate_ids: &[u64],
) -> Result<()>Expand description
Write a v2 NDVS segment file as name inside dir.
surrogate_ids[i] is the u64 surrogate for vectors[i]. The slice may be
empty, in which case all surrogate IDs are written as 0.
The segment is assembled in memory and published with a single
write โ sync_data โ rename โ fsync_dir sequence, so the final name only
ever names a complete, footer-terminated segment. Writing into the final
path directly had two crash windows: truncating it destroyed an existing
segment before anything valid replaced it, and a crash between the body and
footer syncs left a final-named file that no reader could validate.
ยงErrors
Returns std::io::Error on any I/O failure, arithmetic overflow, or a
name that is not one plain path component.