|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdata_structures.AbstractSearchStructure
data_structures.VladArray
public class VladArray
This class can be used for storing vectors and also for performing k-nearest neighbor queries.
Field Summary | |
---|---|
private gnu.trove.list.array.TIntArrayList |
idsList
The ids of the corresponding images are stored in this int array. |
private boolean |
loadIndexInMemory
Whether the index will be loaded in memory or not. |
private long |
totalpersistentIndexUpdateTime
The total time taken to update the persistent index. |
private boolean |
useDiskOrderedCursor
Whether to use a disk ordered cursor or not. |
private gnu.trove.list.array.TDoubleArrayList |
vectorsList
The vectors are stored here. |
private com.sleepycat.je.Database |
vladArrayBDB
Berkeley db for persistence of the VladArray data structure |
Fields inherited from class data_structures.AbstractSearchStructure |
---|
cachePercent, cacheSize, countSizeOnLoad, dbEnv, idToNameBDB, idToNameMappings, loadCounter, maxNumVectors, nameToIdBDB, numIndexingThreads, readOnly, syncRate, transactional, vectorLength |
Constructor Summary | |
---|---|
VladArray(int vectorLength,
int loadCounter,
int maxNumVectors,
java.lang.String BDBEnvHome,
boolean loadIndexInMemory,
boolean countSizeOnLoad,
boolean readOnly)
Advanced constructor. |
|
VladArray(int vectorLength,
int maxNumVectors,
java.lang.String BDBEnvHome)
Simple constructor. |
Method Summary | |
---|---|
void |
closeInternal()
Each subclass should implement this method to close the BDB databases that it uses. |
protected com.aliasi.util.BoundedPriorityQueue<Result> |
computeNearestNeighborsInternal(int k,
double[] queryVector)
Computes the k-nearest neighbors for the given query vector. |
double[] |
getVector(int k)
Returns the k-th vector, either from the ram-based or from the disk-based index. |
int |
getVectorId(int k)
Returns the k-th id in the ids array |
protected void |
indexVectorInternal(int id,
double[] vector,
com.sleepycat.je.Transaction txn)
Append the vectors array with the given vector and the ids array with the given id. |
private void |
loadIndexInMemory(boolean diskOrdered)
Loads the persistent index in memory. |
protected void |
outputIndexingTimesInternal()
Index specific time measurements. |
private void |
updatePersistentIndex(int id,
double[] vector,
com.sleepycat.je.Transaction txn)
Updates the persisent vlad index. |
Methods inherited from class data_structures.AbstractSearchStructure |
---|
close, computeNearestNeighbors, createOrOpenBDBEnvAndDbs, getExternalId, getInternalId, getLoadCounter, indexVector, isIndexed, outputIndexingTimes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private gnu.trove.list.array.TDoubleArrayList vectorsList
private gnu.trove.list.array.TIntArrayList idsList
private boolean loadIndexInMemory
private boolean useDiskOrderedCursor
private com.sleepycat.je.Database vladArrayBDB
private long totalpersistentIndexUpdateTime
Constructor Detail |
---|
public VladArray(int vectorLength, int loadCounter, int maxNumVectors, java.lang.String BDBEnvHome, boolean loadIndexInMemory, boolean countSizeOnLoad, boolean readOnly) throws java.lang.Exception
vectorLength
- The dimensionality of the vectors.loadCounter
- The initial value of the loadCounter.maxNumVectors
- The maximum number of vectors.BDBEnvHome
- The BDB environment home directory.loadIndexInMemory
- Whether to load the index in memory.countSizeOnLoad
- Whether the loadCounter will be initialized by the size of the persistent store.readOnly
- If true the persistent store will opened only for read access (allows multiple opens).
java.lang.Exception
public VladArray(int vectorLength, int maxNumVectors, java.lang.String BDBEnvHome) throws java.lang.Exception
vectorLength
- maxNumVectors
- BDBEnvHome
-
java.lang.Exception
Method Detail |
---|
protected void indexVectorInternal(int id, double[] vector, com.sleepycat.je.Transaction txn) throws java.lang.Exception
indexVectorInternal
in class AbstractSearchStructure
name
- vector
-
java.lang.Exception
protected com.aliasi.util.BoundedPriorityQueue<Result> computeNearestNeighborsInternal(int k, double[] queryVector) throws java.lang.Exception
computeNearestNeighborsInternal
in class AbstractSearchStructure
k
- the number of nearest neighbors to be returnedqueryVector
- the query vector
java.lang.Exception
private void loadIndexInMemory(boolean diskOrdered) throws java.lang.Exception
diskOrdered
- whether to use a diskOrderedCursor
java.lang.Exception
private void updatePersistentIndex(int id, double[] vector, com.sleepycat.je.Transaction txn)
id
- vector
- txn
- public double[] getVector(int k) throws java.lang.Exception
k
- index of the vector to be returned (starts from 0)
java.lang.Exception
public int getVectorId(int k) throws java.lang.Exception
k
- index of the id to be returned (starts from 0)
java.lang.Exception
public void closeInternal()
AbstractSearchStructure
closeInternal
in class AbstractSearchStructure
protected void outputIndexingTimesInternal()
AbstractSearchStructure
outputIndexingTimesInternal
in class AbstractSearchStructure
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |