ruvector/crates/ruvector-postgres/src/sparse/mod.rs
rUv 77f391b0b7 fix(ci): Fix formatting and workflow permission issues
- Run cargo fmt across all crates (468 files formatted)
- Add permissions for PR comments in benchmarks.yml
- Add continue-on-error for PR comment steps
- Remove Docker service from postgres-extension-ci (pgrx manages own postgres)
- Add permissions to postgres-extension-ci.yml

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-26 22:11:57 +00:00

30 lines
842 B
Rust

//! Sparse vector support for efficient storage and search of high-dimensional sparse embeddings.
//!
//! This module provides:
//! - Sparse vector type with COO (Coordinate) format storage
//! - Efficient sparse-sparse distance computations
//! - PostgreSQL operators and functions
//! - Support for BM25, SPLADE, and learned sparse representations
pub mod distance;
pub mod operators;
pub mod types;
// Re-exports for convenience
pub use distance::{sparse_cosine, sparse_dot, sparse_euclidean};
pub use types::SparseVec;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_sparse_module() {
let indices = vec![0, 2, 5];
let values = vec![1.0, 2.0, 3.0];
let sparse = SparseVec::new(indices, values, 10).unwrap();
assert_eq!(sparse.nnz(), 3);
assert_eq!(sparse.dim(), 10);
}
}