Knowhere Architecture
Directory Structure
| Directory |
Purpose |
include/knowhere/ |
Public headers |
src/index/ |
Index implementations (flat/, hnsw/, ivf/, gpu/, diskann/, sparse/, minhash/) |
src/common/ |
Threading, tracing, metrics utilities |
src/cluster/ |
Clustering algorithms (KMeans) |
tests/ut/ |
Unit tests |
thirdparty/ |
Forked third-party libraries |
Core Components
Index Factory (include/knowhere/index/index_factory.h)
- Singleton factory pattern for creating indexes
- Uses macro-based static registration (
KNOWHERE_SIMPLE_REGISTER_GLOBAL)
Index Interface (include/knowhere/index/index.h)
- Template-based
Index<IndexNode> wrapper
- Operations: Build, Search, RangeSearch
Configuration (include/knowhere/config.h)
- JSON-based config system
- Compile-time and runtime parameter validation
Data Types (include/knowhere/operands.h)
- fp32, fp16, bf16, int8, bin1 (binary), sparse_u32_f32
Error Handling (include/knowhere/expected.h)
- Custom
expected<T> type with Status enum
Metric Types
L2, IP (Inner Product), COSINE, Jaccard, Hamming, BM25
Detailed Reference
- Index types: See index-types.md for each index's capabilities and use cases
- Third-party libraries: See dependencies.md for faiss, hnswlib, DiskANN, Cardinal details
1---2name: architecture3description: Use when exploring codebase structure, understanding index implementations (HNSW, IVF, DISKANN, Sparse, MinHash), working with third-party libraries (faiss, hnswlib, DiskANN, Cardinal), or locating specific functionality4---56# Knowhere Architecture78## Directory Structure910| Directory | Purpose |11|-----------|---------|12| `include/knowhere/` | Public headers |13| `src/index/` | Index implementations (flat/, hnsw/, ivf/, gpu/, diskann/, sparse/, minhash/) |14| `src/common/` | Threading, tracing, metrics utilities |15| `src/cluster/` | Clustering algorithms (KMeans) |16| `tests/ut/` | Unit tests |17| `thirdparty/` | Forked third-party libraries |1819## Core Components2021**Index Factory** (`include/knowhere/index/index_factory.h`)22- Singleton factory pattern for creating indexes23- Uses macro-based static registration (`KNOWHERE_SIMPLE_REGISTER_GLOBAL`)2425**Index Interface** (`include/knowhere/index/index.h`)26- Template-based `Index<IndexNode>` wrapper27- Operations: Build, Search, RangeSearch2829**Configuration** (`include/knowhere/config.h`)30- JSON-based config system31- Compile-time and runtime parameter validation3233**Data Types** (`include/knowhere/operands.h`)34- fp32, fp16, bf16, int8, bin1 (binary), sparse_u32_f323536**Error Handling** (`include/knowhere/expected.h`)37- Custom `expected<T>` type with Status enum3839## Metric Types4041L2, IP (Inner Product), COSINE, Jaccard, Hamming, BM254243## Detailed Reference4445- **Index types**: See [index-types.md](index-types.md) for each index's capabilities and use cases46- **Third-party libraries**: See [dependencies.md](dependencies.md) for faiss, hnswlib, DiskANN, Cardinal details