-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add usearch #2608
feat: add usearch #2608
Conversation
WalkthroughWalkthroughThe changes introduce functionality for managing and installing the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Makefile
participant Docker
participant GoModule
participant UsearchAPI
participant UsearchTests
participant ErrorHandling
User->>Makefile: Invoke make commands
Makefile->>Docker: Build Docker image
Docker->>Makefile: Execute usearch/install
Makefile->>GoModule: Add dependency
GoModule->>UsearchAPI: Initialize Usearch instance
UsearchAPI->>UsearchTests: Run unit tests
UsearchTests->>ErrorHandling: Validate error scenarios
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying vald with Cloudflare Pages
|
[CHATOPS:HELP] ChatOps commands.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2608 +/- ##
==========================================
+ Coverage 24.24% 24.35% +0.11%
==========================================
Files 533 536 +3
Lines 46255 46439 +184
==========================================
+ Hits 11213 11310 +97
- Misses 34288 34361 +73
- Partials 754 768 +14 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Outside diff range and nitpick comments (2)
internal/errors/usearch.go (1)
20-32
: LGTM, but consider adding more context if needed.The custom error type
UsearchError
, constructor functionNewUsearchError
, andError
method are correctly implemented and follow Go conventions.Consider adding more context or structured fields to the
UsearchError
type if it would be helpful for error handling and debugging. For example:type UsearchError struct { Msg string Code int Cause error }internal/core/algorithm/usearch/usearch_test.go (1)
1-379
: LGTM! The test file is well-structured and comprehensive.The code changes are approved. The test file follows best practices for unit testing in Go and covers a good range of scenarios to ensure the correctness of the
Search
method. The use of table-driven tests and helper functions makes the test code maintainable and readable.Here are a few suggestions to further improve the test file:
Consider adding more test cases to cover edge cases and boundary conditions, such as:
- Searching with an empty query vector.
- Searching with a large
k
value that exceeds the number of indexed vectors.- Searching with a negative
k
value.- Searching in an empty index.
Consider extracting the common setup logic from the
createFunc
of each test case into a separate helper function. This will reduce duplication and make the test cases more focused on the specific scenario they are testing.Consider adding a test case to verify the behavior when the index file is not found or corrupted. This will help ensure graceful error handling in such scenarios.
Consider adding a benchmark test to measure the performance of the
Search
method with different index sizes and query parameters. This will help track and optimize the performance of theusearch
package over time.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
Files selected for processing (10)
- Makefile (3 hunks)
- dockers/ci/base/Dockerfile (1 hunks)
- go.mod (1 hunks)
- hack/actions/gen/main.go (1 hunks)
- hack/docker/gen/main.go (3 hunks)
- internal/core/algorithm/usearch/option.go (1 hunks)
- internal/core/algorithm/usearch/usearch.go (1 hunks)
- internal/core/algorithm/usearch/usearch_test.go (1 hunks)
- internal/errors/usearch.go (1 hunks)
- versions/USEARCH_VERSION (1 hunks)
Files skipped from review due to trivial changes (1)
- versions/USEARCH_VERSION
Additional comments not posted (31)
internal/errors/usearch.go (2)
1-16
: LGTM!The Apache 2.0 license header is correctly included.
17-18
: LGTM!The package declaration and documentation are appropriate.
dockers/ci/base/Dockerfile (1)
123-123
: LGTM!The code change is approved. The addition of
make usearch/install
command to install theusearch
library is consistent with the existing pattern and enhances the functionality of the Docker image.internal/core/algorithm/usearch/option.go (7)
45-53
: LGTM!The code changes are approved.
110-120
: LGTM!The code changes are approved.
123-132
: LGTM!The code changes are approved.
135-144
: LGTM!The code changes are approved.
147-156
: LGTM!The code changes are approved.
159-164
: LGTM!The code changes are approved.
33-42
: LGTM!The code changes are approved.
internal/core/algorithm/usearch/usearch.go (14)
29-58
: LGTM!The
Usearch
interface looks good and covers all the necessary operations for managing theusearch
index.
60-75
: LGTM!The
usearch
struct looks good and contains all the necessary fields for managing theusearch
index.
78-81
: LGTM!The
New
function looks good and follows the common pattern for constructor functions.
83-85
: LGTM!The
Load
function looks good and follows the common pattern for constructor functions.
87-128
: LGTM!The
gen
function looks good and handles the initialization of theusearch
index based on theisLoad
flag.
130-140
: LGTM!The
SaveIndex
method looks good and ensures thread safety by acquiring a write lock.
142-152
: LGTM!The
SaveIndexWithPath
method looks good and ensures thread safety by acquiring a write lock.
154-163
: LGTM!The
GetIndicesSize
method looks good and ensures thread safety by acquiring a read lock.
165-178
: LGTM!The
Add
method looks good and ensures thread safety by acquiring a write lock. It also validates the dimension of the vector before adding it to the index.
180-189
: LGTM!The
Reserve
method looks good and ensures thread safety by acquiring a write lock.
191-211
: LGTM!The
Search
method looks good and ensures thread safety by acquiring a read lock. It also validates the dimension of the query vector before performing the search.
213-229
: LGTM!The
GetObject
method looks good and ensures thread safety by acquiring a read lock.
231-241
: LGTM!The
Remove
method looks good and ensures thread safety by acquiring a write lock.
243-251
: LGTM!The
Close
method looks good and properly frees the resources associated with theusearch
index.hack/actions/gen/main.go (1)
316-316
: LGTM!The addition of the
usearchVersionPath
constant is a straightforward and consistent extension of the existing versioning mechanism. It allows for tracking the version of the "usearch" component alongside other components like NGT and Faiss.The code change is approved.
hack/docker/gen/main.go (3)
244-246
: LGTM!The addition of the
usearchPreprocess
constant follows the existing pattern forngt
andfaiss
preprocess constants. It indicates that a newusearch
library is being introduced, and the assignedmake
command suggests that there will be a correspondingusearch/install
target in the Makefile to handle the installation.
649-649
: LGTM!The addition of
usearchPreprocess
to thePreprocess
slice of thevald-ci-container
configuration ensures that theusearch
library is installed as part of the preprocessing steps. This change is consistent with the existing preprocessing steps forngt
andfaiss
libraries.
667-668
: LGTM!The addition of
usearchPreprocess
to thePreprocess
slice of thevald-dev-container
configuration ensures that theusearch
library is installed as part of the preprocessing steps for the development container. This change maintains consistency with the existing preprocessing steps forngt
andfaiss
libraries.Makefile (2)
88-88
: LGTM!The code changes are approved. The new variable
USEARCH_VERSION
is defined correctly, following the existing pattern of reading the version from a file.
607-611
: LGTM!The code changes are approved. The new targets
version/usearch
andusearch/install
are implemented correctly, following the existing pattern for managing dependencies. The installation process handles different operating systems appropriately.Also applies to: 686-701
go.mod (1)
383-383
: New dependency added: github.com/unum-cloud/usearch/golangA new dependency on the
usearch
library has been added. A few suggestions:
- Consider pointing to a specific release version instead of a commit hash for better reproducibility of builds.
- Ensure that thorough testing is done to validate the integration of this new library and check for any regressions.
- Update the documentation as needed to reflect this new dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@all-contributors please add @iammytoo for code,research |
I've put up a pull request to add @iammytoo! 🎉 |
* feat: add usearch * style: format code with Gofumpt and Prettier This commit fixes the style issues introduced in 58baee9 according to the output from Gofumpt and Prettier. Details: #2608 * feat: impl usearch istallation cmd for ci/base container * style: format code with Gofumpt and Prettier This commit fixes the style issues introduced in 938cc12 according to the output from Gofumpt and Prettier. Details: #2608 * add: multiple vector test * fix: add ldconfg to Makefile * refactor: covert switch to map --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Hiroto Funakoshi <[email protected]> Co-authored-by: Kiichiro YUKAWA <[email protected]> Co-authored-by: Yusuke Kato <[email protected]>
Description
internal/core/algorithm/usearch/*.go
.Makefile
andhack/docker/gen/main.go
.Related Issue
Versions
Checklist
Special notes for your reviewer
Summary by CodeRabbit
Summary by CodeRabbit
Release Notes
New Features
usearch
library, allowing users to check the current version.usearch
on both Linux and macOS systems.Enhancements
usearch
installation into the Docker build process.usearch
library.usearch
algorithm, enhancing usability.Bug Fixes
Tests
Usearch
interface.Version Update
USEARCH_VERSION
to 2.15.1, indicating new features and improvements.