Brute force linear nearest neighbor search. This simplest solution computes
the distance from the query point to every other point in the database,
keeping track of the "best so far". There are no search data structures to
maintain, so linear search has no space complexity beyond the storage of
the database. Although it is very simple, naive search outperforms space
partitioning approaches (e.g. K-D trees) on higher dimensional spaces.
By default, the query object (reference equality) is excluded from the neighborhood.
Note that you may observe weird behavior with String objects. JVM will pool the string
literal objects. So the below variables
String a = "ABC";
String b = "ABC";
String c = "AB" + "C";
are actually equal in reference test a == b == c. With toy data that you
type explicitly in the code, this will cause problems. Fortunately, the data would be
read from secondary storage in production.