@Beta public interface KnnResults extends NnResults
0
to NnResults.getQueryCount()
-1
. For at least one neighbor index
(NnResults.getMostSimilarNeighbor(int)
) with a dissimilarity value (NnResults.getMostSimilarDissimilarity(int)
) is
stored. Interpretation of the query and target indices is implementation dependent. Note that some search
implementation might accept dissimilarity threshold values which might result in no hits for certain queries. Such
queries are not represented by an instance of this interface and the index mapping must be provided outside.
Note that the stored neighbor count might not be constant for implementations providing such thresholds.
This result object holds ordered target-query-dissimilarity triplets. Self and inter-set nearest neighbor list can be represented by this type. When self knn is represented reference to the actual query is not part of the resulted nearest neighbor lists.
Modifier and Type | Method and Description |
---|---|
int |
copyNeighborsTo(int queryIndex,
int[] neighbors,
double[] dissimilarities)
Copy neighbor data to an allocated array.
|
int |
getAllNeighborCount()
All stored neighbor count.
|
double[] |
getDissimilarities(int queryIndex)
Dissimilarity.
|
double |
getDissimilarity(int queryIndex,
int neighborIndex)
Dissimilarity of a single neighbor.
|
int |
getK()
Deprecated.
|
int |
getMaxNeighborCount()
Maximal neighbor count represented.
|
int |
getMinNeighborCount()
Minimal neighbor count represented.
|
int |
getNeighbor(int queryIndex,
int neighborIndex)
Index of a single neighbor.
|
int[] |
getNeighborCountsOfAll()
Neighbor count of all queries.
|
double |
getNeighborDissimilaritiesMissingValue()
Missing value for results of
getNthNeighborDissimilaritiesOfAll(int) . |
int[] |
getNeighbors(int queryIndex)
ID of the nearest neighbors of query.
|
double[] |
getNthNeighborDissimilaritiesOfAll(int neighborIndex)
Get
n -th neighbor dissimilarities for all queries. |
int[] |
getNthNeighborIdsOfAll(int neighborIndex)
Get
n -th neighbor indices for all queries. |
getMaxDissimilarity, getMaxNeighborIndex, getMinDissimilarity, getMinNeighborIndex, getMostSimilarDissimilarity, getMostSimilarNeighbor, getQueryCount
@Deprecated int getK()
getMinNeighborCount()
and getMaxNeighborCount()
int getMaxNeighborCount()
int getMinNeighborCount()
int getAllNeighborCount()
int[] getNeighbors(int queryIndex)
NnResults.getMinNeighborIndex()
and NnResults.getMaxNeighborIndex()
are valid for all neighbors.
First element of the returned list is the same as NnResults.getMostSimilarNeighbor(int)
. The length of the list
might vary from query to query, but is non-empty and no longer than the value of getK()
. The length of
the list is the same as the length of getDissimilarities(int)
.
queryIndex
- Indexint[] getNeighborCountsOfAll()
int getNeighbor(int queryIndex, int neighborIndex)
queryIndex
- QueryneighborIndex
- Neighbor indexint[] getNthNeighborIdsOfAll(int neighborIndex)
n
-th neighbor indices for all queries.neighborIndex
- 0-based neigbbor indexIllegalArgumentException
- when neighborIndex
is less than 0 or more or equal to the
getMaxNeighborCount()
double[] getDissimilarities(int queryIndex)
NnResults.getMinDissimilarity()
and NnResults.getMaxDissimilarity()
are valid for all neighbors.
First element of the returned list is the same as NnResults.getMostSimilarDissimilarity(int)
. The length of the
list might vary from query to query, but is non-empty and no longer than the value of getK()
. The length
of the list is the same as the length of getNeighbors(int)
.
queryIndex
- Index of querydouble getDissimilarity(int queryIndex, int neighborIndex)
queryIndex
- QueryneighborIndex
- Neighbor indexgetNeighborDissimilaritiesMissingValue()
double getNeighborDissimilaritiesMissingValue()
getNthNeighborDissimilaritiesOfAll(int)
.double[] getNthNeighborDissimilaritiesOfAll(int neighborIndex)
n
-th neighbor dissimilarities for all queries.neighborIndex
- 0-based neigbbor indexgetNeighborDissimilaritiesMissingValue()
when
given neighbor is not presentIllegalArgumentException
- when neighborIndex
is less than 0int copyNeighborsTo(int queryIndex, int[] neighbors, double[] dissimilarities)
queryIndex
- Query indexneighbors
- Array to copy neighbor indicesdissimilarities
- Array to copy dissimilaritiesIllegalArgumentException
- when array size is small to store neighbor data