Skip to main content

a3s_vec/
lib.rs

1//! `a3s-vec` is A3S's native Rust in-process vector database.
2//!
3//! The crate provides the collection, document, schema, query, index, and
4//! durability primitives needed by an embedded vector store.  It follows the
5//! zvec Rust API vocabulary while keeping the implementation free of a C/C++
6//! runtime dependency, which makes the same source usable on Apple Silicon,
7//! current Intel macOS (deployment target 15.0), Linux, and Windows. macOS 12
8//! Monterey Intel is unsupported.
9//!
10//! A collection's document snapshot and WAL are authoritative. Flat queries
11//! execute against that snapshot; revision-tagged HNSW, IVF, metric-aware
12//! Vamana, and product-quantized `DiskANN` generations select bounded
13//! candidates before exact re-ranking. Each Vamana/DiskANN base also has an A3S-native,
14//! sector-aligned recovery sidecar. Native
15//! numeric vector encodings are preserved at rest and remain distinct from index-only
16//! FP16/INT8/INT4 scalar quantization. Revisioned scalar and full-text indexes
17//! accelerate structured and lexical retrieval, including Unicode n-grams,
18//! ordered token filters, boolean groups, required/prohibited clauses, and
19//! wildcard/fuzzy/range terms, boosts, and ordered phrase proximity. HNSW and
20//! IVF also provide multi-bit `RaBitQ` families with exact re-ranking. `DiskANN`
21//! uses deterministic PQ training, ADC graph traversal, and a typed choice of
22//! positioned reads or a validated immutable anonymous mmap snapshot. With the
23//! `async` feature, query, multi-query, and group-by entry points run that same
24//! work on Tokio's blocking pool. Writable collections can also opt into one
25//! explicitly owned standard-thread maintenance scheduler, while public health
26//! snapshots distinguish authoritative revision failures from derived-index
27//! degradation and normal WAL checkpoint lag. Native async file reads and
28//! direct file-backed mmap remain explicit future optimizations.
29//!
30//! The external algorithm kernel is an implementation detail and is not part
31//! of the stable A3S API:
32//!
33//! ```compile_fail
34//! use a3s_vec::core;
35//! ```
36
37mod collection;
38mod config;
39mod doc;
40mod embedding;
41mod error;
42mod index;
43mod iterator;
44mod multi_query;
45mod query;
46mod schema;
47mod stats;
48mod storage;
49mod text;
50mod types;
51
52pub use collection::{
53    Collection, CollectionHealth, CollectionHealthStatus, CollectionMaintenanceHealth,
54    CollectionMaintenanceOptions, CollectionMaintenancePhase, CollectionMaintenanceRuntime,
55    CollectionOptions, CollectionResourceLimits, CollectionStats, DocWriteResult, IndexStat,
56    WriteResult,
57};
58pub use config::{
59    check_version, default_config, initialize, is_initialized, shutdown, version, version_major,
60    version_minor, version_patch, ConfigBuilder, Durability, IoBackend,
61};
62pub use doc::{Doc, FieldValue, VectorValue};
63pub use embedding::{DenseEmbedding, EmbeddingInput, QueryExecutor, SparseEmbedding};
64pub use error::{Error, ErrorCode, Result};
65pub use iterator::DocIterator;
66pub use multi_query::{MultiQuery, RerankMethod, SubQuery};
67pub use query::{
68    DiskannQueryParams, FlatQueryParams, Fts, FtsQueryParams, GroupBySearchQuery, HnswQueryParams,
69    IvfQueryParams, IvfRabitqQueryParams, SearchQuery, SearchQueryBuilder, VectorQuery,
70};
71pub use schema::{
72    AddColumnOption, AlterColumnOption, CollectionSchema, CollectionSchemaBuilder,
73    DiskANNIndexParam, DiskAnnIndexParam, FieldSchema, FlatIndexParam, FtsIndexParam,
74    HnswIndexParam, IVFIndexParam, IndexParams, IndexParamsBuilder, InvertIndexParam,
75    IvfIndexParam, IvfRabitqIndexParam, VamanaIndexParam, VectorSchema,
76};
77pub use stats::StatsSnapshot;
78pub use types::{DataType, DocOperator, IndexType, MetricType, QuantizeType};
79
80/// Convenient import for the common collection workflow.
81pub mod prelude {
82    pub use crate::{
83        initialize, is_initialized, version, Collection, CollectionMaintenanceOptions,
84        CollectionOptions, CollectionResourceLimits, CollectionSchema, ConfigBuilder, DataType,
85        Doc, DocIterator, Error, ErrorCode, FieldSchema, IndexParams, IoBackend, MetricType,
86        MultiQuery, QuantizeType, Result, SearchQuery, VectorSchema, WriteResult,
87    };
88}
89
90#[cfg(test)]
91mod tests {
92    use super::*;
93
94    #[test]
95    fn public_version_is_nonempty() {
96        assert!(!version().is_empty());
97    }
98}