Class DNN_euclidean_neighbors

java.lang.Object
io.nosqlbench.virtdata.lib.vectors.dnn.euclidean.DNN_euclidean_neighbors
All Implemented Interfaces:
IntFunction<int[]>

public class DNN_euclidean_neighbors extends Object implements IntFunction<int[]>
Compute the indices of the neighbors of a given v using DNN mapping. To avoid ambiguity on equidistant neighbors, odd neighborhood sizes are preferred.
  • Constructor Details

    • DNN_euclidean_neighbors

      public DNN_euclidean_neighbors(int k, int N, int D)
      Parameters:
      k - The size of neighborhood
      N - The number of total vectors, necessary for boundary conditions of defined vector
      D - Number of dimensions in each vector
  • Method Details

    • apply

      public int[] apply(int value)

      Compute neighbor indices with a (hopefully) fast implementation. There are surely some simplifications to be made in the functions below, but even in the current form it avoids a significant number of branches.

      This code is not as simple as it could be. It was built more for speed than simplicity since it will be a hot spot for testing. The unit tests for this are essential.

      The method is thus:

      1. Determine the sections of the neighborhood which aren't subject to boundary conditions, starting at the central vector (the index of the query vector).
      2. Layer these in rank order using closed-form index functions.
      3. Layer in any zero-boundary values which were deferred from above.
      4. Layer in an N-boundary values which were deferred from above.

      The boundary conditions for zero and N are mutually exclusive. Even though there is some amount of ranging and book keeping in this approach, it should make the general case more stable, especially when there are many dimensions and many neighbors.

      Specified by:
      apply in interface IntFunction<int[]>
      Parameters:
      value - the function argument, or the index of the query vector for the DNN addressing scheme
      Returns:
      A ranked neighborhood of vector indices, using the DNN addressing scheme