|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdata_structures.AbstractSearchStructure
data_structures.ADC
public class ADC
This class implements ADC (Asymmetric Distance Computation). It can be used for indexing and searching a database according to ADC approach.
Field Summary | |
---|---|
private com.sleepycat.je.Database |
adcBDB
Berkeley db for persistence of the ADC index |
private gnu.trove.list.array.TIntArrayList |
ids
The ids of the corresponding images are stored in this list. |
private int |
numProductCentroids
The number of centroids used to quantize each sub-vector. |
private int |
numSubVectors
The number of sub-vectors used in this product quantization. |
private long |
persistentIndexUpdateTime
|
private gnu.trove.list.array.TByteArrayList |
pqByteCodes
The product-quantization codes for all vector are stored in this list if the code can fit in the byte range. |
private gnu.trove.list.array.TShortArrayList |
pqShortCodes
The product-quantization codes for all vector are stored in this list if the code cannot fit in the byte range. |
private long |
productQuantizationTime
|
private double[][][] |
productQuantizer
The sub-quantizers. |
private RandomOrthogonalTransformation |
randomTransform
This object is used for applying random orthogonal transformation prior to product quantization. |
private boolean |
randomTransformation
Whether to apply random orthogonal transformation on the vectors prior to product quantization. |
private int |
subVectorLength
The length of each subvector. |
Fields inherited from class data_structures.AbstractSearchStructure |
---|
cachePercent, cacheSize, countSizeOnLoad, dbEnv, idToNameBDB, idToNameMappings, loadCounter, maxNumVectors, nameToIdBDB, numIndexingThreads, readOnly, syncRate, transactional, vectorLength |
Constructor Summary | |
---|---|
ADC(int vectorLength,
int subVectorLength,
int numProductCentroids,
boolean randomTransformation,
int maxNumVectors,
int loadCounter,
java.lang.String BDBEnvHome,
boolean readOnly,
boolean countSizeOnLoad)
Advanced constructor. |
|
ADC(int vectorLength,
int subVectorLength,
int numProductCentroids,
boolean randomTransformation,
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. |
private com.aliasi.util.BoundedPriorityQueue<Result> |
computeKNN_ADC(int k,
double[] queryVector)
|
double[][] |
computeLookupADC(double[] queryVector)
Takes a query vector as input and returns a look-up table containing the distance between each sub-vector of the query vector from each centroid of each sub-quantizer. |
protected com.aliasi.util.BoundedPriorityQueue<Result> |
computeNearestNeighborsInternal(int k,
double[] query)
This method returns a bounded priority queue of Result objects, corresponding to the k nearest neighbors' ids and their distances from the query vector, ordered by lowest distance. |
private int |
computeNearestProductIndex(double[] subvector,
int subQuantizerIndex)
Finds and returns the index of the centroid of the subquantizer with the given index which is closer to the given subvector. |
protected void |
indexVectorInternal(int id,
double[] vector,
com.sleepycat.je.Transaction txn)
Append the pqCodes and ids arrays with the code and the id of the given vector. |
private void |
loadIndexInMemory()
The previous example shows how to scan through the records in your database sequentially; that is, in the record's sort order. |
void |
loadProductQuantizer(java.lang.String filname)
Load the product quantizer from a given file |
void |
outputIndexingTimesInternal()
This method can be called to output indexing time measurements. |
java.lang.String |
toString()
|
private void |
updatePersistentIndex(int id,
byte[] code,
com.sleepycat.je.Transaction txn)
|
private void |
updatePersistentIndex(int id,
short[] code,
com.sleepycat.je.Transaction txn)
|
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, wait, wait, wait |
Field Detail |
---|
private long productQuantizationTime
private long persistentIndexUpdateTime
private double[][][] productQuantizer
private int numSubVectors
private int numProductCentroids
private int subVectorLength
private gnu.trove.list.array.TByteArrayList pqByteCodes
private gnu.trove.list.array.TShortArrayList pqShortCodes
private gnu.trove.list.array.TIntArrayList ids
private boolean randomTransformation
private RandomOrthogonalTransformation randomTransform
private com.sleepycat.je.Database adcBDB
Constructor Detail |
---|
public ADC(int vectorLength, int subVectorLength, int numProductCentroids, boolean randomTransformation, int maxNumVectors, int loadCounter, java.lang.String BDBEnvHome, boolean readOnly, boolean countSizeOnLoad) throws java.lang.Exception
vectorLength
- The dimensionality of the vectors.subVectorLength
- The subvector length.numProductCentroids
- The number of product centroids.randomTransformation
- Whether to perform random transformation.maxNumVectors
- The maximum number of vectors.loadCounter
- The initial value of the loadCounter.BDBEnvHome
- The BDB environment home directory.readOnly
- If true the persistent store will opened only for read access (allows multiple opens).countSizeOnLoad
- Whether the loadCounter will be initialized by the size of the persistent store.
java.lang.Exception
public ADC(int vectorLength, int subVectorLength, int numProductCentroids, boolean randomTransformation, int maxNumVectors, java.lang.String BDBEnvHome) throws java.lang.Exception
vectorLength
- subVectorLength
- numProductCentroids
- randomTransformation
- maxNumVectors
- BDBEnvHome
-
java.lang.Exception
Method Detail |
---|
public void loadProductQuantizer(java.lang.String filname) throws java.io.IOException
filname
-
java.io.IOException
private void loadIndexInMemory() throws java.lang.Exception
java.lang.Exception
protected void indexVectorInternal(int id, double[] vector, com.sleepycat.je.Transaction txn) throws java.lang.Exception
indexVectorInternal
in class AbstractSearchStructure
id
- vector
- txn
- A transaction handle.
java.lang.Exception
private void updatePersistentIndex(int id, byte[] code, com.sleepycat.je.Transaction txn)
private void updatePersistentIndex(int id, short[] code, com.sleepycat.je.Transaction txn)
private int computeNearestProductIndex(double[] subvector, int subQuantizerIndex)
subvector
- subQuantizerIndex
-
public double[][] computeLookupADC(double[] queryVector)
queryVector
-
protected com.aliasi.util.BoundedPriorityQueue<Result> computeNearestNeighborsInternal(int k, double[] query) throws java.lang.Exception
AbstractSearchStructure
computeNearestNeighborsInternal
in class AbstractSearchStructure
k
- The number of nearest neighbors to return.query
- The query vector.
java.lang.Exception
private com.aliasi.util.BoundedPriorityQueue<Result> computeKNN_ADC(int k, double[] queryVector)
public void closeInternal()
AbstractSearchStructure
closeInternal
in class AbstractSearchStructure
public void outputIndexingTimesInternal()
outputIndexingTimesInternal
in class AbstractSearchStructure
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |