Package elki.database.query
Class WrappedPrioritySearchDBIDByLookup<O>
- java.lang.Object
-
- elki.database.query.WrappedPrioritySearchDBIDByLookup<O>
-
- Type Parameters:
O- relation object type
- All Implemented Interfaces:
DBIDIter,DBIDRef,KNNSearcher<DBIDRef>,PrioritySearcher<DBIDRef>,RangeSearcher<DBIDRef>,Iter
- Direct Known Subclasses:
WrappedPrioritySearchDBIDByLookup.Linear
public class WrappedPrioritySearchDBIDByLookup<O> extends java.lang.Object implements PrioritySearcher<DBIDRef>
Find nearest neighbors by querying with the original object.- Since:
- 0.8.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWrappedPrioritySearchDBIDByLookup.Linear<O>Linear scan searcher.
-
Constructor Summary
Constructors Modifier Constructor Description privateWrappedPrioritySearchDBIDByLookup(Relation<? extends O> relation, PrioritySearcher<O> inner)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PrioritySearcher<DBIDRef>advance()Moves the iterator forward to the next entry.doubleallLowerBound()Lower bound for all subsequent instances (that have been completely explored).doublecomputeExactDistance()Compute the exact distance to the current candidate.PrioritySearcher<DBIDRef>decreaseCutoff(double threshold)Decrease the cutoff threshold.doublegetApproximateAccuracy()Get approximate distance accuracy (if available).doublegetApproximateDistance()Get approximate distance (if available).KNNListgetKNN(DBIDRef id, int k)Get the k nearest neighbors for a particular object.doublegetLowerBound()Get the lower bound (if available).ModifiableDoubleDBIDListgetRange(DBIDRef id, double range, ModifiableDoubleDBIDList result)Get the neighbors for a particular id in a given query range.doublegetUpperBound()Get the upper bound (if available).intinternalGetIndex()Internal only: Get the internal index.PrioritySearcher<DBIDRef>search(DBIDRef query)Start search with a new object.booleanvalid()Returns true if the iterator currently points to a valid object.static <O> PrioritySearcher<DBIDRef>wrap(Relation<? extends O> relation, PrioritySearcher<O> inner)Wrap a query, if notnull.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.database.query.PrioritySearcher
search
-
Methods inherited from interface elki.database.query.range.RangeSearcher
getRange
-
-
-
-
Field Detail
-
inner
private PrioritySearcher<O> inner
Inner kNN searcher.
-
-
Constructor Detail
-
WrappedPrioritySearchDBIDByLookup
private WrappedPrioritySearchDBIDByLookup(Relation<? extends O> relation, PrioritySearcher<O> inner)
Constructor.- Parameters:
relation- data relationinner- inner kNN searcher
-
-
Method Detail
-
getRange
public ModifiableDoubleDBIDList getRange(DBIDRef id, double range, ModifiableDoubleDBIDList result)
Description copied from interface:RangeSearcherGet the neighbors for a particular id in a given query range.- Specified by:
getRangein interfacePrioritySearcher<O>- Specified by:
getRangein interfaceRangeSearcher<O>- Parameters:
id- query object IDrange- Query rangeresult- Output data structure- Returns:
- neighbors
-
getKNN
public KNNList getKNN(DBIDRef id, int k)
Description copied from interface:KNNSearcherGet the k nearest neighbors for a particular object.- Specified by:
getKNNin interfaceKNNSearcher<O>- Specified by:
getKNNin interfacePrioritySearcher<O>- Parameters:
id- query objectk- Number of neighbors requested- Returns:
- neighbors
-
search
public PrioritySearcher<DBIDRef> search(DBIDRef query)
Description copied from interface:PrioritySearcherStart search with a new object.- Specified by:
searchin interfacePrioritySearcher<O>- Parameters:
query- Query object- Returns:
this, for chaining
-
advance
public PrioritySearcher<DBIDRef> advance()
Description copied from interface:IterMoves the iterator forward to the next entry.
-
valid
public boolean valid()
Description copied from interface:IterReturns true if the iterator currently points to a valid object.
-
decreaseCutoff
public PrioritySearcher<DBIDRef> decreaseCutoff(double threshold)
Description copied from interface:PrioritySearcherDecrease the cutoff threshold.The cutoff must not be increased, as the search may have pruned some results automatically.
- Specified by:
decreaseCutoffin interfacePrioritySearcher<O>- Parameters:
threshold- Threshold parameter- Returns:
- this, for chaining
-
internalGetIndex
public int internalGetIndex()
Description copied from interface:DBIDRefInternal only: Get the internal index.NOT FOR PUBLIC USE - ELKI Optimization engine only.
- Specified by:
internalGetIndexin interfaceDBIDRef- Returns:
- Internal index
-
getApproximateDistance
public double getApproximateDistance()
Description copied from interface:PrioritySearcherGet approximate distance (if available).Quality guarantees may vary a lot!
- Specified by:
getApproximateDistancein interfacePrioritySearcher<O>- Returns:
Double.NaNif not valid
-
getApproximateAccuracy
public double getApproximateAccuracy()
Description copied from interface:PrioritySearcherGet approximate distance accuracy (if available).Quality guarantees may vary a lot!
- Specified by:
getApproximateAccuracyin interfacePrioritySearcher<O>- Returns:
Double.NaNif not valid
-
getLowerBound
public double getLowerBound()
Description copied from interface:PrioritySearcherGet the lower bound (if available).Note: the lower bound is already checked by the cutoff of the priority search, so this is primarily useful for analyzing the search behavior.
- Specified by:
getLowerBoundin interfacePrioritySearcher<O>- Returns:
Double.NaNif not valid
-
getUpperBound
public double getUpperBound()
Description copied from interface:PrioritySearcherGet the upper bound (if available).- Specified by:
getUpperBoundin interfacePrioritySearcher<O>- Returns:
Double.NaNif not valid
-
computeExactDistance
public double computeExactDistance()
Description copied from interface:PrioritySearcherCompute the exact distance to the current candidate.The searcher may or may not have this value already.
- Specified by:
computeExactDistancein interfacePrioritySearcher<O>- Returns:
- Distance
-
allLowerBound
public double allLowerBound()
Description copied from interface:PrioritySearcherLower bound for all subsequent instances (that have been completely explored). The searcher guarantees that no further results will be returned with a distance less than this.- Specified by:
allLowerBoundin interfacePrioritySearcher<O>- Returns:
- lower bound;
0if no guarantees (e.g., linear scan)
-
wrap
public static <O> PrioritySearcher<DBIDRef> wrap(Relation<? extends O> relation, PrioritySearcher<O> inner)
Wrap a query, if notnull.- Type Parameters:
O- inner data type- Parameters:
relation- Relation to get object frominner- inner query- Returns:
- wrapped query, or
nullif inner wasnull
-
-