Package elki.database.query.distance
Class LinearScanEuclideanPrioritySearcher<Q,O extends NumberVector>
- java.lang.Object
-
- elki.database.query.distance.LinearScanEuclideanPrioritySearcher<Q,O>
-
- Type Parameters:
Q- Query typeO- Relation object type
- All Implemented Interfaces:
DBIDIter,DBIDRef,KNNSearcher<Q>,LinearScanQuery,PrioritySearcher<Q>,RangeSearcher<Q>,Iter
- Direct Known Subclasses:
LinearScanEuclideanPrioritySearcher.ByDBID,LinearScanEuclideanPrioritySearcher.ByObject
public abstract class LinearScanEuclideanPrioritySearcher<Q,O extends NumberVector> extends java.lang.Object implements PrioritySearcher<Q>, LinearScanQuery
Default linear scan search class, for Euclidean distance.This is a fallback option - results are not returned in order, and (as always) may exceed the given cutoff threshold.
- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLinearScanEuclideanPrioritySearcher.ByDBID<O extends NumberVector>Search by DBID.static classLinearScanEuclideanPrioritySearcher.ByObject<O extends NumberVector>Search by Object.
-
Field Summary
Fields Modifier and Type Field Description private doublecurdistCurrent distance.private doublecurdistsqCurrent squared distance.protected DistanceQuery<O>distanceQueryDistance to use.private DBIDIteriterIterator.private OqueryCurrent query object.private static SquaredEuclideanDistanceSQUAREDSquared distanceprivate doublethresholdsqCutoff threshold.private doublethresholdUpFake lower bound to return for cut-off values.
-
Constructor Summary
Constructors Constructor Description LinearScanEuclideanPrioritySearcher(DistanceQuery<O> distanceQuery)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PrioritySearcher<Q>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<Q>decreaseCutoff(double threshold)Decrease the cutoff threshold.doublegetApproximateAccuracy()Get approximate distance accuracy (if available).doublegetApproximateDistance()Get approximate distance (if available).doublegetLowerBound()Get the lower bound (if available).doublegetSquaredDistance()Get the squared distance.doublegetUpperBound()Get the upper bound (if available).intinternalGetIndex()Internal only: Get the internal index.PrioritySearcher<Q>realSearch(O query)The real search function.booleanvalid()Returns true if the iterator currently points to a valid object.-
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
getKNN, getRange, search, search
-
Methods inherited from interface elki.database.query.range.RangeSearcher
getRange
-
-
-
-
Field Detail
-
distanceQuery
protected DistanceQuery<O extends NumberVector> distanceQuery
Distance to use.
-
iter
private DBIDIter iter
Iterator.
-
query
private O extends NumberVector query
Current query object.
-
thresholdUp
private double thresholdUp
Fake lower bound to return for cut-off values.
-
thresholdsq
private double thresholdsq
Cutoff threshold.
-
curdist
private double curdist
Current distance.
-
curdistsq
private double curdistsq
Current squared distance.
-
SQUARED
private static final SquaredEuclideanDistance SQUARED
Squared distance
-
-
Constructor Detail
-
LinearScanEuclideanPrioritySearcher
public LinearScanEuclideanPrioritySearcher(DistanceQuery<O> distanceQuery)
Constructor.- Parameters:
distanceQuery- Distance function to use
-
-
Method Detail
-
realSearch
public PrioritySearcher<Q> realSearch(O query)
The real search function.- Parameters:
query- Query object- Returns:
- this
-
valid
public boolean valid()
Description copied from interface:IterReturns true if the iterator currently points to a valid object.
-
advance
public PrioritySearcher<Q> advance()
Description copied from interface:IterMoves the iterator forward to the next entry.
-
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
-
decreaseCutoff
public PrioritySearcher<Q> 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<Q>- Parameters:
threshold- Threshold parameter- Returns:
- this, for chaining
-
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<Q>- Returns:
- Distance
-
getSquaredDistance
public double getSquaredDistance()
Get the squared distance.- Returns:
- squared distance
-
getApproximateAccuracy
public double getApproximateAccuracy()
Description copied from interface:PrioritySearcherGet approximate distance accuracy (if available).Quality guarantees may vary a lot!
- Specified by:
getApproximateAccuracyin interfacePrioritySearcher<Q>- Returns:
Double.NaNif not valid
-
getApproximateDistance
public double getApproximateDistance()
Description copied from interface:PrioritySearcherGet approximate distance (if available).Quality guarantees may vary a lot!
- Specified by:
getApproximateDistancein interfacePrioritySearcher<Q>- 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<Q>- Returns:
Double.NaNif not valid
-
getUpperBound
public double getUpperBound()
Description copied from interface:PrioritySearcherGet the upper bound (if available).- Specified by:
getUpperBoundin interfacePrioritySearcher<Q>- Returns:
Double.NaNif not valid
-
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<Q>- Returns:
- lower bound;
0if no guarantees (e.g., linear scan)
-
-