Commit Graph

36 Commits

Author SHA1 Message Date
Pekka Enberg
3a4cb34606 Merge 'Fix memory leaks, make extension types more efficient' from Preston Thorpe
I was baffled previously, because any time that `free` was called on a
type from an extension, it would hang even when I knew it wasn't in use
any longer, and hadn't been double free'd.
After #737 was merged, I tried it again and noticed that it would no
longer hang... but only for extensions that were staticly linked.
Then I realized that we are using a global allocator, that likely wasn't
getting used in the shared library that is built separately that won't
inherit from our global allocator in core, causing some symbol mismatch
and the subsequent hanging on calls to `free`.
This PR adds the global allocator to extensions behind a feature flag in
the macro that will prevent it from being used in `wasm` and staticly
linked environments where it would conflict with limbos normal global
allocator. This allows us to properly free the memory from returning
extension functions over FFI.
This PR also changes the Extension type to a union field so we can store
int + float values inline without boxing them.
any additional tips or thoughts anyone else has on improving this would
be appreciated 👍

Closes #803
2025-01-30 13:31:17 +02:00
Jussi Saurio
c950b177aa Add test for property: vector -> text -> vector produces an equal vector 2025-01-28 16:09:48 +02:00
Jussi Saurio
e01555467f Add quickcheck property tests for vector extension 2025-01-28 15:53:11 +02:00
Pekka Enberg
ee05ad172b core: Bundle vector extension by default 2025-01-28 14:24:09 +02:00
Pekka Enberg
9462426685 Vector extension functions
This patch adds some libSQL vector extension functions such as
`vector()` and `vector_distance_cos()`, which can be used for exact
nearest neighbor search as follows:

```
limbo> SELECT embedding, vector_distance_cos(embedding, '[9, 9, 9]')
   ...> FROM movies ORDER BY vector_distance_cos(embedding, '[9, 9, 9]');
[4, 5, 6]|0.013072490692138672
[1, 2, 3]|0.07417994737625122
```
2025-01-28 14:24:09 +02:00
PThorpe92
793cdf8bad Fix memory issues, make extension types more efficient 2025-01-27 22:30:31 -05:00
PThorpe92
c5e60d8e08 Enable only uuid by default, change tests back to account for this 2025-01-21 10:20:01 -05:00
PThorpe92
f13d035965 Enable wasm to static link extensions 2025-01-21 09:36:49 -05:00
PThorpe92
c1152670a3 Remove manual extension registration 2025-01-21 09:32:43 -05:00
PThorpe92
3d188eba0f Enable staticly linking with builtin extensions 2025-01-21 09:32:43 -05:00
PThorpe92
bcd3ae2bd7 Add documentation to core/ext and relevant macros 2025-01-18 16:04:28 -05:00
PThorpe92
9c47379927 Fix deref null ptr in Debug impl on external types 2025-01-18 15:23:33 -05:00
PThorpe92
956320b7d0 Fix scalar API in extensions, add some error handling 2025-01-18 15:19:35 -05:00
Jussi Saurio
a48c9033e2 Merge pull request #724 from PThorpe92/extdocs
Add documentation for extensions/core
2025-01-18 11:08:35 +02:00
PThorpe92
b57308003e Handle freeing memory in finalize, remove unused free fn 2025-01-17 21:54:25 -05:00
PThorpe92
fc82461eff Complete percentile extension, enable col+delimeter args 2025-01-17 21:15:09 -05:00
PThorpe92
dc16ed1ef6 Add documentation for extensions/core 2025-01-17 20:43:10 -05:00
PThorpe92
5dfc3b8787 Create simple extension for testing aggregate functions, add tests 2025-01-17 14:30:12 -05:00
PThorpe92
44374b9e69 Clean up scalar trait remove unnecessary args method 2025-01-17 14:13:57 -05:00
PThorpe92
a1b1c01e9a Alter existing extensions to match new API 2025-01-17 14:13:57 -05:00
PThorpe92
0c737d88f7 Support aggregate functions in Extensions 2025-01-17 14:13:57 -05:00
PThorpe92
9b7b794e07 Begin sketching out aggregates api 2025-01-17 14:13:42 -05:00
psvri
e43271f53b Implement regexp extension 2025-01-16 23:15:59 +05:30
Pekka Enberg
9209641a07 cargo fmt 2025-01-16 14:43:23 +02:00
Pekka Enberg
93903555aa Rename limbo_extension crate to limbo_ext 2025-01-16 14:40:52 +02:00
Pekka Enberg
f83b34287e Move limbo_extension crate to extensions/core 2025-01-16 14:39:12 +02:00
PThorpe92
343ccb3f72 Replace declare_scalar_functions in extension API with proc macro 2025-01-14 11:49:57 -05:00
PThorpe92
9c208dc866 Add tests for first extension 2025-01-14 07:27:35 -05:00
PThorpe92
e4ce6402eb Remove previous uuid implementation 2025-01-14 07:20:50 -05:00
PThorpe92
3099e5c9ba Improve api, standardize conversions between types, finish extension 2025-01-14 07:20:50 -05:00
PThorpe92
6e05258d36 Add safety comments and clean up extension types 2025-01-14 07:20:50 -05:00
PThorpe92
98eff6cf7a Enable passing arguments to external functions 2025-01-14 07:20:50 -05:00
PThorpe92
852817c9ff Have args macro in extension take a range 2025-01-14 07:20:50 -05:00
PThorpe92
c565fba195 Adjust types in extension API 2025-01-14 07:20:49 -05:00
PThorpe92
3412a3d4c2 Rough design for extension api/draft extension 2025-01-14 07:20:48 -05:00
PThorpe92
0a10d893d9 Sketch out runtime extension loading 2025-01-14 07:18:07 -05:00