You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -85238,6 +85238,26 @@ typedef u32 VectorDims;
85238
85238
*/
85239
85239
#define MAX_VECTOR_SZ 65536
85240
85240
85241
+
/*
85242
+
* on-disk binary format for vector of different types:
85243
+
* 1. float32
85244
+
* [data[0] as f32] [data[1] as f32] ... [data[dims - 1] as f32] [1 as u8]?
85245
+
* - last 'type'-byte is optional for float32 vectors
85246
+
*
85247
+
* 2. float64
85248
+
* [data[0] as f64] [data[1] as f64] ... [data[dims - 1] as f64] [2 as u8]
85249
+
* - last 'type'-byte is mandatory for float64 vectors
85250
+
*
85251
+
* 3. float1bit
85252
+
* [data[0] as u8] [data[1] as u8] ... [data[(dims + 7) / 8] as u8] [_ as u8; padding]? [leftover as u8] [3 as u8]
85253
+
* - every data byte (except for the last) represents exactly 8 components of the vector
85254
+
* - last data byte represents [1..8] components of the vector
85255
+
* - optional padding byte ensures that leftover byte will be written at the odd blob position (0-based)
85256
+
* - leftover byte specify amount of trailing *bits* in the blob without last 'type'-byte which must be omitted
85257
+
* (so, vector dimensions are equal to 8 * (blob_size - 1) - leftover)
85258
+
* - last 'type'-byte is mandatory for float1bit vectors
85259
+
*/
85260
+
85241
85261
/*
85242
85262
* Enumerate of supported vector types (0 omitted intentionally as we can use zero as "undefined" value)
85243
85263
*/
@@ -211204,28 +211224,28 @@ static int vectorParseMeta(const unsigned char *pBlob, size_t nBlobSize, int *pT
211204
211224
211205
211225
if( *pType == VECTOR_TYPE_FLOAT32 ){
211206
211226
if( nBlobSize % 4 != 0 ){
211207
-
*pzErrMsg = sqlite3_mprintf("invalid vector: f32 vector blob length must be divisible by 4 (excluding optional 'type'-byte): length=%d", nBlobSize);
211227
+
*pzErrMsg = sqlite3_mprintf("vector: f32 vector blob length must be divisible by 4 (excluding optional 'type'-byte): length=%d", nBlobSize);
211208
211228
return SQLITE_ERROR;
211209
211229
}
211210
211230
*pDims = nBlobSize / sizeof(float);
211211
211231
*pDataSize = nBlobSize;
211212
211232
}else if( *pType == VECTOR_TYPE_FLOAT64 ){
211213
211233
if( nBlobSize % 8 != 0 ){
211214
-
*pzErrMsg = sqlite3_mprintf("invalid vector: f64 vector blob length must be divisible by 8 (excluding 'type'-byte): length=%d", nBlobSize);
211234
+
*pzErrMsg = sqlite3_mprintf("vector: f64 vector blob length must be divisible by 8 (excluding 'type'-byte): length=%d", nBlobSize);
211215
211235
return SQLITE_ERROR;
211216
211236
}
211217
211237
*pDims = nBlobSize / sizeof(double);
211218
211238
*pDataSize = nBlobSize;
211219
211239
}else if( *pType == VECTOR_TYPE_1BIT ){
211220
211240
if( nBlobSize == 0 || nBlobSize % 2 != 0 ){
211221
-
*pzErrMsg = sqlite3_mprintf("invalid vector: 1bit vector blob length must be divisible by 2 and not be empty (excluding 'type'-byte): length=%d", nBlobSize);
211241
+
*pzErrMsg = sqlite3_mprintf("vector: 1bit vector blob length must be divisible by 2 and not be empty (excluding 'type'-byte): length=%d", nBlobSize);
Copy file name to clipboardExpand all lines: libsql-ffi/bundled/src/sqlite3.c
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -85238,6 +85238,26 @@ typedef u32 VectorDims;
85238
85238
*/
85239
85239
#define MAX_VECTOR_SZ 65536
85240
85240
85241
+
/*
85242
+
* on-disk binary format for vector of different types:
85243
+
* 1. float32
85244
+
* [data[0] as f32] [data[1] as f32] ... [data[dims - 1] as f32] [1 as u8]?
85245
+
* - last 'type'-byte is optional for float32 vectors
85246
+
*
85247
+
* 2. float64
85248
+
* [data[0] as f64] [data[1] as f64] ... [data[dims - 1] as f64] [2 as u8]
85249
+
* - last 'type'-byte is mandatory for float64 vectors
85250
+
*
85251
+
* 3. float1bit
85252
+
* [data[0] as u8] [data[1] as u8] ... [data[(dims + 7) / 8] as u8] [_ as u8; padding]? [leftover as u8] [3 as u8]
85253
+
* - every data byte (except for the last) represents exactly 8 components of the vector
85254
+
* - last data byte represents [1..8] components of the vector
85255
+
* - optional padding byte ensures that leftover byte will be written at the odd blob position (0-based)
85256
+
* - leftover byte specify amount of trailing *bits* in the blob without last 'type'-byte which must be omitted
85257
+
* (so, vector dimensions are equal to 8 * (blob_size - 1) - leftover)
85258
+
* - last 'type'-byte is mandatory for float1bit vectors
85259
+
*/
85260
+
85241
85261
/*
85242
85262
* Enumerate of supported vector types (0 omitted intentionally as we can use zero as "undefined" value)
85243
85263
*/
@@ -211204,28 +211224,28 @@ static int vectorParseMeta(const unsigned char *pBlob, size_t nBlobSize, int *pT
211204
211224
211205
211225
if( *pType == VECTOR_TYPE_FLOAT32 ){
211206
211226
if( nBlobSize % 4 != 0 ){
211207
-
*pzErrMsg = sqlite3_mprintf("invalid vector: f32 vector blob length must be divisible by 4 (excluding optional 'type'-byte): length=%d", nBlobSize);
211227
+
*pzErrMsg = sqlite3_mprintf("vector: f32 vector blob length must be divisible by 4 (excluding optional 'type'-byte): length=%d", nBlobSize);
211208
211228
return SQLITE_ERROR;
211209
211229
}
211210
211230
*pDims = nBlobSize / sizeof(float);
211211
211231
*pDataSize = nBlobSize;
211212
211232
}else if( *pType == VECTOR_TYPE_FLOAT64 ){
211213
211233
if( nBlobSize % 8 != 0 ){
211214
-
*pzErrMsg = sqlite3_mprintf("invalid vector: f64 vector blob length must be divisible by 8 (excluding 'type'-byte): length=%d", nBlobSize);
211234
+
*pzErrMsg = sqlite3_mprintf("vector: f64 vector blob length must be divisible by 8 (excluding 'type'-byte): length=%d", nBlobSize);
211215
211235
return SQLITE_ERROR;
211216
211236
}
211217
211237
*pDims = nBlobSize / sizeof(double);
211218
211238
*pDataSize = nBlobSize;
211219
211239
}else if( *pType == VECTOR_TYPE_1BIT ){
211220
211240
if( nBlobSize == 0 || nBlobSize % 2 != 0 ){
211221
-
*pzErrMsg = sqlite3_mprintf("invalid vector: 1bit vector blob length must be divisible by 2 and not be empty (excluding 'type'-byte): length=%d", nBlobSize);
211241
+
*pzErrMsg = sqlite3_mprintf("vector: 1bit vector blob length must be divisible by 2 and not be empty (excluding 'type'-byte): length=%d", nBlobSize);
0 commit comments