Skip to content

Commit 1216f17

Browse files
committed
remove unused function
1 parent 307139f commit 1216f17

5 files changed

Lines changed: 9 additions & 52 deletions

File tree

libsql-sqlite3/src/vector.c

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -339,39 +339,21 @@ int vectorParseSqliteBlobWithType(
339339

340340
int detectBlobVectorParameters(sqlite3_value *arg, int *pType, int *pDims, char **pzErrMsg) {
341341
const u8 *pBlob;
342-
int nBlobSize;
342+
size_t nBlobSize, nDataSize;
343343

344344
assert( sqlite3_value_type(arg) == SQLITE_BLOB );
345345

346346
pBlob = sqlite3_value_blob(arg);
347347
nBlobSize = sqlite3_value_bytes(arg);
348-
if( nBlobSize % 2 != 0 ){
349-
// we have trailing byte with explicit type definition
350-
*pType = pBlob[nBlobSize - 1];
351-
nBlobSize--;
352-
} else {
353-
// else, fallback to FLOAT32
354-
*pType = VECTOR_TYPE_FLOAT32;
355-
}
356-
if( *pType == VECTOR_TYPE_FLOAT32 ){
357-
*pDims = nBlobSize / sizeof(float);
358-
}else if( *pType == VECTOR_TYPE_FLOAT64 ){
359-
*pDims = nBlobSize / sizeof(double);
360-
}else if( *pType == VECTOR_TYPE_1BIT ){
361-
if( nBlobSize == 0 || nBlobSize % 2 != 0 ){
362-
*pzErrMsg = sqlite3_mprintf("vector: malformed 1bit float: blob size must has even size (without last byte): size=%d", nBlobSize);
363-
return -1;
364-
}
365-
*pDims = nBlobSize * 8 - pBlob[nBlobSize - 1];
366-
}else{
367-
*pzErrMsg = sqlite3_mprintf("vector: unexpected binary type: got %d, expected %d or %d", *pType, VECTOR_TYPE_FLOAT32, VECTOR_TYPE_FLOAT64);
368-
return -1;
348+
349+
if( vectorParseMeta(pBlob, nBlobSize, pType, pDims, &nDataSize, pzErrMsg) != SQLITE_OK ){
350+
return SQLITE_ERROR;
369351
}
370352
if( *pDims > MAX_VECTOR_SZ ){
371353
*pzErrMsg = sqlite3_mprintf("vector: max size exceeded: %d > %d", *pDims, MAX_VECTOR_SZ);
372-
return -1;
354+
return SQLITE_ERROR;
373355
}
374-
return 0;
356+
return SQLITE_OK;
375357
}
376358

377359
int detectTextVectorParameters(sqlite3_value *arg, int typeHint, int *pType, int *pDims, char **pzErrMsg) {
@@ -560,16 +542,7 @@ size_t vectorSerializeToBlob(const Vector *pVector, unsigned char *pBlob, size_t
560542
}
561543

562544
void vectorInitFromBlob(Vector *pVector, const unsigned char *pBlob, size_t nBlobSize){
563-
switch (pVector->type) {
564-
case VECTOR_TYPE_FLOAT32:
565-
vectorF32InitFromBlob(pVector, pBlob, nBlobSize);
566-
break;
567-
case VECTOR_TYPE_FLOAT64:
568-
vectorF64InitFromBlob(pVector, pBlob, nBlobSize);
569-
break;
570-
default:
571-
assert(0);
572-
}
545+
pVector->data = (void*)pBlob;
573546
}
574547

575548
static void vectorConvertFromF32(const Vector *pFrom, Vector *pTo){

libsql-sqlite3/src/vectorIndex.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,6 @@ int vectorIndexCreate(Parse *pParse, const Index *pIdx, const char *zDbSName, co
883883
sqlite3ErrorMsg(pParse, "vector index: %s: %s", pzErrMsg, zEmbeddingColumnTypeName);
884884
return CREATE_FAIL;
885885
}
886-
887886
// schema is locked while db is initializing and we need to just proceed here
888887
if( db->init.busy == 1 ){
889888
return CREATE_OK;
@@ -963,11 +962,8 @@ int vectorIndexSearch(
963962
rc = SQLITE_ERROR;
964963
goto out;
965964
}
966-
if( type != VECTOR_TYPE_FLOAT32 && type != VECTOR_TYPE_FLOAT64 ){
967-
*pzErrMsg = sqlite3_mprintf("vector index(search): unsupported vector type: only FLOAT32/FLOAT64 are available for indexing");
968-
rc = SQLITE_ERROR;
969-
goto out;
970-
}
965+
assert( type == VECTOR_TYPE_FLOAT32 || type == VECTOR_TYPE_FLOAT64 || type == VECTOR_TYPE_1BIT );
966+
971967
pVector = vectorAlloc(type, dims);
972968
if( pVector == NULL ){
973969
rc = SQLITE_NOMEM_BKPT;

libsql-sqlite3/src/vectorInt.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ void vector1BitDeserializeFromBlob(Vector *, const unsigned char *, size_t);
105105

106106
void vectorInitStatic(Vector *, VectorType, VectorDims, void *);
107107
void vectorInitFromBlob(Vector *, const unsigned char *, size_t);
108-
void vectorF32InitFromBlob(Vector *, const unsigned char *, size_t);
109-
void vectorF64InitFromBlob(Vector *, const unsigned char *, size_t);
110108

111109
void vectorConvert(const Vector *, Vector *);
112110

libsql-sqlite3/src/vectorfloat32.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ float vectorF32DistanceL2(const Vector *v1, const Vector *v2){
168168
return sqrt(sum);
169169
}
170170

171-
void vectorF32InitFromBlob(Vector *pVector, const unsigned char *pBlob, size_t nBlobSize){
172-
pVector->dims = nBlobSize / sizeof(float);
173-
pVector->data = (void*)pBlob;
174-
}
175-
176171
void vectorF32DeserializeFromBlob(
177172
Vector *pVector,
178173
const unsigned char *pBlob,

libsql-sqlite3/src/vectorfloat64.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ double vectorF64DistanceL2(const Vector *v1, const Vector *v2){
175175
return sqrt(sum);
176176
}
177177

178-
void vectorF64InitFromBlob(Vector *pVector, const unsigned char *pBlob, size_t nBlobSize){
179-
pVector->dims = nBlobSize / sizeof(double);
180-
pVector->data = (void*)pBlob;
181-
}
182-
183178
void vectorF64DeserializeFromBlob(
184179
Vector *pVector,
185180
const unsigned char *pBlob,

0 commit comments

Comments
 (0)