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 class
WrappedPrioritySearchDBIDByLookup.Linear<O>
Linear scan searcher.
-
Constructor Summary
Constructors Modifier Constructor Description private
WrappedPrioritySearchDBIDByLookup(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.double
allLowerBound()
Lower bound for all subsequent instances (that have been completely explored).double
computeExactDistance()
Compute the exact distance to the current candidate.PrioritySearcher<DBIDRef>
decreaseCutoff(double threshold)
Decrease the cutoff threshold.double
getApproximateAccuracy()
Get approximate distance accuracy (if available).double
getApproximateDistance()
Get approximate distance (if available).KNNList
getKNN(DBIDRef id, int k)
Get the k nearest neighbors for a particular object.double
getLowerBound()
Get the lower bound (if available).ModifiableDoubleDBIDList
getRange(DBIDRef id, double range, ModifiableDoubleDBIDList result)
Get the neighbors for a particular id in a given query range.double
getUpperBound()
Get the upper bound (if available).int
internalGetIndex()
Internal only: Get the internal index.PrioritySearcher<DBIDRef>
search(DBIDRef query)
Start search with a new object.boolean
valid()
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:RangeSearcher
Get the neighbors for a particular id in a given query range.- Specified by:
getRange
in interfacePrioritySearcher<O>
- Specified by:
getRange
in 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:KNNSearcher
Get the k nearest neighbors for a particular object.- Specified by:
getKNN
in interfaceKNNSearcher<O>
- Specified by:
getKNN
in interfacePrioritySearcher<O>
- Parameters:
id
- query objectk
- Number of neighbors requested- Returns:
- neighbors
-
search
public PrioritySearcher<DBIDRef> search(DBIDRef query)
Description copied from interface:PrioritySearcher
Start search with a new object.- Specified by:
search
in interfacePrioritySearcher<O>
- Parameters:
query
- Query object- Returns:
this
, for chaining
-
advance
public PrioritySearcher<DBIDRef> advance()
Description copied from interface:Iter
Moves the iterator forward to the next entry.
-
valid
public boolean valid()
Description copied from interface:Iter
Returns true if the iterator currently points to a valid object.
-
decreaseCutoff
public PrioritySearcher<DBIDRef> decreaseCutoff(double threshold)
Description copied from interface:PrioritySearcher
Decrease the cutoff threshold.The cutoff must not be increased, as the search may have pruned some results automatically.
- Specified by:
decreaseCutoff
in interfacePrioritySearcher<O>
- Parameters:
threshold
- Threshold parameter- Returns:
- this, for chaining
-
internalGetIndex
public int internalGetIndex()
Description copied from interface:DBIDRef
Internal only: Get the internal index.NOT FOR PUBLIC USE - ELKI Optimization engine only.
- Specified by:
internalGetIndex
in interfaceDBIDRef
- Returns:
- Internal index
-
getApproximateDistance
public double getApproximateDistance()
Description copied from interface:PrioritySearcher
Get approximate distance (if available).Quality guarantees may vary a lot!
- Specified by:
getApproximateDistance
in interfacePrioritySearcher<O>
- Returns:
Double.NaN
if not valid
-
getApproximateAccuracy
public double getApproximateAccuracy()
Description copied from interface:PrioritySearcher
Get approximate distance accuracy (if available).Quality guarantees may vary a lot!
- Specified by:
getApproximateAccuracy
in interfacePrioritySearcher<O>
- Returns:
Double.NaN
if not valid
-
getLowerBound
public double getLowerBound()
Description copied from interface:PrioritySearcher
Get 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:
getLowerBound
in interfacePrioritySearcher<O>
- Returns:
Double.NaN
if not valid
-
getUpperBound
public double getUpperBound()
Description copied from interface:PrioritySearcher
Get the upper bound (if available).- Specified by:
getUpperBound
in interfacePrioritySearcher<O>
- Returns:
Double.NaN
if not valid
-
computeExactDistance
public double computeExactDistance()
Description copied from interface:PrioritySearcher
Compute the exact distance to the current candidate.The searcher may or may not have this value already.
- Specified by:
computeExactDistance
in interfacePrioritySearcher<O>
- Returns:
- Distance
-
allLowerBound
public double allLowerBound()
Description copied from interface:PrioritySearcher
Lower 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:
allLowerBound
in interfacePrioritySearcher<O>
- Returns:
- lower bound;
0
if 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
null
if inner wasnull
-
-