@@ -114,18 +114,19 @@ struct AQDistanceComputerLUT : FlatCodesDistanceComputer {
114114 * scanning implementation for search
115115 ************************************************************/
116116
117- template <class VectorDistance , class ResultHandler >
117+ template <class VectorDistance , class BlockResultHandler >
118118void search_with_decompress (
119119 const IndexAdditiveQuantizer& ir,
120120 const float * xq,
121121 VectorDistance& vd,
122- ResultHandler & res) {
122+ BlockResultHandler & res) {
123123 const uint8_t * codes = ir.codes .data ();
124124 size_t ntotal = ir.ntotal ;
125125 size_t code_size = ir.code_size ;
126126 const AdditiveQuantizer* aq = ir.aq ;
127127
128- using SingleResultHandler = typename ResultHandler::SingleResultHandler;
128+ using SingleResultHandler =
129+ typename BlockResultHandler::SingleResultHandler;
129130
130131#pragma omp parallel for if (res.nq > 100)
131132 for (int64_t q = 0 ; q < res.nq ; q++) {
@@ -142,19 +143,23 @@ void search_with_decompress(
142143 }
143144}
144145
145- template <bool is_IP, AdditiveQuantizer::Search_type_t st, class ResultHandler >
146+ template <
147+ bool is_IP,
148+ AdditiveQuantizer::Search_type_t st,
149+ class BlockResultHandler >
146150void search_with_LUT (
147151 const IndexAdditiveQuantizer& ir,
148152 const float * xq,
149- ResultHandler & res) {
153+ BlockResultHandler & res) {
150154 const AdditiveQuantizer& aq = *ir.aq ;
151155 const uint8_t * codes = ir.codes .data ();
152156 size_t ntotal = ir.ntotal ;
153157 size_t code_size = aq.code_size ;
154158 size_t nq = res.nq ;
155159 size_t d = ir.d ;
156160
157- using SingleResultHandler = typename ResultHandler::SingleResultHandler;
161+ using SingleResultHandler =
162+ typename BlockResultHandler::SingleResultHandler;
158163 std::unique_ptr<float []> LUT (new float [nq * aq.total_codebook_size ]);
159164
160165 aq.compute_LUT (nq, xq, LUT.get ());
@@ -241,21 +246,23 @@ void IndexAdditiveQuantizer::search(
241246 if (metric_type == METRIC_L2) {
242247 using VD = VectorDistance<METRIC_L2>;
243248 VD vd = {size_t (d), metric_arg};
244- HeapResultHandler <VD::C> rh (n, distances, labels, k);
249+ HeapBlockResultHandler <VD::C> rh (n, distances, labels, k);
245250 search_with_decompress (*this , x, vd, rh);
246251 } else if (metric_type == METRIC_INNER_PRODUCT) {
247252 using VD = VectorDistance<METRIC_INNER_PRODUCT>;
248253 VD vd = {size_t (d), metric_arg};
249- HeapResultHandler <VD::C> rh (n, distances, labels, k);
254+ HeapBlockResultHandler <VD::C> rh (n, distances, labels, k);
250255 search_with_decompress (*this , x, vd, rh);
251256 }
252257 } else {
253258 if (metric_type == METRIC_INNER_PRODUCT) {
254- HeapResultHandler<CMin<float , idx_t >> rh (n, distances, labels, k);
259+ HeapBlockResultHandler<CMin<float , idx_t >> rh (
260+ n, distances, labels, k);
255261 search_with_LUT<true , AdditiveQuantizer::ST_LUT_nonorm>(
256262 *this , x, rh);
257263 } else {
258- HeapResultHandler<CMax<float , idx_t >> rh (n, distances, labels, k);
264+ HeapBlockResultHandler<CMax<float , idx_t >> rh (
265+ n, distances, labels, k);
259266 switch (aq->search_type ) {
260267#define DISPATCH (st ) \
261268 case AdditiveQuantizer::st: \
0 commit comments