Skip to content

Commit

Permalink
introduce V3 on-disk vector index format with aligned metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sivukhin committed Nov 11, 2024
1 parent 7e2b44e commit 497ab06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion libsql-sqlite3/src/vectorIndexInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ typedef u8 MetricType;
/*
* 1 - v1 version; node block format: [node meta] [node vector] [edge vectors] ... [ [u64 unused ] [u64 edge rowid] ] ...
* 2 - v2 version; node block format: [node meta] [node vector] [edge vectors] ... [ [u32 unused] [f32 distance] [u64 edge rowid] ] ...
* 3 - v3 version; node meta aligned to 8-byte boundary (instead of having u64 + u16 size - we round it up to u64 + u64)
*/
#define VECTOR_FORMAT_V1 1
#define VECTOR_FORMAT_DEFAULT 2
#define VECTOR_FORMAT_V2 2
#define VECTOR_FORMAT_DEFAULT 3

/* type of the vector index */
#define VECTOR_INDEX_TYPE_PARAM_ID 2
Expand Down
6 changes: 5 additions & 1 deletion libsql-sqlite3/src/vectordiskann.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ void blobSpotFree(BlobSpot *pBlobSpot) {
**************************************************************************/

int nodeMetadataSize(int nFormatVersion){
return (sizeof(u64) + sizeof(u16));
if( nFormatVersion <= VECTOR_FORMAT_V2 ){
return (sizeof(u64) + sizeof(u16));
}else{
return (sizeof(u64) + sizeof(u64));
}
}

int edgeMetadataSize(int nFormatVersion){
Expand Down

0 comments on commit 497ab06

Please sign in to comment.