@Beta public final class FixedKnnResultsImpl extends Object implements KnnResults
KnnResults.
Note that query and target IDs might refer to the same or different sets. If they refer to the same set the nearest neighbor list does not contain self ID.
| Constructor and Description |
|---|
FixedKnnResultsImpl(int k,
int queryCount,
int[] targets,
double[] dissimilarities)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
int |
copyNeighborsTo(int queryIndex,
int[] neighbors,
double[] dissimilarities)
Copy neighbor data to an allocated array.
|
void |
copyTo(int k,
int startQueryIndex,
int[] t,
double[] d)
Low level array copy to target arrays.
|
int |
getAllNeighborCount()
All stored neighbor count.
|
double[] |
getDissimilarities(int index)
Dissimilarity.
|
double |
getDissimilarity(int queryIndex,
int neighborIndex)
Dissimilarity of a single neighbor.
|
int |
getK()
Value of k.
|
double |
getMaxDissimilarity()
Upper bound of dissimilarity values.
|
int |
getMaxNeighborCount()
Maximal neighbor count represented.
|
int |
getMaxNeighborIndex()
Upper bound of neighbor index values.
|
double |
getMinDissimilarity()
Lower bound of dissimilarity values.
|
int |
getMinNeighborCount()
Minimal neighbor count represented.
|
int |
getMinNeighborIndex()
Lower bound of neighbor index values.
|
double |
getMostSimilarDissimilarity(int queryIndex)
Dissimilarity of the most similar neighbor.
|
int |
getMostSimilarNeighbor(int queryIndex)
Index of most similar neighbor.
|
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
KnnResults.getNthNeighborDissimilaritiesOfAll(int). |
int[] |
getNeighbors(int index)
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. |
int |
getQueryCount()
Number of queries stored.
|
String |
toString() |
public FixedKnnResultsImpl(int k,
int queryCount,
int[] targets,
double[] dissimilarities)
k - Number of nearest neighbors recorded for each queryqueryCount - Query counttargets - Concatenated lists of nearest neighbors for each querydissimilarities - DissimilaritiesIllegalArgumentException - when array sizes mismatch or dissimilarities array contains NaN or INF valuepublic int getK()
KnnResultsgetK in interface KnnResultspublic int getMinNeighborCount()
KnnResultsgetMinNeighborCount in interface KnnResultspublic int getMaxNeighborCount()
KnnResultsgetMaxNeighborCount in interface KnnResultspublic int getAllNeighborCount()
KnnResultsgetAllNeighborCount in interface KnnResultspublic int getQueryCount()
NnResultsgetQueryCount in interface NnResultspublic int[] getNeighbors(int index)
KnnResultsNnResults.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 KnnResults.getK(). The length of
the list is the same as the length of KnnResults.getDissimilarities(int).
getNeighbors in interface KnnResultsindex - Indexpublic double[] getDissimilarities(int index)
KnnResultsNnResults.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 KnnResults.getK(). The length
of the list is the same as the length of KnnResults.getNeighbors(int).
getDissimilarities in interface KnnResultsindex - Index of querypublic void copyTo(int k,
int startQueryIndex,
int[] t,
double[] d)
k - Target kstartQueryIndex - First query index to writet - concatenated knn listsd - dissimilaritiesIllegalArgumentException - when trivial consistency checks failpublic int copyNeighborsTo(int queryIndex,
int[] neighbors,
double[] dissimilarities)
KnnResultscopyNeighborsTo in interface KnnResultsqueryIndex - Query indexneighbors - Array to copy neighbor indicesdissimilarities - Array to copy dissimilaritiespublic int getMinNeighborIndex()
NnResultsgetMinNeighborIndex in interface NnResultspublic int getMaxNeighborIndex()
NnResultsgetMaxNeighborIndex in interface NnResultspublic double getMinDissimilarity()
NnResultsgetMinDissimilarity in interface NnResultspublic double getMaxDissimilarity()
NnResultsgetMaxDissimilarity in interface NnResultspublic int getMostSimilarNeighbor(int queryIndex)
NnResultsgetMostSimilarNeighbor in interface NnResultsqueryIndex - Index of querypublic double getMostSimilarDissimilarity(int queryIndex)
NnResultsgetMostSimilarDissimilarity in interface NnResultsqueryIndex - Index of querypublic int[] getNeighborCountsOfAll()
KnnResultsgetNeighborCountsOfAll in interface KnnResultspublic int getNeighbor(int queryIndex,
int neighborIndex)
KnnResultsgetNeighbor in interface KnnResultsqueryIndex - QueryneighborIndex - Neighbor indexpublic int[] getNthNeighborIdsOfAll(int neighborIndex)
KnnResultsn-th neighbor indices for all queries.getNthNeighborIdsOfAll in interface KnnResultsneighborIndex - 0-based neigbbor indexpublic double getDissimilarity(int queryIndex,
int neighborIndex)
KnnResultsgetDissimilarity in interface KnnResultsqueryIndex - QueryneighborIndex - Neighbor indexKnnResults.getNeighborDissimilaritiesMissingValue()public double getNeighborDissimilaritiesMissingValue()
KnnResultsKnnResults.getNthNeighborDissimilaritiesOfAll(int).getNeighborDissimilaritiesMissingValue in interface KnnResultspublic double[] getNthNeighborDissimilaritiesOfAll(int neighborIndex)
KnnResultsn-th neighbor dissimilarities for all queries.getNthNeighborDissimilaritiesOfAll in interface KnnResultsneighborIndex - 0-based neigbbor indexKnnResults.getNeighborDissimilaritiesMissingValue() when
given neighbor is not present