Class DNN_euclidean_neighbors
java.lang.Object
io.nosqlbench.virtdata.lib.vectors.dnn.euclidean.DNN_euclidean_neighbors
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint[]apply(int value) Compute neighbor indices with a (hopefully) fast implementation.
-
Constructor Details
-
DNN_euclidean_neighbors
public DNN_euclidean_neighbors(int k, int N, int D) - Parameters:
k- The size of neighborhoodN- The number of total vectors, necessary for boundary conditions of defined vectorD- 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:
- Determine the sections of the neighborhood which aren't subject to boundary conditions, starting at the central vector (the index of the query vector).
- Layer these in rank order using closed-form index functions.
- Layer in any zero-boundary values which were deferred from above.
- 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:
applyin interfaceIntFunction<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
-