183 lines
6.8 KiB
Java
183 lines
6.8 KiB
Java
/* ----------------------------------------------------------------------------
|
|
* This file was automatically generated by SWIG (http://www.swig.org).
|
|
* Version 4.0.2
|
|
*
|
|
* Do not make changes to this file unless you know what you are doing--modify
|
|
* the SWIG interface file instead.
|
|
* ----------------------------------------------------------------------------- */
|
|
|
|
package com.twitter.ann.faiss;
|
|
|
|
public class IndexPQ extends IndexFlatCodes {
|
|
private transient long swigCPtr;
|
|
|
|
protected IndexPQ(long cPtr, boolean cMemoryOwn) {
|
|
super(swigfaissJNI.IndexPQ_SWIGUpcast(cPtr), cMemoryOwn);
|
|
swigCPtr = cPtr;
|
|
}
|
|
|
|
protected static long getCPtr(IndexPQ obj) {
|
|
return (obj == null) ? 0 : obj.swigCPtr;
|
|
}
|
|
|
|
@SuppressWarnings("deprecation")
|
|
protected void finalize() {
|
|
delete();
|
|
}
|
|
|
|
public synchronized void delete() {
|
|
if (swigCPtr != 0) {
|
|
if (swigCMemOwn) {
|
|
swigCMemOwn = false;
|
|
swigfaissJNI.delete_IndexPQ(swigCPtr);
|
|
}
|
|
swigCPtr = 0;
|
|
}
|
|
super.delete();
|
|
}
|
|
|
|
public void setPq(ProductQuantizer value) {
|
|
swigfaissJNI.IndexPQ_pq_set(swigCPtr, this, ProductQuantizer.getCPtr(value), value);
|
|
}
|
|
|
|
public ProductQuantizer getPq() {
|
|
long cPtr = swigfaissJNI.IndexPQ_pq_get(swigCPtr, this);
|
|
return (cPtr == 0) ? null : new ProductQuantizer(cPtr, false);
|
|
}
|
|
|
|
public IndexPQ(int d, long M, long nbits, MetricType metric) {
|
|
this(swigfaissJNI.new_IndexPQ__SWIG_0(d, M, nbits, metric.swigValue()), true);
|
|
}
|
|
|
|
public IndexPQ(int d, long M, long nbits) {
|
|
this(swigfaissJNI.new_IndexPQ__SWIG_1(d, M, nbits), true);
|
|
}
|
|
|
|
public IndexPQ() {
|
|
this(swigfaissJNI.new_IndexPQ__SWIG_2(), true);
|
|
}
|
|
|
|
public void train(long n, SWIGTYPE_p_float x) {
|
|
swigfaissJNI.IndexPQ_train(swigCPtr, this, n, SWIGTYPE_p_float.getCPtr(x));
|
|
}
|
|
|
|
public void search(long n, SWIGTYPE_p_float x, long k, SWIGTYPE_p_float distances, LongVector labels) {
|
|
swigfaissJNI.IndexPQ_search(swigCPtr, this, n, SWIGTYPE_p_float.getCPtr(x), k, SWIGTYPE_p_float.getCPtr(distances), SWIGTYPE_p_long_long.getCPtr(labels.data()), labels);
|
|
}
|
|
|
|
public void sa_encode(long n, SWIGTYPE_p_float x, SWIGTYPE_p_unsigned_char bytes) {
|
|
swigfaissJNI.IndexPQ_sa_encode(swigCPtr, this, n, SWIGTYPE_p_float.getCPtr(x), SWIGTYPE_p_unsigned_char.getCPtr(bytes));
|
|
}
|
|
|
|
public void sa_decode(long n, SWIGTYPE_p_unsigned_char bytes, SWIGTYPE_p_float x) {
|
|
swigfaissJNI.IndexPQ_sa_decode(swigCPtr, this, n, SWIGTYPE_p_unsigned_char.getCPtr(bytes), SWIGTYPE_p_float.getCPtr(x));
|
|
}
|
|
|
|
public DistanceComputer get_distance_computer() {
|
|
long cPtr = swigfaissJNI.IndexPQ_get_distance_computer(swigCPtr, this);
|
|
return (cPtr == 0) ? null : new DistanceComputer(cPtr, false);
|
|
}
|
|
|
|
public void setDo_polysemous_training(boolean value) {
|
|
swigfaissJNI.IndexPQ_do_polysemous_training_set(swigCPtr, this, value);
|
|
}
|
|
|
|
public boolean getDo_polysemous_training() {
|
|
return swigfaissJNI.IndexPQ_do_polysemous_training_get(swigCPtr, this);
|
|
}
|
|
|
|
public void setPolysemous_training(PolysemousTraining value) {
|
|
swigfaissJNI.IndexPQ_polysemous_training_set(swigCPtr, this, PolysemousTraining.getCPtr(value), value);
|
|
}
|
|
|
|
public PolysemousTraining getPolysemous_training() {
|
|
long cPtr = swigfaissJNI.IndexPQ_polysemous_training_get(swigCPtr, this);
|
|
return (cPtr == 0) ? null : new PolysemousTraining(cPtr, false);
|
|
}
|
|
|
|
public void setSearch_type(IndexPQ.Search_type_t value) {
|
|
swigfaissJNI.IndexPQ_search_type_set(swigCPtr, this, value.swigValue());
|
|
}
|
|
|
|
public IndexPQ.Search_type_t getSearch_type() {
|
|
return IndexPQ.Search_type_t.swigToEnum(swigfaissJNI.IndexPQ_search_type_get(swigCPtr, this));
|
|
}
|
|
|
|
public void setEncode_signs(boolean value) {
|
|
swigfaissJNI.IndexPQ_encode_signs_set(swigCPtr, this, value);
|
|
}
|
|
|
|
public boolean getEncode_signs() {
|
|
return swigfaissJNI.IndexPQ_encode_signs_get(swigCPtr, this);
|
|
}
|
|
|
|
public void setPolysemous_ht(int value) {
|
|
swigfaissJNI.IndexPQ_polysemous_ht_set(swigCPtr, this, value);
|
|
}
|
|
|
|
public int getPolysemous_ht() {
|
|
return swigfaissJNI.IndexPQ_polysemous_ht_get(swigCPtr, this);
|
|
}
|
|
|
|
public void search_core_polysemous(long n, SWIGTYPE_p_float x, long k, SWIGTYPE_p_float distances, LongVector labels) {
|
|
swigfaissJNI.IndexPQ_search_core_polysemous(swigCPtr, this, n, SWIGTYPE_p_float.getCPtr(x), k, SWIGTYPE_p_float.getCPtr(distances), SWIGTYPE_p_long_long.getCPtr(labels.data()), labels);
|
|
}
|
|
|
|
public void hamming_distance_histogram(long n, SWIGTYPE_p_float x, long nb, SWIGTYPE_p_float xb, LongVector dist_histogram) {
|
|
swigfaissJNI.IndexPQ_hamming_distance_histogram(swigCPtr, this, n, SWIGTYPE_p_float.getCPtr(x), nb, SWIGTYPE_p_float.getCPtr(xb), SWIGTYPE_p_long_long.getCPtr(dist_histogram.data()), dist_histogram);
|
|
}
|
|
|
|
public void hamming_distance_table(long n, SWIGTYPE_p_float x, SWIGTYPE_p_int dis) {
|
|
swigfaissJNI.IndexPQ_hamming_distance_table(swigCPtr, this, n, SWIGTYPE_p_float.getCPtr(x), SWIGTYPE_p_int.getCPtr(dis));
|
|
}
|
|
|
|
public final static class Search_type_t {
|
|
public final static IndexPQ.Search_type_t ST_PQ = new IndexPQ.Search_type_t("ST_PQ");
|
|
public final static IndexPQ.Search_type_t ST_HE = new IndexPQ.Search_type_t("ST_HE");
|
|
public final static IndexPQ.Search_type_t ST_generalized_HE = new IndexPQ.Search_type_t("ST_generalized_HE");
|
|
public final static IndexPQ.Search_type_t ST_SDC = new IndexPQ.Search_type_t("ST_SDC");
|
|
public final static IndexPQ.Search_type_t ST_polysemous = new IndexPQ.Search_type_t("ST_polysemous");
|
|
public final static IndexPQ.Search_type_t ST_polysemous_generalize = new IndexPQ.Search_type_t("ST_polysemous_generalize");
|
|
|
|
public final int swigValue() {
|
|
return swigValue;
|
|
}
|
|
|
|
public String toString() {
|
|
return swigName;
|
|
}
|
|
|
|
public static Search_type_t swigToEnum(int swigValue) {
|
|
if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
|
|
return swigValues[swigValue];
|
|
for (int i = 0; i < swigValues.length; i++)
|
|
if (swigValues[i].swigValue == swigValue)
|
|
return swigValues[i];
|
|
throw new IllegalArgumentException("No enum " + Search_type_t.class + " with value " + swigValue);
|
|
}
|
|
|
|
private Search_type_t(String swigName) {
|
|
this.swigName = swigName;
|
|
this.swigValue = swigNext++;
|
|
}
|
|
|
|
private Search_type_t(String swigName, int swigValue) {
|
|
this.swigName = swigName;
|
|
this.swigValue = swigValue;
|
|
swigNext = swigValue+1;
|
|
}
|
|
|
|
private Search_type_t(String swigName, Search_type_t swigEnum) {
|
|
this.swigName = swigName;
|
|
this.swigValue = swigEnum.swigValue;
|
|
swigNext = this.swigValue+1;
|
|
}
|
|
|
|
private static Search_type_t[] swigValues = { ST_PQ, ST_HE, ST_generalized_HE, ST_SDC, ST_polysemous, ST_polysemous_generalize };
|
|
private static int swigNext = 0;
|
|
private final int swigValue;
|
|
private final String swigName;
|
|
}
|
|
|
|
}
|