unum-cloud / usearch

Fast Open-Source Search & Clustering engine × for Vectors & 🔜 Strings × in C++, C, Python, JavaScript, Rust, Java, Objective-C, Swift, C#, GoLang, and Wolfram 🔍
https://unum-cloud.github.io/usearch/
Apache License 2.0
2.27k stars 143 forks source link

Add: Swift & Obj-C bindings for filteredSearch #471

Closed vardhan closed 2 months ago

vardhan commented 3 months ago

Added a couple of tests in Swift to test both functions.

Tested with swift build && swift test -v

Issue: #470

vardhan commented 3 months ago

gentle ping @ashvardanian 🙏

ashvardanian commented 2 months ago

@vardhan, can you please refresh from main-dev, there are some patches that may help pass the tests on MacOS. Thanks!

vardhan commented 2 months ago

@vardhan, can you please refresh from main-dev, there are some patches that may help pass the tests on MacOS. Thanks!

Rebased on top of latest main-dev. I'm not able successfully swift build though -- seems like some C++ duplicate definition failure? I tried checking out main-dev and doing a swift build too, but fails similarly, so I think its not related to my PR.

ashvardanian commented 2 months ago

I can't run it locally right now, but the CI is failing.

Building for debugging...
[0/1] Compiling USearchObjective USearchObjective.mm
[2/4] Compiling USearch USearch.swift
[3/4] Emitting module USearch
[4/4] Compiling USearch Index+Sugar.swift
/Users/runner/work/usearch/usearch/swift/Index+Sugar.swift:137:20: error: cannot find 'getDouble' in scope
            return getDouble(
                   ^~~~~~~~~
/Users/runner/work/usearch/usearch/swift/Index+Sugar.swift:[19](https://github.com/unum-cloud/usearch/actions/runs/10550588738/job/29227007339?pr=471#step:14:20)9:13: error: cannot find 'filteredSearchDouble' in scope
            filteredSearchDouble(
            ^~~~~~~~~~~~~~~~~~~~
Error: Process completed with exit code 1.

This looks like it's coming from your changes, @vardhan.

vardhan commented 2 months ago

Thanks! I fixed the issues that CI raised.

However, when I try to build (swift build), or even from a clean origin/main-dev, i get:

In file included from /Users/vardhan/github/usearch/objc/USearchObjective.mm:5:
In file included from /Users/vardhan/github/usearch/include/usearch/index_dense.hpp:12:
/Users/vardhan/github/usearch/include/usearch/index_plugins.hpp:1123:20: error: redefinition of 'cast_gt<signed char, __fp16>'
template <> struct cast_gt<i8_t, bf16_t> : public cast_from_i8_gt<bf16_t> {};
                   ^~~~~~~~~~~~~~~~~~~~~

though it doesnt look like CI is hitting this issue. Note that if I checkout an older commit (tag v2.14.0), I don't see any failures.

ashvardanian commented 2 months ago

That looks like a mistake in the core implementation, that may even be coming from SimSIMD type definitions, where bf16 maps to fp16. That shouldn't happen.

vardhan commented 2 months ago

That looks like a mistake in the core implementation, that may even be coming from SimSIMD type definitions, where bf16 maps to fp16. That shouldn't happen.

This was the error I mentioned earlier -- It doesn't seem like it's related to this PR though. Please let me know if CI throws any more issues (I don't have the ability to run it from my fork)

In case it matters, I'm building on an Apple Macbook w/ M3 (so arm64), Sonoma 14.6, and XCode 15.4

ashvardanian commented 2 months ago

Thank you, @vardhan! Merged 😉