dart_native_annoy 0.1.0+1 copy "dart_native_annoy: ^0.1.0+1" to clipboard
dart_native_annoy: ^0.1.0+1 copied to clipboard

A dart binding to native annoy library to serve pre-built Annoy index.

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.

1
likes
140
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

A dart binding to native annoy library to serve pre-built Annoy index.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

ffi

More

Packages that depend on dart_native_annoy