Package elki.database.query
Class EmpiricalQueryOptimizer
- java.lang.Object
-
- elki.database.query.EmpiricalQueryOptimizer
-
- All Implemented Interfaces:
QueryOptimizer
@Alias("auto") public class EmpiricalQueryOptimizer extends java.lang.Object implements QueryOptimizer
Class to automatically add indexes to a database.- Since:
- 0.8.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.reflect.Constructor<? extends Index>
coverIndex
cover tree index class.private java.lang.reflect.Constructor<? extends Index>
kdIndex
k-d-tree index class.private java.lang.reflect.Constructor<? extends KNNIndex<?>>
knnIndex
kNN preprocessor class.private static Logging
LOG
Class logger.private java.lang.reflect.Constructor<? extends Index>
matrixIndex
Distance matrix index class.private static long
MEGA
Megabytes for formatting memory.private java.lang.reflect.Constructor<? extends Index>
vpIndex
vp tree index class.
-
Constructor Summary
Constructors Constructor Description EmpiricalQueryOptimizer()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
formatMemory(long mem)
Format a memory amount.<O> DistanceQuery<O>
getDistanceQuery(Relation<? extends O> relation, Distance<? super O> distance, int flags)
Optimize a distance query for this relation.private static long
getFreeMemory()
Get the currently free amount of memory.<O> KNNSearcher<DBIDRef>
kNNByDBID(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, int maxk, int flags)
Optimize a kNN query for this relation.<O> KNNSearcher<O>
kNNByObject(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, int maxk, int flags)
Optimize a kNN query for this relation.private <O> DistancePriorityIndex<O>
makeCoverTree(Relation<? extends O> relation, Distance<? super O> distance, int leafsize)
private <O> DistancePriorityIndex<O>
makeKDTree(Relation<? extends O> relation, Distance<? super O> distance, int k)
private <O> KNNIndex<O>
makeKnnPreprocessor(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, int maxk, int flags)
Make a knn preprocessor.private <O> DistancePriorityIndex<O>
makeMatrixIndex(Relation<? extends O> relation, Distance<? super O> distance)
private <O> DistancePriorityIndex<O>
makeVPTree(Relation<? extends O> relation, Distance<? super O> distance, int leafsize)
<O> PrioritySearcher<DBIDRef>
priorityByDBID(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Optimize a distance priority search for this relation.<O> PrioritySearcher<O>
priorityByObject(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Optimize a distance priority search for this relation.<O> RangeSearcher<DBIDRef>
rangeByDBID(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Optimize a range query for this relation.<O> RangeSearcher<O>
rangeByObject(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Optimize a range query for this relation.-
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.QueryOptimizer
getSimilarityQuery, rkNNByDBID, rkNNByObject, similarityRangeByDBID, similarityRangeByObject
-
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Class logger.
-
MEGA
private static final long MEGA
Megabytes for formatting memory.- See Also:
- Constant Field Values
-
matrixIndex
private final java.lang.reflect.Constructor<? extends Index> matrixIndex
Distance matrix index class.
-
knnIndex
private final java.lang.reflect.Constructor<? extends KNNIndex<?>> knnIndex
kNN preprocessor class.
-
coverIndex
private final java.lang.reflect.Constructor<? extends Index> coverIndex
cover tree index class.
-
vpIndex
private final java.lang.reflect.Constructor<? extends Index> vpIndex
vp tree index class.
-
kdIndex
private final java.lang.reflect.Constructor<? extends Index> kdIndex
k-d-tree index class.
-
-
Method Detail
-
getDistanceQuery
public <O> DistanceQuery<O> getDistanceQuery(Relation<? extends O> relation, Distance<? super O> distance, int flags)
Description copied from interface:QueryOptimizer
Optimize a distance query for this relation.- Specified by:
getDistanceQuery
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistance
- Distance functionflags
- Optimizer flags- Returns:
- optimized query, if possible
-
kNNByObject
public <O> KNNSearcher<O> kNNByObject(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:QueryOptimizer
Optimize a kNN query for this relation.- Specified by:
kNNByObject
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxk
- Maximum kflags
- Optimizer flags- Returns:
- optimized query, if possible
-
kNNByDBID
public <O> KNNSearcher<DBIDRef> kNNByDBID(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, int maxk, int flags)
Description copied from interface:QueryOptimizer
Optimize a kNN query for this relation.- Specified by:
kNNByDBID
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxk
- Maximum kflags
- Optimizer flags- Returns:
- optimized query, if possible
-
rangeByObject
public <O> RangeSearcher<O> rangeByObject(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:QueryOptimizer
Optimize a range query for this relation.- Specified by:
rangeByObject
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxrange
- Maximum rangeflags
- Optimizer flags- Returns:
- optimized query, if possible
-
rangeByDBID
public <O> RangeSearcher<DBIDRef> rangeByDBID(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:QueryOptimizer
Optimize a range query for this relation.- Specified by:
rangeByDBID
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxrange
- Maximum rangeflags
- Optimizer flags- Returns:
- optimized query, if possible
-
priorityByObject
public <O> PrioritySearcher<O> priorityByObject(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:QueryOptimizer
Optimize a distance priority search for this relation.- Specified by:
priorityByObject
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxrange
- Maximum rangeflags
- Optimizer flags- Returns:
- optimized query, if possible
-
priorityByDBID
public <O> PrioritySearcher<DBIDRef> priorityByDBID(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, double maxrange, int flags)
Description copied from interface:QueryOptimizer
Optimize a distance priority search for this relation.- Specified by:
priorityByDBID
in interfaceQueryOptimizer
- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxrange
- Maximum rangeflags
- Optimizer flags- Returns:
- optimized query, if possible
-
makeMatrixIndex
private <O> DistancePriorityIndex<O> makeMatrixIndex(Relation<? extends O> relation, Distance<? super O> distance)
-
makeCoverTree
private <O> DistancePriorityIndex<O> makeCoverTree(Relation<? extends O> relation, Distance<? super O> distance, int leafsize)
-
makeVPTree
private <O> DistancePriorityIndex<O> makeVPTree(Relation<? extends O> relation, Distance<? super O> distance, int leafsize)
-
makeKDTree
private <O> DistancePriorityIndex<O> makeKDTree(Relation<? extends O> relation, Distance<? super O> distance, int k)
-
makeKnnPreprocessor
private <O> KNNIndex<O> makeKnnPreprocessor(Relation<? extends O> relation, DistanceQuery<O> distanceQuery, int maxk, int flags)
Make a knn preprocessor.- Type Parameters:
O
- Object type- Parameters:
relation
- Data relationdistanceQuery
- distance querymaxk
- Maximum kflags
- Optimizer flags- Returns:
- knn preprocessor
-
getFreeMemory
private static long getFreeMemory()
Get the currently free amount of memory.- Returns:
- Free memory
-
formatMemory
private static java.lang.String formatMemory(long mem)
Format a memory amount.- Parameters:
mem
- Memory- Returns:
- Memory amount
-
-