V
- Vector typepublic class InMemoryInvertedIndex<V extends NumberVector> extends AbstractIndex<V> implements KNNIndex<V>, RangeIndex<V>
TODO: support additional distances.
Modifier and Type | Class and Description |
---|---|
protected class |
InMemoryInvertedIndex.ArcCosineKNNQuery
kNN query object, for arc cosine distance.
|
protected class |
InMemoryInvertedIndex.ArcCosineRangeQuery
kNN query object, for cosine distance.
|
protected class |
InMemoryInvertedIndex.CosineKNNQuery
kNN query object, for cosine distance.
|
protected class |
InMemoryInvertedIndex.CosineRangeQuery
kNN query object, for cosine distance.
|
static class |
InMemoryInvertedIndex.Factory<V extends NumberVector>
Index factory
|
Modifier and Type | Field and Description |
---|---|
(package private) java.util.ArrayList<ModifiableDoubleDBIDList> |
index
Inverted index.
|
(package private) WritableDoubleDataStore |
length
Length storage.
|
private static Logging |
LOG
Class logger.
|
relation
Constructor and Description |
---|
InMemoryInvertedIndex(Relation<V> relation)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
KNNQuery<V> |
getKNNQuery(DistanceQuery<V> distanceQuery,
java.lang.Object... hints)
Get a KNN query object for the given distance query and k.
|
java.lang.String |
getLongName()
A "pretty" name for the result, for use in titles, captions and menus.
|
private ModifiableDoubleDBIDList |
getOrCreateColumn(int dim)
Get (or create) a column.
|
RangeQuery<V> |
getRangeQuery(DistanceQuery<V> distanceQuery,
java.lang.Object... hints)
Get a range query object for the given distance query and k.
|
java.lang.String |
getShortName()
A short name for the result, useful for file names.
|
private void |
indexDense(DBIDRef ref,
V obj)
Index a single (dense) instance.
|
private void |
indexSparse(DBIDRef ref,
SparseNumberVector obj)
Index a single (sparse) instance.
|
void |
initialize()
Initialize the index.
|
void |
logStatistics()
Send statistics to the logger, if enabled.
|
private double |
naiveQuery(V obj,
WritableDoubleDataStore scores,
HashSetModifiableDBIDs cands)
Query the most similar objects, abstract version.
|
private double |
naiveQueryDense(NumberVector obj,
WritableDoubleDataStore scores,
HashSetModifiableDBIDs cands)
Query the most similar objects, dense version.
|
private double |
naiveQuerySparse(SparseNumberVector obj,
WritableDoubleDataStore scores,
HashSetModifiableDBIDs cands)
Query the most similar objects, sparse version.
|
private static final Logging LOG
java.util.ArrayList<ModifiableDoubleDBIDList> index
WritableDoubleDataStore length
public void initialize()
Index
initialize
in interface Index
private void indexSparse(DBIDRef ref, SparseNumberVector obj)
ref
- Object referenceobj
- Object to index.private void indexDense(DBIDRef ref, V obj)
ref
- Object referenceobj
- Object to index.private ModifiableDoubleDBIDList getOrCreateColumn(int dim)
dim
- Dimensionprivate double naiveQuerySparse(SparseNumberVector obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands)
obj
- Query objectscores
- Score storagecands
- Non-zero objects setprivate double naiveQueryDense(NumberVector obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands)
obj
- Query objectscores
- Score storagecands
- Non-zero objects setprivate double naiveQuery(V obj, WritableDoubleDataStore scores, HashSetModifiableDBIDs cands)
obj
- Query objectscores
- Score storage (must be initialized with zeros!)cands
- Non-zero objects set (must be empty)public void logStatistics()
Index
logStatistics
in interface Index
public KNNQuery<V> getKNNQuery(DistanceQuery<V> distanceQuery, java.lang.Object... hints)
KNNIndex
getKNNQuery
in interface KNNIndex<V extends NumberVector>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
public RangeQuery<V> getRangeQuery(DistanceQuery<V> distanceQuery, java.lang.Object... hints)
RangeIndex
getRangeQuery
in interface RangeIndex<V extends NumberVector>
distanceQuery
- Distance queryhints
- Hints for the optimizernull
public java.lang.String getLongName()
Result
getLongName
in interface Result
getLongName
in class AbstractIndex<V extends NumberVector>
public java.lang.String getShortName()
Result
getShortName
in interface Result
getShortName
in class AbstractIndex<V extends NumberVector>
Copyright © 2019 ELKI Development Team. License information.