Closed micycle1 closed 7 months ago
It depends on the index you are using.
Most indexes now use incremental NN search, i.e. you can safely set k=Integer.MAX_VALUE
without risking long initialization times or memory exhaustion.
I think the only exception is the CoverTree which will internally first collect all candidates before returning an interator on the internal list.
The KDTree has two different NN search implementations. The default implementation queryKnn()
works incrementally and can use k=Integer.MAX_VALUE
. The old knnQuery()
methods works differently and will first allocate a list of all results (sorry about those method names).
Note: I haven't actually tried setting k=Integer.MAX_VALUE
but it should work fine for all except CoverTree
(and Array
but that should anyway not be used).
I'm most concerned with KDTree, so that's good to hear. Thanks.
Maybe worth clarifying this (particularly the cover tree exception) in Javadocs.
Maybe worth clarifying this (particularly the cover tree exception) in Javadocs.
Yes, that makes sense.
Can Tinspin support an indefinite nearest neighbor search, where I can iteratively query for the next nearest neighbor without a predetermined 'k' value?
Is it possible to simulate this by setting k to something like
Integer.MAX_VALUE
, or does Tinspin first search for and gather all points AND THEN provide an iterator on these, which would be less efficient?