0 purchases
dart native annoy
dart_native_annoy #
#
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);
copied to clipboard
To get more examples
Go to unit test
To run unit tests #
pub get && dart run test
copied to clipboard
To build native lib (libru_annoy.so) #
install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
copied to clipboard
go to RuAnnoy directory, run
cargo build --release --all-features
copied to clipboard
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
copied to clipboard
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.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.