Coverage Report

Created: 2025-11-25 18:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/doris/contrib/faiss/faiss/IndexPQFastScan.h
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#pragma once
9
10
#include <faiss/IndexFastScan.h>
11
#include <faiss/IndexPQ.h>
12
#include <faiss/impl/ProductQuantizer.h>
13
#include <faiss/utils/AlignedTable.h>
14
15
namespace faiss {
16
17
/** Fast scan version of IndexPQ. Works for 4-bit PQ for now.
18
 *
19
 * The codes are not stored sequentially but grouped in blocks of size bbs.
20
 * This makes it possible to compute distances quickly with SIMD instructions.
21
 *
22
 * Implementations:
23
 * 12: blocked loop with internal loop on Q with qbs
24
 * 13: same with reservoir accumulator to store results
25
 * 14: no qbs with heap accumulator
26
 * 15: no qbs with reservoir accumulator
27
 */
28
29
struct IndexPQFastScan : IndexFastScan {
30
    ProductQuantizer pq;
31
32
    IndexPQFastScan(
33
            int d,
34
            size_t M,
35
            size_t nbits,
36
            MetricType metric = METRIC_L2,
37
            int bbs = 32);
38
39
0
    IndexPQFastScan() = default;
40
41
    /// build from an existing IndexPQ
42
    explicit IndexPQFastScan(const IndexPQ& orig, int bbs = 32);
43
44
    void train(idx_t n, const float* x) override;
45
46
    void compute_codes(uint8_t* codes, idx_t n, const float* x) const override;
47
48
    void compute_float_LUT(float* lut, idx_t n, const float* x) const override;
49
50
    void sa_decode(idx_t n, const uint8_t* bytes, float* x) const override;
51
};
52
53
} // namespace faiss