#最近邻搜索 #索引 #annoy #端口 #服务 #GitHub #API

ru_annoy

annoy(https://github.com/spotify/annoy)的Rust实现(仅支持索引服务)。同时提供C API

4个版本

0.1.3 2021年3月4日
0.1.2 2021年3月1日
0.1.1 2021年2月27日
0.1.0-dev12019年5月9日

算法中排名第886

MIT许可证

57KB
856

RuAnnoy

main appveyor travis MIT License

这个库是spotify/annoy的Rust版本,目前仅支持索引服务。

通过crates.io安装

Crates.io codecov

# Cargo.toml
[dependencies]
ru_annoy = "0"

用法

use ru_annoy::*;

let index = AnnoyIndex::load(10, "index.ann", IndexType::Angular).unwrap();
let v0 = index.get_item_vector(0);
let nearest = index.get_nearest(v0.as_ref(), 5, -1, true);

FFI支持

kotlin/java

它使用JNI绑定到Rust crate,在基准测试场景中比纯Java实现快约5-10倍

通过jitpack.io安装

Release

repositories {
  mavenCentral()
  maven { url 'https://jitpack.io' }
}
  
dependencies {
  implementation 'com.github.hanabi1224:RuAnnoy:<tag>'
}

用法

val index = AnnoyIndex.tryLoad("index.5d.ann", 5, IndexType.Angular)

dotnet

运行时 Nuget包
RuAnnoy NuGet version
RuAnnoy-Batteries-Windows-x64 NuGet version
RuAnnoy-Batteries-Linux-x64 NuGet version
RuAnnoy-Batteries-Darwin-x64 NuGet version

通过nuget安装

  <ItemGroup>
    <PackageReference Include="RuAnnoy" Version="*" />
    <PackageReference Include="RuAnnoy-Batteries-Windows-x64" Version="*" />
  </ItemGroup>

用法

var index = AnnoyIndex.Load("index.5d.ann", 5, IndexType.Angular);

待办事项

  • 索引构建支持
  • 从文件构建索引的CLI工具

依赖项

~2MB
~29K SLoC