V
- the type of FeatureVector handled by this AlgorithmD
- the type of Distance used by this AlgorithmN
- the type of node used in the spatial index structureE
- the type of entry used in the spatial node@Title(value="K-Nearest Neighbor Join") @Description(value="Algorithm to find the k-nearest neighbors of each object in a spatial database") public class KNNJoin<V extends NumberVector<V,?>,D extends Distance<D>,N extends SpatialNode<N,E>,E extends SpatialEntry> extends AbstractDistanceBasedAlgorithm<V,D,DataStore<KNNList<D>>>
Modifier and Type | Class and Description |
---|---|
static class |
KNNJoin.Parameterizer<V extends NumberVector<V,?>,D extends Distance<D>,N extends SpatialNode<N,E>,E extends SpatialEntry>
Parameterization class.
|
Modifier and Type | Field and Description |
---|---|
(package private) int |
k
The k parameter
|
static OptionID |
K_ID
Parameter that specifies the k-nearest neighbors to be assigned, must be an
integer greater than 0.
|
private static Logging |
logger
The logger for this class.
|
DISTANCE_FUNCTION_ID
Constructor and Description |
---|
KNNJoin(DistanceFunction<? super V,D> distanceFunction,
int k)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
TypeInformation[] |
getInputTypeRestriction()
Get the input type restriction used for negotiating the data query.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
private D |
processDataPages(DistanceQuery<V,D> distQ,
N pr,
N ps,
WritableDataStore<KNNHeap<D>> knnLists,
D pr_knn_distance)
Processes the two data pages pr and ps and determines the k-nearest
neighbors of pr in ps.
|
DataStore<KNNList<D>> |
run(Database database,
Relation<V> relation)
Joins in the given spatial database to each object its k-nearest neighbors.
|
getDistanceFunction
makeParameterDistanceFunction, run
private static final Logging logger
public static final OptionID K_ID
int k
public KNNJoin(DistanceFunction<? super V,D> distanceFunction, int k)
distanceFunction
- Distance functionk
- k parameterpublic DataStore<KNNList<D>> run(Database database, Relation<V> relation) throws IllegalStateException
IllegalStateException
- if not suitable SpatialIndexTree
was
found or the specified distance function is not an instance of
SpatialPrimitiveDistanceFunction
.private D processDataPages(DistanceQuery<V,D> distQ, N pr, N ps, WritableDataStore<KNNHeap<D>> knnLists, D pr_knn_distance)
distQ
- the distance to usepr
- the first data pageps
- the second data pageknnLists
- the knn lists for each data objectpr_knn_distance
- the current knn distance of data page prpublic TypeInformation[] getInputTypeRestriction()
AbstractAlgorithm
getInputTypeRestriction
in interface Algorithm
getInputTypeRestriction
in class AbstractAlgorithm<DataStore<KNNList<D extends Distance<D>>>>
protected Logging getLogger()
AbstractAlgorithm