Skip to content

Commit

Permalink
gha: trying to fix linux + windows testing
Browse files Browse the repository at this point in the history
  • Loading branch information
asg017 committed Apr 20, 2024
1 parent 2843d24 commit 1b3731b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 9 deletions.
47 changes: 46 additions & 1 deletion sqlite-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,52 @@
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1

#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif

#ifndef UINT32_TYPE
# ifdef HAVE_UINT32_T
# define UINT32_TYPE uint32_t
# else
# define UINT32_TYPE unsigned int
# endif
#endif
#ifndef UINT16_TYPE
# ifdef HAVE_UINT16_T
# define UINT16_TYPE uint16_t
# else
# define UINT16_TYPE unsigned short int
# endif
#endif
#ifndef INT16_TYPE
# ifdef HAVE_INT16_T
# define INT16_TYPE int16_t
# else
# define INT16_TYPE short int
# endif
#endif
#ifndef UINT8_TYPE
# ifdef HAVE_UINT8_T
# define UINT8_TYPE uint8_t
# else
# define UINT8_TYPE unsigned char
# endif
#endif
#ifndef INT8_TYPE
# ifdef HAVE_INT8_T
# define INT8_TYPE int8_t
# else
# define INT8_TYPE signed char
# endif
#endif
#ifndef LONGDOUBLE_TYPE
# define LONGDOUBLE_TYPE long double
#endif

typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int64_t uint64_t;
Expand Down Expand Up @@ -4162,7 +4208,6 @@ int vec0Update_Insert(sqlite3_vtab *pVTab, int argc, sqlite3_value **argv,
int rc = vector_from_value(valueVector, &vectorDatas[i], &dimensions,
&elementType, &cleanups[i], &pzError);
todo_assert(rc == SQLITE_OK);
printf("%d %d\n", elementType, p->vector_columns[i].element_type);
assert(elementType == p->vector_columns[i].element_type);

if (dimensions != p->vector_columns[i].dimensions) {
Expand Down
17 changes: 9 additions & 8 deletions tests/test-loadable.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

EXT_PATH = "./dist/vec0"

SUPPORTS_SUBTYPE = sqlite3.version_info[1] > 38

def bitmap_full(n: int) -> bytearray:
assert (n % 8) == 0
Expand Down Expand Up @@ -136,7 +137,8 @@ def test_vec_bit():
vec_bit = lambda *args: db.execute("select vec_bit(?)", args).fetchone()[0]
assert vec_bit(b"\xff") == b"\xff"

assert db.execute("select subtype(vec_bit(X'FF'))").fetchone()[0] == 224
if SUPPORTS_SUBTYPE:
assert db.execute("select subtype(vec_bit(X'FF'))").fetchone()[0] == 224

with pytest.raises(
sqlite3.OperationalError, match="zero-length vectors are not supported."
Expand Down Expand Up @@ -165,7 +167,8 @@ def test_vec_f32():
for test in tests:
assert vec_f32(json.dumps(test)) == _f32(test)

assert db.execute("select subtype(vec_f32(X'00000000'))").fetchone()[0] == 223
if SUPPORTS_SUBTYPE:
assert db.execute("select subtype(vec_f32(X'00000000'))").fetchone()[0] == 223

with pytest.raises(
sqlite3.OperationalError, match="zero-length vectors are not supported."
Expand Down Expand Up @@ -207,7 +210,9 @@ def test_vec_int8():
vec_int8 = lambda *args: db.execute("select vec_int8(?)", args).fetchone()[0]
assert vec_int8(b"\x00") == _int8([0])
assert vec_int8(b"\x00\x0f") == _int8([0, 15])
assert db.execute("select subtype(vec_int8(?))", [b"\x00"]).fetchone()[0] == 225

if SUPPORTS_SUBTYPE:
assert db.execute("select subtype(vec_int8(?))", [b"\x00"]).fetchone()[0] == 225


def npy_cosine(a, b):
Expand Down Expand Up @@ -584,23 +589,19 @@ def test_smoke():
db.execute("create virtual table vec_xyz using vec0( a float[2] )")
assert execute_all(
db,
"select name, ncol from pragma_table_list where name like 'vec_xyz%' order by name;",
"select name from sqlite_master where name like 'vec_xyz%' order by name;",
) == [
{
"name": "vec_xyz",
"ncol": 4,
},
{
"name": "vec_xyz_chunks",
"ncol": 4,
},
{
"name": "vec_xyz_rowids",
"ncol": 4,
},
{
"name": "vec_xyz_vector_chunks00",
"ncol": 2,
},
]
chunk = db.execute("select * from vec_xyz_chunks").fetchone()
Expand Down

0 comments on commit 1b3731b

Please sign in to comment.