annoy-rb 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +34 -9
- data/ext/annoy/annoyext.cpp +12 -9
- data/ext/annoy/annoyext.hpp +290 -284
- data/ext/annoy/src/LICENSE +1 -1
- data/ext/annoy/src/annoylib.h +75 -59
- data/ext/annoy/src/kissrandom.h +19 -5
- data/lib/annoy/version.rb +2 -2
- data/lib/annoy-rb.rb +3 -0
- data/lib/annoy.rb +16 -5
- data/sig/annoy.rbs +75 -1
- metadata +10 -16
- data/.github/workflows/build.yml +0 -20
- data/.gitignore +0 -21
- data/.rspec +0 -3
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -10
- data/Rakefile +0 -15
- data/Steepfile +0 -20
- data/annoy-rb.gemspec +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a73345b4bb8bb29cbfc836599215b38dfa2e61f53bcf8183978802dbafbadc
|
4
|
+
data.tar.gz: fdf69a4b34bd4c1a06cab5a68c54de13ac7a521c079ff9526981c8b13056373b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7999995d341e22f10ce89c645b5eaa2a7911812a03e3c04291c28e120bfcec27397930815b8491854a2f65577804a8b7fb50ac6bb7eaba2d7cc1d780c90df711
|
7
|
+
data.tar.gz: b58d1820ce6a48d7bae526afccaefe16770091c9b84b00679517ffeabfde16df5cd70ababc751037b54c3f04a064131614edb852d9c8298a756efa6fc09592e3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
## 0.7.0
|
2
|
+
|
3
|
+
- Update bundled Annoy version to 1.17.1.
|
4
|
+
- Refactor config files.
|
5
|
+
|
6
|
+
## 0.6.1
|
7
|
+
|
8
|
+
- Refactor codes and configs with RuboCop and clang-format.
|
9
|
+
|
10
|
+
## 0.6.0
|
11
|
+
- Add `dtype` argument to initialize method to specify the data type of vector element.
|
12
|
+
If you want to load a search index created with the Python bindings, specify 'float32' to the dtype argument.
|
13
|
+
|
14
|
+
```
|
15
|
+
require 'annoy'
|
16
|
+
|
17
|
+
f = 40
|
18
|
+
t = Annoy::AnnoyIndex.new(n_features: f, metric: 'angular', dtype: 'float32')
|
19
|
+
t.load('index_with_python_bindings.ann')
|
20
|
+
```
|
21
|
+
|
22
|
+
- Change the data type of item index from int to int32_t.
|
23
|
+
- Update type declarations and documentations.
|
24
|
+
- Introduce conventional commits.
|
25
|
+
|
1
26
|
## 0.5.0
|
2
27
|
### Breaking change
|
3
28
|
- Remove `-march=native` and `-DANNOYLIB_MULTITHREADED_BUILD` from CXXFLAGS.
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# annoy-rb
|
2
2
|
|
3
|
-
[![Build Status](https://github.com/yoshoku/annoy
|
3
|
+
[![Build Status](https://github.com/yoshoku/annoy-rb/workflows/build/badge.svg)](https://github.com/yoshoku/annoy-rb/actions?query=workflow%3Abuild)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/annoy-rb.svg)](https://badge.fury.io/rb/annoy-rb)
|
5
|
-
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://github.com/yoshoku/annoy
|
6
|
-
[![Documentation](
|
5
|
+
[![License](https://img.shields.io/badge/License-Apache%202.0-yellowgreen.svg)](https://github.com/yoshoku/annoy-rb/blob/main/LICENSE.txt)
|
6
|
+
[![Documentation](https://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/annoy-rb/doc/)
|
7
7
|
|
8
|
-
|
8
|
+
annoy-rb provides Ruby bindings for the [Annoy (Approximate Nearest Neighbors Oh Yeah)](https://github.com/spotify/annoy).
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -23,11 +23,24 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
$ gem install annoy-rb
|
25
25
|
|
26
|
-
Note:
|
26
|
+
Note: annoy-rb does not require the installation of another external library.
|
27
|
+
In addition, annoy-rb does not give any optimization options when building native extensions.
|
28
|
+
If necessary, add optimization options yourself during installation, as follows;
|
29
|
+
|
30
|
+
```
|
31
|
+
$ bundle config --local build.annoy-rb "--with-cxxflags=-march=native"
|
32
|
+
$ bundle install
|
33
|
+
```
|
34
|
+
|
35
|
+
Or:
|
36
|
+
|
37
|
+
```
|
38
|
+
$ gem install annoy-rb -- --with-cxxflags=-march=native
|
39
|
+
```
|
27
40
|
|
28
41
|
## Documentation
|
29
42
|
|
30
|
-
* [
|
43
|
+
* [annoy-rb API Documentation](https://yoshoku.github.io/annoy-rb/doc/)
|
31
44
|
|
32
45
|
## Usage
|
33
46
|
|
@@ -50,12 +63,24 @@ u.load('test.ann')
|
|
50
63
|
p u.get_nns_by_item(0, 100) # will find the 100 nearest neighbors.
|
51
64
|
```
|
52
65
|
|
66
|
+
With the default argument, annoy-rb uses double precision floating point type for the data type of vector element.
|
67
|
+
On the other hand, the [Python bindings of Annoy](https://pypi.org/project/annoy/) use single precision floating point type.
|
68
|
+
If you want to load a search index created with the Python bindings, specify 'float32' to the dtype argument.
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
require 'annoy'
|
72
|
+
|
73
|
+
f = 40
|
74
|
+
t = Annoy::AnnoyIndex.new(n_features: f, metric: 'angular', dtype: 'float32')
|
75
|
+
t.load('index_with_python_bindings.ann')
|
76
|
+
```
|
77
|
+
|
53
78
|
## License
|
54
79
|
|
55
80
|
The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
|
56
81
|
|
57
82
|
## Contributing
|
58
83
|
|
59
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/annoy
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/annoy-rb.
|
60
85
|
This project is intended to be a safe, welcoming space for collaboration,
|
61
|
-
and contributors are expected to adhere to the [
|
86
|
+
and contributors are expected to adhere to the [Contributor Covenant](https://contributor-covenant.org) code of conduct.
|
data/ext/annoy/annoyext.cpp
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Annoy.rb is a Ruby binding for the Annoy (Approximate Nearest Neighbors Oh Yeah).
|
3
3
|
*
|
4
|
-
* Copyright (c) 2020 Atsushi Tatsuma
|
4
|
+
* Copyright (c) 2020-2022 Atsushi Tatsuma
|
5
5
|
*
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
* you may not use this file except in compliance with the License.
|
@@ -18,13 +18,16 @@
|
|
18
18
|
|
19
19
|
#include "annoyext.hpp"
|
20
20
|
|
21
|
-
extern "C"
|
22
|
-
void Init_annoyext(void)
|
23
|
-
{
|
21
|
+
extern "C" void Init_annoyext(void) {
|
24
22
|
VALUE rb_mAnnoy = rb_define_module("Annoy");
|
25
|
-
RbAnnoyIndex<AnnoyIndexAngular
|
26
|
-
RbAnnoyIndex<AnnoyIndexDotProduct
|
27
|
-
RbAnnoyIndex<AnnoyIndexHamming
|
28
|
-
RbAnnoyIndex<AnnoyIndexEuclidean
|
29
|
-
RbAnnoyIndex<AnnoyIndexManhattan
|
23
|
+
RbAnnoyIndex<AnnoyIndexAngular<double>, double>::define_class(rb_mAnnoy, "AnnoyIndexAngular");
|
24
|
+
RbAnnoyIndex<AnnoyIndexDotProduct<double>, double>::define_class(rb_mAnnoy, "AnnoyIndexDotProduct");
|
25
|
+
RbAnnoyIndex<AnnoyIndexHamming<uint64_t>, uint64_t>::define_class(rb_mAnnoy, "AnnoyIndexHamming");
|
26
|
+
RbAnnoyIndex<AnnoyIndexEuclidean<double>, double>::define_class(rb_mAnnoy, "AnnoyIndexEuclidean");
|
27
|
+
RbAnnoyIndex<AnnoyIndexManhattan<double>, double>::define_class(rb_mAnnoy, "AnnoyIndexManhattan");
|
28
|
+
|
29
|
+
RbAnnoyIndex<AnnoyIndexAngular<float>, float>::define_class(rb_mAnnoy, "AnnoyIndexAngularFloat32");
|
30
|
+
RbAnnoyIndex<AnnoyIndexDotProduct<float>, float>::define_class(rb_mAnnoy, "AnnoyIndexDotProductFloat32");
|
31
|
+
RbAnnoyIndex<AnnoyIndexEuclidean<float>, float>::define_class(rb_mAnnoy, "AnnoyIndexEuclideanFloat32");
|
32
|
+
RbAnnoyIndex<AnnoyIndexManhattan<float>, float>::define_class(rb_mAnnoy, "AnnoyIndexManhattanFloat32");
|
30
33
|
}
|