spotify / annoy-java

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

move zero vector check #5

Closed rohanag closed 8 years ago

a1k0n commented 8 years ago

LGTM, looks like a bugfix to me.

rohanag commented 8 years ago

yeah, the zero vector check was in the wrong place, causing many good tree paths to be neglected during tree traversal.

rohanag commented 8 years ago

The funny thing is, the bug affected some trees more than others, for e.g. results on the tree in the test case are unaffected by this fix. I'm not exactly sure why, and what the memory location at topNodeOffset is supposed to contain when the node being traversed has more than MIN_LEAF_SIZE descendants.