V
- the type of FeatureVector handled 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") @Priority(value=-10) public class KNNJoin<V extends NumberVector,N extends SpatialNode<N,E>,E extends SpatialEntry> extends AbstractDistanceBasedAlgorithm<V,Relation<KNNList>>
Since this method compares the MBR of every single leaf with every other leaf, it is essentially quadratic in the number of leaves, which may not be appropriate for large trees. It does currently not yet use the tree structure for pruning.
TODO: exploit the tree structure.
Modifier and Type | Class and Description |
---|---|
static class |
KNNJoin.Parameterizer<V extends NumberVector,N extends SpatialNode<N,E>,E extends SpatialEntry>
Parameterization class.
|
private class |
KNNJoin.Task
Task in the processing queue.
|
Modifier and Type | Field and Description |
---|---|
(package private) int |
k
The k parameter.
|
private static Logging |
LOG
The logger for this class.
|
ALGORITHM_ID
DISTANCE_FUNCTION_ID
Constructor and Description |
---|
KNNJoin(DistanceFunction<? super V> distanceFunction,
int k)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private double |
computeStopDistance(java.util.List<KNNHeap> heaps)
Compute the maximum stop distance.
|
TypeInformation[] |
getInputTypeRestriction()
Get the input type restriction used for negotiating the data query.
|
protected Logging |
getLogger()
Get the (STATIC) logger for this class.
|
private java.util.List<KNNHeap> |
initHeaps(SpatialPrimitiveDistanceFunction<V> distFunction,
N pr)
Initialize the heaps.
|
private void |
processDataPages(SpatialPrimitiveDistanceFunction<? super V> df,
java.util.List<KNNHeap> pr_heaps,
java.util.List<KNNHeap> ps_heaps,
N pr,
N ps)
Processes the two data pages pr and ps and determines the k-nearest
neighbors of pr in ps.
|
Relation<KNNList> |
run(Relation<V> relation)
Joins in the given spatial database to each object its k-nearest neighbors.
|
WritableDataStore<KNNList> |
run(Relation<V> relation,
DBIDs ids)
Inner run method.
|
WritableDataStore<KNNList> |
run(SpatialIndexTree<N,E> index,
DBIDs ids)
Inner run method.
|
getDistanceFunction
run
private static final Logging LOG
int k
public KNNJoin(DistanceFunction<? super V> distanceFunction, int k)
distanceFunction
- Distance functionk
- k parameterpublic Relation<KNNList> run(Relation<V> relation)
relation
- Relation to processpublic WritableDataStore<KNNList> run(Relation<V> relation, DBIDs ids)
KNNJoinMaterializeKNNPreprocessor
relation
- Data relationids
- Object IDspublic WritableDataStore<KNNList> run(SpatialIndexTree<N,E> index, DBIDs ids)
KNNJoinMaterializeKNNPreprocessor
index
- Index to processids
- Object IDsprivate java.util.List<KNNHeap> initHeaps(SpatialPrimitiveDistanceFunction<V> distFunction, N pr)
distFunction
- Distance functionpr
- Node to initialize forprivate void processDataPages(SpatialPrimitiveDistanceFunction<? super V> df, java.util.List<KNNHeap> pr_heaps, java.util.List<KNNHeap> ps_heaps, N pr, N ps)
df
- the distance function to usepr
- the first data pageps
- the second data pagepr_heaps
- the knn lists for each data objectps_heaps
- the knn lists for each data object in psprivate double computeStopDistance(java.util.List<KNNHeap> heaps)
heaps
- Heaps listpublic TypeInformation[] getInputTypeRestriction()
AbstractAlgorithm
getInputTypeRestriction
in interface Algorithm
getInputTypeRestriction
in class AbstractAlgorithm<Relation<KNNList>>
protected Logging getLogger()
AbstractAlgorithm
getLogger
in class AbstractAlgorithm<Relation<KNNList>>
Copyright © 2019 ELKI Development Team. License information.