mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
Merge branch 'main' of github.com:asg017/sqlite-vec into main
This commit is contained in:
commit
65c4aa3754
2 changed files with 17 additions and 2 deletions
|
|
@ -41,13 +41,13 @@ See <a href="#sponsors">the Sponsors section</a> for more details.
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
See [Installing `sqlite-vec`](https://alexgarcia.xyz/sqlite-vec/installing.html)
|
See [Installing `sqlite-vec`](https://alexgarcia.xyz/sqlite-vec/installation.html)
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
| Language | Install | More Info | |
|
| Language | Install | More Info | |
|
||||||
| -------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| -------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Python | `pip install sqlite-vec` | [`sqlite-vec` with Python](https://alexgarcia.xyz/sqlite-vec/python.html) | [](https://pypi.org/project/sqlite-vec/) |
|
| Python | `pip install sqlite-vec` | [`sqlite-vec` with Python](https://alexgarcia.xyz/sqlite-vec/python.html) | [](https://pypi.org/project/sqlite-vec/) |
|
||||||
| Node.js | `npm install sqlite-vec` | [`sqlite-vec` with Node.js](https://alexgarcia.xyz/sqlite-vec/nodejs.html) | [](https://www.npmjs.com/package/sqlite-vec) |
|
| Node.js | `npm install sqlite-vec` | [`sqlite-vec` with Node.js](https://alexgarcia.xyz/sqlite-vec/js.html) | [](https://www.npmjs.com/package/sqlite-vec) |
|
||||||
| Ruby | `gem install sqlite-vec` | [`sqlite-vec` with Ruby](https://alexgarcia.xyz/sqlite-vec/ruby.html) |  |
|
| Ruby | `gem install sqlite-vec` | [`sqlite-vec` with Ruby](https://alexgarcia.xyz/sqlite-vec/ruby.html) |  |
|
||||||
| Go | `go get -u github.com/asg017/sqlite-vec/bindings/go` | [`sqlite-vec` with Go](https://alexgarcia.xyz/sqlite-vec/go.html) | [](https://pkg.go.dev/github.com/asg017/asg017/sqlite-vec-go-bindings/cgo) |
|
| Go | `go get -u github.com/asg017/sqlite-vec/bindings/go` | [`sqlite-vec` with Go](https://alexgarcia.xyz/sqlite-vec/go.html) | [](https://pkg.go.dev/github.com/asg017/asg017/sqlite-vec-go-bindings/cgo) |
|
||||||
| Rust | `cargo add sqlite-vec` | [`sqlite-vec` with Rust](https://alexgarcia.xyz/sqlite-vec/rust.html) | [](https://crates.io/crates/sqlite-vec) |
|
| Rust | `cargo add sqlite-vec` | [`sqlite-vec` with Rust](https://alexgarcia.xyz/sqlite-vec/rust.html) | [](https://crates.io/crates/sqlite-vec) |
|
||||||
|
|
|
||||||
15
sqlite-vec.c
15
sqlite-vec.c
|
|
@ -505,9 +505,21 @@ static f32 distance_hamming_u8(u8 *a, u8 *b, size_t n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
#if !defined(__clang__) && \
|
||||||
|
(defined(_M_ARM) || defined(_M_ARM64))
|
||||||
|
// From https://github.com/ngtcp2/ngtcp2/blob/b64f1e77b5e0d880b93d31f474147fae4a1d17cc/lib/ngtcp2_ringbuf.c, line 34-43
|
||||||
|
static unsigned int __builtin_popcountl(unsigned int x) {
|
||||||
|
unsigned int c = 0;
|
||||||
|
for (; x; ++c) {
|
||||||
|
x &= x - 1;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
#else
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#define __builtin_popcountl __popcnt64
|
#define __builtin_popcountl __popcnt64
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static f32 distance_hamming_u64(u64 *a, u64 *b, size_t n) {
|
static f32 distance_hamming_u64(u64 *a, u64 *b, size_t n) {
|
||||||
int same = 0;
|
int same = 0;
|
||||||
|
|
@ -534,6 +546,7 @@ static f32 distance_hamming(const void *a, const void *b, const void *d) {
|
||||||
return distance_hamming_u8((u8 *)a, (u8 *)b, dimensions / CHAR_BIT);
|
return distance_hamming_u8((u8 *)a, (u8 *)b, dimensions / CHAR_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(SQLITE_CORE) || (defined(SQLITE_AMALGAMATION) && defined(SQLITE_OMIT_JSON))
|
||||||
// from SQLite source:
|
// from SQLite source:
|
||||||
// https://github.com/sqlite/sqlite/blob/a509a90958ddb234d1785ed7801880ccb18b497e/src/json.c#L153
|
// https://github.com/sqlite/sqlite/blob/a509a90958ddb234d1785ed7801880ccb18b497e/src/json.c#L153
|
||||||
static const char jsonIsSpaceX[] = {
|
static const char jsonIsSpaceX[] = {
|
||||||
|
|
@ -551,7 +564,9 @@ static const char jsonIsSpaceX[] = {
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define jsonIsspace(x) (jsonIsSpaceX[(unsigned char)x])
|
#define jsonIsspace(x) (jsonIsSpaceX[(unsigned char)x])
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (*vector_cleanup)(void *p);
|
typedef void (*vector_cleanup)(void *p);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue