dart_native_annoy

Main

Annoy (Approximate Nearest Neighbors Oh Yeah)

This is a dart binding to rust annoy

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

/// Creat factory from DynamicLibrary
final fac = AnnoyIndexFactory(lib: DynamicLibrary.open('libru_annoy.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);

To get more examples

Go to unit test

To run unit tests

pub get && dart run test

To build native lib (libru_annoy.so)

install rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

go to RuAnnoy directory, run

cargo build --release --all-features

to cross compile to different target

cargo lipo --release --targets=aarch64-apple-ios,x86_64-apple-ios,armv7-apple-ios,armv7s-apple-ios
cargo build --target aarch64-linux-android --release
cargo build --target armv7-linux-androideabi --release
cargo build --target i686-linux-android --release

The shared library will be under target/release . It would be libru_annoy.so, ru_annoy.dll, libru_annoy.dylib on linux, windows, osx respectively.

Libraries

annoy
native_array_utils