Skip to content

Commit

Permalink
Improved Docs & Minor Patches (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Aug 12, 2024
1 parent af72575 commit 46584d4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Cargo
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run TinySemVer
uses: ashvardanian/tinysemver@v2.0.1
with:
Expand All @@ -40,6 +35,7 @@ jobs:
package.json:"version": "(\d+\.\d+\.\d+)"
CITATION.cff:^version: (\d+\.\d+\.\d+)
Cargo.toml:^version = "(\d+\.\d+\.\d+)"
Cargo.lock:^version = "(\d+\.\d+\.\d+)"
wasmer.toml:^version = "(\d+\.\d+\.\d+)"
conanfile.py:version = "(\d+\.\d+\.\d+)"
java/README.md:<version>(\d+\.\d+\.\d+)</version>
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def search(query: str) -> np.ndarray:
server.run()
```

Similar experiences can also be imlemented in other languages and on the client side, removing the network latency.
Similar experiences can also be implemented in other languages and on the client side, removing the network latency.
For Swift and iOS, check out the [`ashvardanian/SwiftSemanticSearch`](https://github.com/ashvardanian/SwiftSemanticSearch) repository.

<table>
Expand Down
11 changes: 7 additions & 4 deletions c/usearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ USEARCH_EXPORT usearch_distance_t usearch_distance( //
usearch_metric_kind_t metric_kind, usearch_error_t* error);

/**
* @brief Multi-threaded exact nearest neighbors search for equi-dimensional vectors.
* @brief Multi-threaded many-to-many exact nearest neighbors search for equi-dimensional vectors.
* @param[in] dataset Pointer to the first scalar of the dataset matrix.
* @param[in] queries Pointer to the first scalar of the queries matrix.
* @param[in] dataset_size Number of vectors in the `dataset`.
Expand All @@ -446,10 +446,13 @@ USEARCH_EXPORT usearch_distance_t usearch_distance( //
* @param[in] metric_kind The metric kind used for distance calculation between vectors.
* @param[in] count Upper bound on the number of neighbors to search, the "k" in "kANN".
* @param[in] threads Upper bound for the number of CPU threads to use.
* @param[out] keys Output buffer for up to `count` nearest neighbors keys.
* @param[out] distances Output buffer for up to `count` distances to nearest neighbors.
* @param[out] keys Output matrix for `queries_size * count` nearest neighbors keys. Each row of the
* matrix must be contiguous in memory, but different rows can be separated by `keys_stride` bytes.
* @param[in] keys_stride Number of bytes between starts of consecutive rows od scalars in `keys`.
* @param[out] distances Output matrix for `queries_size * count` distances to nearest neighbors. Each row of the
* matrix must be contiguous in memory, but different rows can be separated by `keys_stride` bytes.
* @param[in] distances_stride Number of bytes between starts of consecutive rows od scalars in `distances`.
* @param[out] error Pointer to a string where the error message will be stored, if an error occurs.
* @return Number of found matches.
*/
USEARCH_EXPORT void usearch_exact_search( //
void const* dataset, size_t dataset_size, size_t dataset_stride, //
Expand Down
2 changes: 1 addition & 1 deletion java/cloud/unum/usearch/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public int[] search(float vector[], long count) {
*
* @param key key to lookup.
* @return the contents of the vector.
* @throws linkIllegalArgumentException} is key is not available.
* @throws IllegalArgumentException is key is not available.
*/
public float[] get(int key) {
if (c_ptr == 0) {
Expand Down
10 changes: 5 additions & 5 deletions java/cloud/unum/usearch/cloud_unum_usearch_Index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1create( //
return result;
}

JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1createFromFile(JNIEnv *env, jclass, jstring path, jboolean view) {
JNIEXPORT jlong JNICALL Java_cloud_unum_usearch_Index_c_1createFromFile(JNIEnv* env, jclass, jstring path,
jboolean view) {
char const* path_cstr = env->GetStringUTFChars(path, 0);
index_dense_t::state_result_t make_result = index_dense_t::make(path_cstr, view);
env->ReleaseStringUTFChars(path, path_cstr);
Expand Down Expand Up @@ -157,9 +158,8 @@ JNIEXPORT void JNICALL Java_cloud_unum_usearch_Index_c_1add( //
(*env).ReleaseFloatArrayElements(vector, vector_data, 0);
}

JNIEXPORT jfloatArray JNICALL Java_cloud_unum_usearch_Index_c_1get(
JNIEnv *env, jclass, jlong c_ptr, jint key) {

JNIEXPORT jfloatArray JNICALL Java_cloud_unum_usearch_Index_c_1get(JNIEnv* env, jclass, jlong c_ptr, jint key) {

auto index = reinterpret_cast<index_dense_t*>(c_ptr);
size_t dim = index->dimensions();
std::unique_ptr<jfloat[]> vector(new jfloat[dim]);
Expand All @@ -170,7 +170,7 @@ JNIEXPORT jfloatArray JNICALL Java_cloud_unum_usearch_Index_c_1get(
}
}
jfloatArray jvector = env->NewFloatArray(dim);
if (jvector == nullptr) { // out of memory
if (jvector == nullptr) { // out of memory
return nullptr;
}
env->SetFloatArrayRegion(jvector, 0, dim, vector.get());
Expand Down
6 changes: 5 additions & 1 deletion rust/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,9 @@ std::unique_ptr<NativeIndex> new_native_index(IndexOptions const& options) {
throw std::invalid_argument("Unsupported metric or scalar type");
index_dense_config_t config(options.connectivity, options.expansion_add, options.expansion_search);
config.multi = options.multi;
return wrap(index_t::make(metric, config));
index_t index = index_t::make(metric, config);
// In Rust we have the luxury of returning a `Result` type even for the constructor.
// So let's pre-reserve the maximal number of threads and return the error if it fails.
index.reserve(index_limits_t{});
return wrap(std::move(index));
}
2 changes: 1 addition & 1 deletion rust/lib.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "rust/cxx.h"

// We don't have to forward decalre all of those:
// We don't have to forward declare all of those:
struct Matches;
struct IndexOptions;
enum class MetricKind;
Expand Down

0 comments on commit 46584d4

Please sign in to comment.