Skip to content

TrainHead-software/annoy.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Annoy.NET

Annoy.NET is a C# Wrapper for Spotify's Annoy, it can be used either with Unity or your C# based Application.

Unity Integration

  1. Drag & Drop annoy.net.unitypackage into unity editor
  2. Profit!

Usage

using System;  
using UnityEngine;  
using AnnoyWrapper;  
  
public class Test : MonoBehaviour  
{  
    void Start()  
    {
        IntPtr index = Annoy.Index(512, AnnoyMetric.Angular);  
        Annoy.AddItem(index, 0, new float[512]);  
        Annoy.AddItem(index, 1, new float[512]);  
        Annoy.AddItem(index, 2, new float[512]);  
        Annoy.Build(index, 10);  
        Debug.Log(Annoy.GetNItems(index)); // 3  
        Annoy.Free(index);  
    }}

Setup & Build Instructions

  1. Clone this repository
git clone https://github.com/TrainHead-software/annoy.net.git
cd annoy.net
  1. Clone the Annoy source inside project folder
git clone https://github.com/spotify/annoy.git annoy
  1. Build the native library using CMake (works on Windows, Linux, and other platforms):
cmake -S annoy_clang -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

On Linux this generates libannoy_c.so, while on Windows it produces annoy_c.dll.

TODO

  • Metric_Hamming: add support to C-wrapper and P/Invoke.
  • Cross-platform compatibility: builds for macOS (.dylib)

License

This project includes and wraps Spotify Annoy, a C++ library for approximate nearest neighbors.