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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8108550b7970bce06a297ee075182f286e451e902ade1254a1c095f05b53d2b
4
- data.tar.gz: e35e6b247dfec3b21341339a56039ae63267c133ba53f4d6d3004f9acce90d67
3
+ metadata.gz: 26a73345b4bb8bb29cbfc836599215b38dfa2e61f53bcf8183978802dbafbadc
4
+ data.tar.gz: fdf69a4b34bd4c1a06cab5a68c54de13ac7a521c079ff9526981c8b13056373b
5
5
  SHA512:
6
- metadata.gz: 60fc9c1c02215333eb63b8a6cc2c1228bf97da7da444ea5ba9b930f756ed5f4363f336b96332034d4f391f18e999dbb21c8e2df0dd6bb00a7491ea257d39a2ac
7
- data.tar.gz: dd63d425a08a94a102e7731c040563a2f788e284b671babb0d9683275c9affcc2119eeb89968f699f642ad8203230e7b821b49ca88a03c9963be9ea66d95b893
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
- # Annoy.rb
1
+ # annoy-rb
2
2
 
3
- [![Build Status](https://github.com/yoshoku/annoy.rb/workflows/build/badge.svg)](https://github.com/yoshoku/annoy.rb/actions?query=workflow%3Abuild)
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.rb/blob/main/LICENSE.txt)
6
- [![Documentation](http://img.shields.io/badge/api-reference-blue.svg)](https://yoshoku.github.io/annoy.rb/doc/)
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
- Annoy.rb provides Ruby bindings for the [Annoy (Approximate Nearest Neighbors Oh Yeah)](https://github.com/spotify/annoy).
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: Annoy.rb does not require the installation of another external library.
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
- * [Annoy.rb API Documentation](https://yoshoku.github.io/annoy.rb/doc/)
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.rb.
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 [code of conduct](https://github.com/yoshoku/annoy.rb/blob/main/CODE_OF_CONDUCT.md).
86
+ and contributors are expected to adhere to the [Contributor Covenant](https://contributor-covenant.org) code of conduct.
@@ -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, double>::define_class(rb_mAnnoy, "AnnoyIndexAngular");
26
- RbAnnoyIndex<AnnoyIndexDotProduct, double>::define_class(rb_mAnnoy, "AnnoyIndexDotProduct");
27
- RbAnnoyIndex<AnnoyIndexHamming, uint64_t>::define_class(rb_mAnnoy, "AnnoyIndexHamming");
28
- RbAnnoyIndex<AnnoyIndexEuclidean, double>::define_class(rb_mAnnoy, "AnnoyIndexEuclidean");
29
- RbAnnoyIndex<AnnoyIndexManhattan, double>::define_class(rb_mAnnoy, "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
  }