npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hanabi1224/annoy-rs

v0.1.0

Published

A rust implementation of annoy(https://github.com/spotify/annoy) (Index serving only). C ABI is also provided.

Downloads

2

Readme

RuAnnoy

main MIT License

This library is a rust port of spotify/annoy , currently only index serving is supported.

A live demo using web assembly is available at https://annoy-web-demo.vercel.app/

It also provides FFI bindings for jvm, dotnet and dart

| Metric | Serve | Build | jvm binding | dotnet binding | dart binding | WASM support | | :-------- | :---: | ----: | ----------- | -------------- | ------------ | ------------ | | Angular | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | | Euclidean | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | | Manhattan | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | | Dot | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | | Hamming | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |

Install via crates.io

Crates.io codecov dependency status

# Cargo.toml
[dependencies]
annoy-rs = "0.1"

Usage

use annoy_rs::*;

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);

SIMD support

SIMD is supported via std::simd on nightly rust. Note that avx intrinsics need to be enabled explicitly by setting your cpu features in RUSTFLAGS environment variable.

RUSTFLAGS="-Ctarget-feature=+avx" cargo +nightly build --release
# or
RUSTFLAGS="-Ctarget-cpu=native" cargo +nightly build --release

WASM support

Install wasm-pack

wasm-pack build
wasm-pack test --node

simd128 is supported in chrome by default.

To enable simd128, build with below command

RUSTFLAGS="-Ctarget-feature=+simd128" cargo +nightly build --release --target wasm32-unknown-unknown

An example site is deployed at https://annoy-web-demo.vercel.app/

Source code is under example/web

FFI support

kotlin/java

It uses JNI bindings to rust crate and is ~5-10x faster than pure java implementation in benchmark scenario

Note that the prebuilt dynamically linked libraries are built with simd support, avx cpu feature is required.

Install via jitpack.io

Release

repositories {
  mavenCentral()
  maven { url 'https://jitpack.io' }
}

dependencies {
  implementation 'com.github.hanabi1224:RuAnnoy:<tag>'
}

Usage

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

dotnet

| Runtimes | Nuget package | | ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | RuAnnoy | NuGet version | | RuAnnoy-Batteries-Windows-x64 | NuGet version | | RuAnnoy-Batteries-Linux-x64 | NuGet version | | RuAnnoy-Batteries-Darwin-x64 | NuGet version |

Install via nuget

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

Usage

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

dart

Install via pub.dev

# pubspec.yaml
dependencies:
  dart_native_annoy: ^0.1.0

Usage

import 'dart:ffi';
import 'package:dart_native_annoy/annoy.dart';

/// Creat factory from DynamicLibrary
final indexFactory = AnnoyIndexFactory(lib: DynamicLibrary.open('libannoy_rs_ffi.so'));

/// Load index
final index = indexFactory.loadIndex(
      'index.euclidean.5d.ann', 5, IndexType.Euclidean)!;

print('size: ${index.size}');

final v3 = index.getItemVector(3);

final nearest = index.getNearest(v0, 5, includeDistance: true);

TODO

  • Index building support
  • CLI tool to build index from file