spotify / annoy-java

Approximate nearest neighbors in Java
Apache License 2.0
138 stars 46 forks source link

No check for metric value #14

Open sstolpovskiy opened 6 years ago

sstolpovskiy commented 6 years ago

Hello,

I have faced the issue:

  1. index is created using default metric in python.
  2. index is read in java with Euclidean metric without error.

On search raised following error: java.lang.ArrayIndexOutOfBoundsException: 2820 at com.spotify.annoy.ANNIndex.getIntInAnnBuf(ANNIndex.java:133) ~[annoy-0.2.6-SNAPSHOT.jar:na] at com.spotify.annoy.ANNIndex.getNearest(ANNIndex.java:257) ~[annoy-0.2.6-SNAPSHOT.jar:na]

Where 2820 number depend so how on index size.

I think it should be some check for valid metric.