Skip to content

Commit 4b562ed

Browse files
committed
small refactoring
1 parent 4a57f02 commit 4b562ed

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

libsql-sqlite3/src/vectorIndex.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
**
2525
** libSQL vector search.
2626
*/
27+
#include "vectorInt.h"
2728
#ifndef SQLITE_OMIT_VECTOR
2829
#include "sqlite3.h"
2930
#include "vdbeInt.h"
@@ -373,14 +374,14 @@ void vectorOutRowsFree(sqlite3 *db, VectorOutRows *pRows) {
373374
*/
374375
struct VectorColumnType {
375376
const char *zName;
376-
int nBits;
377+
int type;
377378
};
378379

379380
static struct VectorColumnType VECTOR_COLUMN_TYPES[] = {
380-
{ "FLOAT32", 32 },
381-
{ "FLOAT64", 64 },
382-
{ "F32_BLOB", 32 },
383-
{ "F64_BLOB", 64 }
381+
{ "FLOAT32", VECTOR_TYPE_FLOAT32 },
382+
{ "FLOAT64", VECTOR_TYPE_FLOAT64 },
383+
{ "F32_BLOB", VECTOR_TYPE_FLOAT32 },
384+
{ "F64_BLOB", VECTOR_TYPE_FLOAT64 }
384385
};
385386

386387
/*
@@ -569,14 +570,7 @@ int vectorIdxParseColumnType(const char *zType, int *pType, int *pDims, const ch
569570
}
570571

571572
*pDims = dimensions;
572-
if( VECTOR_COLUMN_TYPES[i].nBits == 32 ) {
573-
*pType = VECTOR_TYPE_FLOAT32;
574-
} else if( VECTOR_COLUMN_TYPES[i].nBits == 64 ) {
575-
*pType = VECTOR_TYPE_FLOAT64;
576-
} else {
577-
*pErrMsg = "unsupported vector type";
578-
return -1;
579-
}
573+
*pType = VECTOR_COLUMN_TYPES[i].type;
580574
return 0;
581575
}
582576
*pErrMsg = "unexpected vector column type";

0 commit comments

Comments
 (0)