{"id":17680912,"url":"https://github.com/hanabi1224/ruannoy","last_synced_at":"2025-07-04T10:03:01.159Z","repository":{"id":33736223,"uuid":"137846366","full_name":"hanabi1224/RuAnnoy","owner":"hanabi1224","description":"Rust port of annoy (https://github.com/spotify/annoy)","archived":false,"fork":false,"pushed_at":"2024-09-04T04:35:18.000Z","size":11452,"stargazers_count":42,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T05:15:33.200Z","etag":null,"topics":["annoy","approximate-nearest-neighbor-search","dotnet","java","kotlin","nearest-neighbor-search","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanabi1224.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-19T05:57:09.000Z","updated_at":"2025-02-01T18:55:42.000Z","dependencies_parsed_at":"2023-02-15T14:01:43.421Z","dependency_job_id":"12d42309-166b-498d-bc89-1a28edd8274a","html_url":"https://github.com/hanabi1224/RuAnnoy","commit_stats":{"total_commits":94,"total_committers":2,"mean_commits":47.0,"dds":"0.021276595744680882","last_synced_commit":"6495d4b42dab5cb9554f72ab7687a57a343399ef"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabi1224%2FRuAnnoy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabi1224%2FRuAnnoy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabi1224%2FRuAnnoy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanabi1224%2FRuAnnoy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanabi1224","download_url":"https://codeload.github.com/hanabi1224/RuAnnoy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241975155,"owners_count":20051431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["annoy","approximate-nearest-neighbor-search","dotnet","java","kotlin","nearest-neighbor-search","rust"],"created_at":"2024-10-24T09:09:44.450Z","updated_at":"2025-03-05T06:16:07.892Z","avatar_url":"https://github.com/hanabi1224.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RuAnnoy\n\n[![main](https://github.com/hanabi1224/RuAnnoy/actions/workflows/main.yml/badge.svg)](https://github.com/hanabi1224/RuAnnoy/actions/workflows/main.yml)\n[![MIT License](https://img.shields.io/github/license/hanabi1224/RuAnnoy.svg)](https://github.com/hanabi1224/RuAnnoy/blob/master/LICENSE)\n========\n\nThis library is a rust port of [spotify/annoy](https://github.com/spotify/annoy) , currently only index serving is supported.\n\nA live demo using web assembly is available at https://annoy-web-demo.vercel.app/\n\nIt also provides [FFI bindings](https://github.com/hanabi1224/RuAnnoy#ffi-support) for [jvm](https://github.com/hanabi1224/RuAnnoy#kotlinjava), [dotnet](https://github.com/hanabi1224/RuAnnoy#dotnet) and [dart](https://github.com/hanabi1224/RuAnnoy#dart)\n\n| Metric    | Serve | Build | jvm binding | dotnet binding | dart binding | WASM support |\n| :-------- | :---: | ----: | ----------- | -------------- | ------------ | ------------ |\n| Angular   |  ✅   |    ❌ | ✅          | ✅             | ✅           | ✅           |\n| Euclidean |  ✅   |    ❌ | ✅          | ✅             | ✅           | ✅           |\n| Manhattan |  ✅   |    ❌ | ✅          | ✅             | ✅           | ✅           |\n| Dot       |  ✅   |    ❌ | ✅          | ✅             | ✅           | ✅           |\n| Hamming   |  ❌   |    ❌ | ❌          | ❌             | ❌           | ❌           |\n\n### Install via [crates.io](https://crates.io/crates/annoy-rs)\n\n[![Crates.io](https://img.shields.io/crates/v/annoy-rs.svg)](https://crates.io/crates/annoy-rs)\n[![codecov](https://codecov.io/gh/hanabi1224/RuAnnoy/branch/master/graph/badge.svg?token=jVO7N0AVTH)](https://codecov.io/gh/hanabi1224/RuAnnoy)\n[![dependency status](https://deps.rs/repo/github/hanabi1224/RuAnnoy/status.svg?style=flat-square)](https://deps.rs/repo/github/hanabi1224/RuAnnoy)\n\n```toml\n# Cargo.toml\n[dependencies]\nannoy-rs = \"0.1\"\n```\n\n### Usage\n\n```rust\nuse annoy_rs::*;\n\nlet index = AnnoyIndex::load(10, \"index.ann\", IndexType::Angular).unwrap();\nlet v0 = index.get_item_vector(0);\nlet nearest = index.get_nearest(v0.as_ref(), 5, -1, true);\n```\n\n## SIMD support\n\nSIMD is supported via [`std::simd`](https://doc.rust-lang.org/nightly/std/simd/index.html) on nightly rust. Note that avx intrinsics need to be enabled explicitly by setting your cpu features in `RUSTFLAGS` environment variable.\n\n```bash\nRUSTFLAGS=\"-Ctarget-feature=+avx\" cargo +nightly build --release\n# or\nRUSTFLAGS=\"-Ctarget-cpu=native\" cargo +nightly build --release\n```\n\n## WASM support\n\nInstall [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/)\n\n```bash\nwasm-pack build\nwasm-pack test --node\n```\n\nsimd128 is supported in chrome by default.\n\nTo enable simd128, build with below command\n\n```bash\nRUSTFLAGS=\"-Ctarget-feature=+simd128\" cargo +nightly build --release --target wasm32-unknown-unknown\n```\n\nAn example site is deployed at https://annoy-web-demo.vercel.app/\n\nSource code is under [example/web](https://github.com/hanabi1224/RuAnnoy/tree/master/example/web)\n\n## FFI support\n\n### kotlin/java\n\nIt uses JNI bindings to rust crate and is ~5-10x faster than [pure java implementation](https://github.com/spotify/annoy-java) in [benchmark scenario](https://github.com/hanabi1224/RuAnnoy/tree/master/bench)\n\nNote that the prebuilt dynamically linked libraries are built with simd support, avx cpu feature is required.\n\n#### Install via [jitpack.io](https://jitpack.io/#hanabi1224/RuAnnoy)\n\n[![Release](https://jitpack.io/v/hanabi1224/RuAnnoy.svg)](https://jitpack.io/#hanabi1224/RuAnnoy)\n\n```gradle\nrepositories {\n  mavenCentral()\n  maven { url 'https://jitpack.io' }\n}\n\ndependencies {\n  implementation 'com.github.hanabi1224:RuAnnoy:\u003ctag\u003e'\n}\n```\n\n#### Usage\n\n```kotlin\nval index = AnnoyIndex.tryLoad(\"index.5d.ann\", 5, IndexType.Angular)\n```\n\n### dotnet\n\n| Runtimes                      | Nuget package                                                                                                                                 |\n| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |\n| RuAnnoy                       | [![NuGet version](https://buildstats.info/nuget/RuAnnoy)](https://www.nuget.org/packages/RuAnnoy)                                             |\n| RuAnnoy-Batteries-Windows-x64 | [![NuGet version](https://buildstats.info/nuget/RuAnnoy-Batteries-Windows-x64)](https://www.nuget.org/packages/RuAnnoy-Batteries-Windows-x64) |\n| RuAnnoy-Batteries-Linux-x64   | [![NuGet version](https://buildstats.info/nuget/RuAnnoy-Batteries-Linux-x64)](https://www.nuget.org/packages/RuAnnoy-Batteries-Linux-x64)     |\n| RuAnnoy-Batteries-Darwin-x64  | [![NuGet version](https://buildstats.info/nuget/RuAnnoy-Batteries-Darwin-x64)](https://www.nuget.org/packages/RuAnnoy-Batteries-Darwin-x64)   |\n\n#### Install via nuget\n\n```xml\n  \u003cItemGroup\u003e\n    \u003cPackageReference Include=\"RuAnnoy\" Version=\"*\" /\u003e\n    \u003cPackageReference Include=\"RuAnnoy-Batteries-Windows-x64\" Version=\"*\" /\u003e\n  \u003c/ItemGroup\u003e\n```\n\n#### Usage\n\n```csharp\nvar index = AnnoyIndex.Load(\"index.5d.ann\", 5, IndexType.Angular);\n```\n\n### dart\n\n#### Install via [pub.dev](https://pub.dev/packages/dart_native_annoy)\n\n```yaml\n# pubspec.yaml\ndependencies:\n  dart_native_annoy: ^0.1.0\n```\n\n#### Usage\n\n```dart\nimport 'dart:ffi';\nimport 'package:dart_native_annoy/annoy.dart';\n\n/// Creat factory from DynamicLibrary\nfinal indexFactory = AnnoyIndexFactory(lib: DynamicLibrary.open('libannoy_rs_ffi.so'));\n\n/// Load index\nfinal index = indexFactory.loadIndex(\n      'index.euclidean.5d.ann', 5, IndexType.Euclidean)!;\n\nprint('size: ${index.size}');\n\nfinal v3 = index.getItemVector(3);\n\nfinal nearest = index.getNearest(v0, 5, includeDistance: true);\n```\n\n## TODO\n\n- Index building support\n- CLI tool to build index from file\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanabi1224%2Fruannoy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanabi1224%2Fruannoy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanabi1224%2Fruannoy/lists"}