public class Index
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Index(HashFamily family,
int numberOfHashes,
int numberOfHashTables)
Create a new index.
|
Modifier and Type | Method and Description |
---|---|
static Index |
deserialize(HashFamily family,
int numberOfHashes,
int numberOfHashTables)
Deserializes the hash table from disk.
|
int |
getNumberOfHashes()
The number of hashes used in each hash table in the current index.
|
int |
getNumberOfHashTables()
The number of hash tables used in the current index.
|
int |
getTouched()
The number of near neighbour candidates that are evaluated during the queries on this index.
|
void |
index(Vector vector)
Add a vector to the current index.
|
java.util.List<Vector> |
query(Vector query,
int maxSize)
Query for the k nearest neighbours in using the current index.
|
static void |
serialize(Index index)
Serializes the index to disk.
|
public Index(HashFamily family, int numberOfHashes, int numberOfHashTables)
family
- The family of hash functions to use.numberOfHashes
- The number of hashes that are concatenated in each hash table.
More concatenated hashes means that less candidates are
selected for evaluation.numberOfHashTables
- The number of hash tables in use, recall increases with the
number of hash tables. Memory use also increases. Time needed
to compute a hash also increases marginally.public void index(Vector vector)
vector
- The vector to add.public int getNumberOfHashTables()
public int getNumberOfHashes()
public java.util.List<Vector> query(Vector query, int maxSize)
query
- The query vector. The center of the neighbourhood.maxSize
- The maximum number of neighbours to return. Beware, the number
of neighbours returned lays between zero and the chosen
maximum.public int getTouched()
public static void serialize(Index index)
index
- the storage object.public static Index deserialize(HashFamily family, int numberOfHashes, int numberOfHashTables)
family
- The family.numberOfHashes
- the number of hashes.numberOfHashTables
- The number of hash tables