|
35 | 35 | #include <iostream> |
36 | 36 | #include "api/feature_vector_array.h" |
37 | 37 | #include "api/ivf_flat_index.h" |
| 38 | +#include "api/ivf_pq_index.h" |
38 | 39 | #include "api/vamana_index.h" |
39 | 40 | #include "detail/linalg/matrix.h" |
40 | 41 | #include "index/ivf_flat_index.h" |
| 42 | +#include "index/ivf_pq_index.h" |
41 | 43 | #include "index/vamana_index.h" |
42 | 44 | #include "mdspan/mdspan.hpp" |
43 | 45 | #include "test/utils/array_defs.h" |
@@ -135,6 +137,27 @@ TEST_CASE("test_query_old_indices", "[backwards_compatibility]") { |
135 | 137 | // Next check that we can load the metadata. |
136 | 138 | auto metadata = vamana_index_metadata(); |
137 | 139 | metadata.load_metadata(read_group); |
| 140 | + } else if (index_uri.find("ivf_pq") != std::string::npos) { |
| 141 | + // First check that we can query the index. |
| 142 | + auto index = IndexIVFPQ(ctx, index_uri); |
| 143 | + auto&& [scores, ids] = index.query(queries_feature_vector_array, 1, 10); |
| 144 | + auto scores_span = |
| 145 | + MatrixView<siftsmall_feature_type, stdx::layout_left>{ |
| 146 | + (siftsmall_feature_type*)scores.data(), |
| 147 | + extents(scores)[0], |
| 148 | + extents(scores)[1]}; |
| 149 | + |
| 150 | + auto ids_span = MatrixView<siftsmall_ids_type, stdx::layout_left>{ |
| 151 | + (siftsmall_ids_type*)ids.data(), extents(ids)[0], extents(ids)[1]}; |
| 152 | + |
| 153 | + for (size_t i = 0; i < query_indices.size(); ++i) { |
| 154 | + CHECK(ids_span[0][i] == query_indices[i]); |
| 155 | + CHECK(scores_span[0][i] == 0); |
| 156 | + } |
| 157 | + |
| 158 | + // Next check that we can load the metadata. |
| 159 | + auto metadata = ivf_pq_metadata(); |
| 160 | + metadata.load_metadata(read_group); |
138 | 161 | } else { |
139 | 162 | REQUIRE(false); |
140 | 163 | } |
|
0 commit comments