Skip to content

Commit 3c09fce

Browse files
committed
build bundles
1 parent 66d374f commit 3c09fce

2 files changed

Lines changed: 50 additions & 10 deletions

File tree

libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85238,6 +85238,26 @@ typedef u32 VectorDims;
8523885238
*/
8523985239
#define MAX_VECTOR_SZ 65536
8524085240

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+
8524185261
/*
8524285262
* Enumerate of supported vector types (0 omitted intentionally as we can use zero as "undefined" value)
8524385263
*/
@@ -211204,28 +211224,28 @@ static int vectorParseMeta(const unsigned char *pBlob, size_t nBlobSize, int *pT
211204211224

211205211225
if( *pType == VECTOR_TYPE_FLOAT32 ){
211206211226
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);
211208211228
return SQLITE_ERROR;
211209211229
}
211210211230
*pDims = nBlobSize / sizeof(float);
211211211231
*pDataSize = nBlobSize;
211212211232
}else if( *pType == VECTOR_TYPE_FLOAT64 ){
211213211233
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);
211215211235
return SQLITE_ERROR;
211216211236
}
211217211237
*pDims = nBlobSize / sizeof(double);
211218211238
*pDataSize = nBlobSize;
211219211239
}else if( *pType == VECTOR_TYPE_1BIT ){
211220211240
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);
211222211242
return SQLITE_ERROR;
211223211243
}
211224211244
nLeftoverBits = pBlob[nBlobSize - 1];
211225211245
*pDims = nBlobSize * 8 - nLeftoverBits;
211226211246
*pDataSize = (*pDims + 7) / 8;
211227211247
}else{
211228-
*pzErrMsg = sqlite3_mprintf("invalid vector: unexpected type: %d", *pType);
211248+
*pzErrMsg = sqlite3_mprintf("vector: unexpected binary type: %d", *pType);
211229211249
return SQLITE_ERROR;
211230211250
}
211231211251
return SQLITE_OK;
@@ -211250,7 +211270,7 @@ int vectorParseSqliteBlobWithType(
211250211270

211251211271
if( nDataSize != vectorDataSize(pVector->type, pVector->dims) ){
211252211272
*pzErrMsg = sqlite3_mprintf(
211253-
"invalid vector: unexpected data size bytes: type=%d, dims=%d, %ull != %ull",
211273+
"vector: unexpected data part size: type=%d, dims=%d, %ull != %ull",
211254211274
pVector->type,
211255211275
pVector->dims,
211256211276
nDataSize,

libsql-ffi/bundled/src/sqlite3.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85238,6 +85238,26 @@ typedef u32 VectorDims;
8523885238
*/
8523985239
#define MAX_VECTOR_SZ 65536
8524085240

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+
8524185261
/*
8524285262
* Enumerate of supported vector types (0 omitted intentionally as we can use zero as "undefined" value)
8524385263
*/
@@ -211204,28 +211224,28 @@ static int vectorParseMeta(const unsigned char *pBlob, size_t nBlobSize, int *pT
211204211224

211205211225
if( *pType == VECTOR_TYPE_FLOAT32 ){
211206211226
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);
211208211228
return SQLITE_ERROR;
211209211229
}
211210211230
*pDims = nBlobSize / sizeof(float);
211211211231
*pDataSize = nBlobSize;
211212211232
}else if( *pType == VECTOR_TYPE_FLOAT64 ){
211213211233
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);
211215211235
return SQLITE_ERROR;
211216211236
}
211217211237
*pDims = nBlobSize / sizeof(double);
211218211238
*pDataSize = nBlobSize;
211219211239
}else if( *pType == VECTOR_TYPE_1BIT ){
211220211240
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);
211222211242
return SQLITE_ERROR;
211223211243
}
211224211244
nLeftoverBits = pBlob[nBlobSize - 1];
211225211245
*pDims = nBlobSize * 8 - nLeftoverBits;
211226211246
*pDataSize = (*pDims + 7) / 8;
211227211247
}else{
211228-
*pzErrMsg = sqlite3_mprintf("invalid vector: unexpected type: %d", *pType);
211248+
*pzErrMsg = sqlite3_mprintf("vector: unexpected binary type: %d", *pType);
211229211249
return SQLITE_ERROR;
211230211250
}
211231211251
return SQLITE_OK;
@@ -211250,7 +211270,7 @@ int vectorParseSqliteBlobWithType(
211250211270

211251211271
if( nDataSize != vectorDataSize(pVector->type, pVector->dims) ){
211252211272
*pzErrMsg = sqlite3_mprintf(
211253-
"invalid vector: unexpected data size bytes: type=%d, dims=%d, %ull != %ull",
211273+
"vector: unexpected data part size: type=%d, dims=%d, %ull != %ull",
211254211274
pVector->type,
211255211275
pVector->dims,
211256211276
nDataSize,

0 commit comments

Comments
 (0)