refactor: update storage size calculations for vector embeddings
- Revised the storage size calculation logic for Milvus, Qdrant, and Weaviate repositories to provide more accurate estimates based on the actual data structure and indexing methods. - Updated comments to clarify the relationship between vector dimensions and index storage requirements, enhancing code readability and maintainability.
This commit is contained in:
@@ -904,10 +904,11 @@ func (q *qdrantRepository) calculateStorageSize(embedding *QdrantVectorEmbedding
|
||||
dimensions := int64(len(embedding.Embedding))
|
||||
vectorSizeBytes = dimensions * 4
|
||||
|
||||
// HNSW index: dimensions × (M × 2) × 4 bytes
|
||||
// Default M=16, so: dimensions × 32 × 4 = dimensions × 128
|
||||
// HNSW graph links per vector: M×2 neighbors in layer 0, ~8 bytes per link
|
||||
// (4 bytes PointOffsetType + multi-layer amortization).
|
||||
// Graph link count depends on M, NOT on vector dimensions.
|
||||
const hnswM = 16
|
||||
hnswIndexBytes = dimensions * (hnswM * 2) * 4
|
||||
hnswIndexBytes = hnswM * 2 * 8
|
||||
}
|
||||
|
||||
// ID tracker metadata: 24 bytes per vector
|
||||
|
||||
Reference in New Issue
Block a user