Skip to content

Commit 58111d8

Browse files
author
Nikos Papailiou
committed
Prefer uint64_t instead of size_t
1 parent e14d040 commit 58111d8

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

apis/python/src/tiledb/vector_search/module.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static void declare_ivf_index_tdb(py::module& m, const std::string& suffix) {
279279
}, py::keep_alive<1,2>());
280280
}
281281

282-
template <class T=float, class U=size_t>
282+
template <class T=float, class U=uint64_t>
283283
static void declareFixedMinPairHeap(py::module& mod) {
284284
using PyFixedMinPairHeap = py::class_<fixed_min_pair_heap<T, U>>;
285285
PyFixedMinPairHeap cls(mod, "FixedMinPairHeap", py::buffer_protocol());
@@ -356,7 +356,7 @@ void declareStdVector(py::module& m, const std::string& suffix) {
356356
});
357357
}
358358

359-
template <typename T, typename indices_type = size_t>
359+
template <typename T, typename indices_type = uint64_t>
360360
void declarePartitionIvfIndex(py::module& m, const std::string& suffix) {
361361
m.def(("partition_ivf_index_" + suffix).c_str(),
362362
[](ColMajorMatrix<float>& centroids,
@@ -496,7 +496,7 @@ PYBIND11_MODULE(_tiledbvspy, m) {
496496
[](ColMajorMatrix<float>& data,
497497
ColMajorMatrix<float>& query_vectors,
498498
int k,
499-
size_t nthreads) -> std::tuple<ColMajorMatrix<float>, ColMajorMatrix<size_t>> {
499+
size_t nthreads) -> std::tuple<ColMajorMatrix<float>, ColMajorMatrix<uint64_t>> {
500500
auto r = detail::flat::vq_query_heap(data, query_vectors, k, nthreads);
501501
return r;
502502
});
@@ -505,13 +505,13 @@ PYBIND11_MODULE(_tiledbvspy, m) {
505505
[](tdbColMajorMatrix<uint8_t>& data,
506506
ColMajorMatrix<float>& query_vectors,
507507
int k,
508-
size_t nthreads) -> std::tuple<ColMajorMatrix<float>, ColMajorMatrix<size_t>> {
508+
size_t nthreads) -> std::tuple<ColMajorMatrix<float>, ColMajorMatrix<uint64_t>> {
509509
auto r = detail::flat::vq_query_heap(data, query_vectors, k, nthreads);
510510
return r;
511511
});
512512

513513
m.def("validate_top_k_u64",
514-
[](const ColMajorMatrix<size_t>& top_k,
514+
[](const ColMajorMatrix<uint64_t>& top_k,
515515
const ColMajorMatrix<int32_t>& ground_truth) -> bool {
516516
return validate_top_k(top_k, ground_truth);
517517
});

src/include/detail/flat/qv.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ auto qv_query_heap(
128128
template <class DB, class Q>
129129
auto qv_query_heap(const DB& db, const Q& q, int k_nn, unsigned nthreads) {
130130
return qv_query_heap(
131-
without_ids{}, db, q, std::vector<size_t>{}, k_nn, nthreads);
131+
without_ids{}, db, q, std::vector<uint64_t>{}, k_nn, nthreads);
132132
}
133133

134134
template <class DB, class Q, class ID>
@@ -209,7 +209,7 @@ auto qv_query_heap_tiled(
209209
template <class DB, class Q>
210210
auto qv_query_heap_tiled(DB& db, const Q& q, int k_nn, unsigned nthreads) {
211211
return qv_query_heap_tiled(
212-
without_ids{}, db, q, std::vector<size_t>{}, k_nn, nthreads);
212+
without_ids{}, db, q, std::vector<uint64_t>{}, k_nn, nthreads);
213213
}
214214

215215
template <class DB, class Q, class ID>
@@ -226,11 +226,11 @@ auto qv_query_heap_tiled(
226226
[[maybe_unused]] const ID& ids,
227227
int k_nn,
228228
unsigned nthreads) {
229-
229+
230230
// using feature_type = typename std::remove_reference_t<decltype(db)>::value_type;
231231
using id_type = typename std::remove_reference_t<decltype(ids)>::value_type;
232232
using score_type = float;
233-
233+
234234
if constexpr (is_loadable_v<decltype(db)>) {
235235
db.load();
236236
}

src/include/detail/flat/vq.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ auto vq_query_heap(
6363
template <class DB, class Q>
6464
auto vq_query_heap(DB& db, const Q& q, int k_nn, unsigned nthreads) {
6565
return vq_query_heap(
66-
without_ids{}, db, q, std::vector<size_t>{}, k_nn, nthreads);
66+
without_ids{}, db, q, std::vector<uint64_t>{}, k_nn, nthreads);
6767
}
6868

6969
template <class DB, class Q, class ID>
@@ -83,11 +83,11 @@ auto vq_query_heap(
8383
unsigned nthreads) {
8484
// @todo Need to get the total number of queries, not just the first block
8585
// @todo Use Matrix here rather than vector of vectors
86-
86+
8787
// using feature_type = typename std::remove_reference_t<decltype(db)>::value_type;
8888
using id_type = typename std::remove_reference_t<decltype(ids)>::value_type;
8989
using score_type = float;
90-
90+
9191
std::vector<std::vector<fixed_min_pair_heap<score_type, id_type>>> scores(
9292
nthreads,
9393
std::vector<fixed_min_pair_heap<score_type, id_type>>(
@@ -173,7 +173,7 @@ auto vq_query_heap_tiled(
173173
template <class DB, class Q>
174174
auto vq_query_heap_tiled(DB& db, const Q& q, int k_nn, unsigned nthreads) {
175175
return vq_query_heap_tiled(
176-
without_ids{}, db, q, std::vector<size_t>{}, k_nn, nthreads);
176+
without_ids{}, db, q, std::vector<uint64_t>{}, k_nn, nthreads);
177177
}
178178

179179
template <class DB, class Q, class ID>
@@ -192,11 +192,11 @@ auto vq_query_heap_tiled(
192192
unsigned nthreads) {
193193
// @todo Need to get the total number of queries, not just the first block
194194
// @todo Use Matrix here rather than vector of vectors
195-
195+
196196
// using feature_type = typename std::remove_reference_t<decltype(db)>::value_type;
197197
using id_type = typename std::remove_reference_t<decltype(ids)>::value_type;
198198
using score_type = float;
199-
199+
200200
std::vector<std::vector<fixed_min_pair_heap<score_type, id_type>>> scores(
201201
nthreads,
202202
std::vector<fixed_min_pair_heap<score_type, id_type>>(
@@ -255,7 +255,7 @@ auto vq_query_heap_2(
255255
template <class DB, class Q>
256256
auto vq_query_heap_2(DB& db, const Q& q, int k_nn, unsigned nthreads) {
257257
return vq_query_heap_2(
258-
without_ids{}, db, q, std::vector<size_t>{}, k_nn, nthreads);
258+
without_ids{}, db, q, std::vector<uint64_t>{}, k_nn, nthreads);
259259
}
260260

261261
template <class DB, class Q, class ID>

0 commit comments

Comments
 (0)