Skip to content

Commit b0e799e

Browse files
committed
doc: uml mermaid
1 parent 4b5cf91 commit b0e799e

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

uml.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
```mermaid
2+
classDiagram
3+
direction LR
4+
5+
class VectorStore {
6+
<<C++ Class>>
7+
-Dataset vectors_
8+
+add(const Dataset& data) void
9+
+getAll() const Dataset&
10+
+size() const size_t
11+
}
12+
13+
class SearchResult {
14+
<<C++ Struct>>
15+
+idList indices
16+
+vector~float~ distances
17+
}
18+
19+
class IndexBase {
20+
<<Abstract C++ Class>>
21+
#size_t dimension_
22+
#shared_ptr~VectorStore~ datastore_
23+
+IndexBase(size_t dim)
24+
+virtual build(const Dataset& data) void
25+
+virtual train()* void
26+
+virtual search(const Vector& query, size_t k) const SearchResult*
27+
+virtual write_index(const string& filename) const void* %% Added pure virtual method
28+
+dimension() const size_t
29+
+data() const Dataset&
30+
}
31+
32+
IndexBase o-- "1" VectorStore : aggregates
33+
34+
class KDTreeIndex {
35+
<<C++ Class>>
36+
-Node* root_
37+
+KDTreeIndex(size_t dim)
38+
+train() void
39+
+search(const Vector& query, size_t k) const SearchResult
40+
+write_index(const string& filename) const void %% Overrides IndexBase::write_index
41+
+read_index(const string& filename) shared_ptr~KDTreeIndex~
42+
}
43+
IndexBase <|-- KDTreeIndex
44+
KDTreeIndex ..> SearchResult : returns
45+
KDTreeIndex "1" *-- "0..*" Node : contains
46+
47+
class Node {
48+
<<Inner C++ Struct of KDTreeIndex>>
49+
+size_t idx
50+
+size_t dim
51+
+float val
52+
+Node* left
53+
+Node* right
54+
+Node(size_t i, size_t d, float v)
55+
}
56+
57+
58+
class IVFFlatIndex {
59+
<<C++ Class>>
60+
-size_t nlist_
61+
-size_t nprobe_
62+
-Dataset centroids_
63+
-vector~idList~ lists_
64+
+IVFFlatIndex(size_t dim, size_t nlist, size_t nprobe)
65+
+train() void
66+
+search(const Vector& query, size_t k) const SearchResult
67+
+search(const Vector& query, size_t k, size_t nprobe) const SearchResult
68+
+search_batch(const Dataset& queries, size_t k) const vector~SearchResult~
69+
+write_index(const string& filename) const void %% Overrides IndexBase::write_index
70+
+read_index(const string& filename) shared_ptr~IVFFlatIndex~
71+
-kmeans(const Dataset& data, size_t iterations) void
72+
}
73+
IndexBase <|-- IVFFlatIndex
74+
IVFFlatIndex ..> SearchResult : returns
75+
IVFFlatIndex ..> SimdUtils : uses
76+
77+
class HNSWIndex {
78+
<<C++ Class>>
79+
-unique_ptr~faiss::IndexHNSWFlat~ idx_
80+
+HNSWIndex(size_t dim, size_t M, size_t efConstruction)
81+
+train() void
82+
+search(const Vector& query, size_t k) const SearchResult
83+
+search(const Vector& query, size_t k, size_t efSearch) const SearchResult
84+
+search_batch(const Dataset& queries, size_t k) const vector~SearchResult~
85+
+set_ef_search(size_t efSearch) void
86+
+reorder_layout() void
87+
+reorder_layout(const string& mapping_file) void
88+
+write_index(const string& filename) const void %% Overrides IndexBase::write_index
89+
+read_index(const string& filename) shared_ptr~HNSWIndex~
90+
}
91+
IndexBase <|-- HNSWIndex
92+
HNSWIndex ..> SearchResult : returns
93+
94+
class PyIndexBase {
95+
<<C++ Trampoline Class for Pybind11>>
96+
+PyIndexBase(size_t dim)
97+
+train() void
98+
+search(const Vector&, size_t) const SearchResult
99+
+write_index(const string& filename) const void %% Added override
100+
}
101+
IndexBase <|-- PyIndexBase
102+
103+
class SimdUtils {
104+
<<C++ Utility Namespace/Static Class>>
105+
+static l2_simd(const float* a, const float* b, size_t dim) float
106+
}

0 commit comments

Comments
 (0)