@@ -114,18 +114,19 @@ struct AQDistanceComputerLUT : FlatCodesDistanceComputer {
114
114
* scanning implementation for search
115
115
************************************************************/
116
116
117
- template <class VectorDistance , class ResultHandler >
117
+ template <class VectorDistance , class BlockResultHandler >
118
118
void search_with_decompress (
119
119
const IndexAdditiveQuantizer& ir,
120
120
const float * xq,
121
121
VectorDistance& vd,
122
- ResultHandler & res) {
122
+ BlockResultHandler & res) {
123
123
const uint8_t * codes = ir.codes .data ();
124
124
size_t ntotal = ir.ntotal ;
125
125
size_t code_size = ir.code_size ;
126
126
const AdditiveQuantizer* aq = ir.aq ;
127
127
128
- using SingleResultHandler = typename ResultHandler::SingleResultHandler;
128
+ using SingleResultHandler =
129
+ typename BlockResultHandler::SingleResultHandler;
129
130
130
131
#pragma omp parallel for if (res.nq > 100)
131
132
for (int64_t q = 0 ; q < res.nq ; q++) {
@@ -142,19 +143,23 @@ void search_with_decompress(
142
143
}
143
144
}
144
145
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 >
146
150
void search_with_LUT (
147
151
const IndexAdditiveQuantizer& ir,
148
152
const float * xq,
149
- ResultHandler & res) {
153
+ BlockResultHandler & res) {
150
154
const AdditiveQuantizer& aq = *ir.aq ;
151
155
const uint8_t * codes = ir.codes .data ();
152
156
size_t ntotal = ir.ntotal ;
153
157
size_t code_size = aq.code_size ;
154
158
size_t nq = res.nq ;
155
159
size_t d = ir.d ;
156
160
157
- using SingleResultHandler = typename ResultHandler::SingleResultHandler;
161
+ using SingleResultHandler =
162
+ typename BlockResultHandler::SingleResultHandler;
158
163
std::unique_ptr<float []> LUT (new float [nq * aq.total_codebook_size ]);
159
164
160
165
aq.compute_LUT (nq, xq, LUT.get ());
@@ -241,21 +246,23 @@ void IndexAdditiveQuantizer::search(
241
246
if (metric_type == METRIC_L2) {
242
247
using VD = VectorDistance<METRIC_L2>;
243
248
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);
245
250
search_with_decompress (*this , x, vd, rh);
246
251
} else if (metric_type == METRIC_INNER_PRODUCT) {
247
252
using VD = VectorDistance<METRIC_INNER_PRODUCT>;
248
253
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);
250
255
search_with_decompress (*this , x, vd, rh);
251
256
}
252
257
} else {
253
258
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);
255
261
search_with_LUT<true , AdditiveQuantizer::ST_LUT_nonorm>(
256
262
*this , x, rh);
257
263
} else {
258
- HeapResultHandler<CMax<float , idx_t >> rh (n, distances, labels, k);
264
+ HeapBlockResultHandler<CMax<float , idx_t >> rh (
265
+ n, distances, labels, k);
259
266
switch (aq->search_type ) {
260
267
#define DISPATCH (st ) \
261
268
case AdditiveQuantizer::st: \
0 commit comments