Skip to content
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

Feature: support for retrieving metadata from index file in C interface #198

Closed
2 of 3 tasks
alexbarev opened this issue Aug 10, 2023 · 2 comments
Closed
2 of 3 tasks
Assignees
Labels
enhancement New feature or request released

Comments

@alexbarev
Copy link
Contributor

alexbarev commented Aug 10, 2023

Describe what you are looking for

Hey, I found an unobvious behaviour with the Go code related to the index pointer and configuration. Here's what's going on:

  1. In the Load function only the index pointer is set up, but the configuration is left with incorrect dimensions.

    usearch/golang/lib.go

    Lines 341 to 356 in e686a3d

    func (index *Index) Load(path string) error {
    if index.opaque_handle == nil {
    panic("Index is uninitialized")
    }
    c_path := C.CString(path)
    defer C.free(unsafe.Pointer(c_path))
    var errorMessage *C.char
    C.usearch_load((C.usearch_index_t)(unsafe.Pointer(index.opaque_handle)), c_path, (*C.usearch_error_t)(&errorMessage))
    if errorMessage != nil {
    return errors.New(C.GoString(errorMessage))
    }
    return nil
    }

  2. In the Get function, a vector is created with a length based on dimensions from config.

    vector = make([]float32, index.config.Dimensions)

    Same in the Search function
    if len(query) != int(index.config.Dimensions) {

  3. The dimensions come from the config struct, but it looks like it might not be set up properly. Since the Load function doesn't set the dimensions, and user can forget to do that explicitly.

One solution might be to set dimensions in Load function.

Or better to add support for metadata loading in C interface, as it is done for Python.

Can you contribute to the implementation?

  • I can contribute

Is your feature request specific to a certain interface?

Other bindings

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@alexbarev alexbarev added the enhancement New feature or request label Aug 10, 2023
@alexbarev alexbarev assigned alexbarev and ashvardanian and unassigned alexbarev Aug 10, 2023
@ashvardanian
Copy link
Contributor

ashvardanian commented Aug 10, 2023

Great catch! Should be an easy patch

ashvardanian pushed a commit that referenced this issue Oct 24, 2023
# [2.8.0](v2.7.8...v2.8.0) (2023-10-24)

### Add

* Jensen-Shannon Divergence-based distance ([799284c](799284c))
* metadata retrieval from C ([4e98cfb](4e98cfb)), closes [#198](#198)

### Docs

* Compatibility with JavaDoc ([d28dc1a](d28dc1a))

### Fix

* Missing header for `size_t` ([e7bbb2c](e7bbb2c))

### Make

* Update C build pipelines for C# deps ([89f53e7](89f53e7))
* Use older MinGW ([9b91f5d](9b91f5d)), closes [egor-tensin/setup-mingw#14](egor-tensin/setup-mingw#14)
* Use recent compiler for NPM uploads ([90042b1](90042b1))
@ashvardanian
Copy link
Contributor

🎉 This issue has been resolved in version 2.8.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

No branches or pull requests

2 participants