1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// SPDX-License-Identifier: Apache-2.0
//! `VectorIndex` and `VectorIndexFactory` traits. See ADR-0002 and ADR-0003.
//!
//! All methods take `&self`. Implementations MUST handle concurrency
//! internally (e.g., `hnsw_rs` uses `parking_lot::RwLock` under the hood;
//! search takes a read lock, insert takes a write lock). This shape lets the
//! writer thread and read-pool tasks share a single
//! `Arc<dyn VectorIndex + Send + Sync>` instance without application-level
//! locking — see ADR-0003 § Operational invariants for the rationale.
use crateResult;
use Path;
/// Approximate nearest-neighbor index over FP32 vectors keyed by SQLite rowid.
///
/// All mutating methods take `&self`. The discipline that makes this safe is
/// twofold: (1) the impl handles its own concurrency, and (2) only one task
/// (the WriterActor on its dedicated OS thread) issues mutations — read tasks
/// only call `search`. The trait does not enforce (2); callers must.
/// Separates "create a fresh index" from "load existing index from disk."
/// The factory holds the configuration (HNSW M, efConstruction, etc.) that
/// is otherwise duplicated between the two operations.