Skip to content

Commit 001b772

Browse files
authored
Rename nlist to partitions (#551)
1 parent 36978a6 commit 001b772

9 files changed

Lines changed: 94 additions & 92 deletions

File tree

apis/python/src/tiledb/vector_search/ivf_pq_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def create(
226226
id_type=np.dtype(np.uint64).name,
227227
partitioning_index_type=np.dtype(np.uint64).name,
228228
dimensions=dimensions,
229-
n_list=partitions if (partitions is not None and partitions != -1) else 0,
229+
partitions=partitions if (partitions is not None and partitions != -1) else 0,
230230
num_subspaces=num_subspaces,
231231
distance_metric=int(distance_metric),
232232
)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,11 @@ void init_type_erased_module(py::module_& m) {
506506
"train",
507507
[](IndexIVFPQ& index,
508508
const FeatureVectorArray& vectors,
509-
std::optional<size_t> nlist) { index.train(vectors, nlist); },
509+
std::optional<size_t> partitions) {
510+
index.train(vectors, partitions);
511+
},
510512
py::arg("vectors"),
511-
py::arg("nlist") = std::nullopt)
513+
py::arg("partitions") = std::nullopt)
512514
.def(
513515
"add",
514516
[](IndexIVFPQ& index, const FeatureVectorArray& vectors) {

src/include/api/ivf_flat_index.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ class IndexIVFFlat {
100100
for (auto&& c : *config) {
101101
auto key = c.first;
102102
auto value = c.second;
103-
if (key == "nlist") {
104-
nlist_ = std::stol(value);
103+
if (key == "partitions") {
104+
partitions_ = std::stol(value);
105105
} else if (key == "dimensions") {
106106
dimensions_ = std::stol(value);
107107
} else if (key == "max_iter") {
@@ -255,12 +255,12 @@ class IndexIVFFlat {
255255
" != " + std::to_string(index_->dimensions()));
256256
}
257257
dimensions_ = index_->dimensions();
258-
if (nlist_ != 0 && nlist_ != index_->num_partitions()) {
258+
if (partitions_ != 0 && partitions_ != index_->num_partitions()) {
259259
throw std::runtime_error(
260-
"nlist mismatch: " + std::to_string(nlist_) +
260+
"partitions mismatch: " + std::to_string(partitions_) +
261261
" != " + std::to_string(index_->num_partitions()));
262262
}
263-
nlist_ = index_->num_partitions();
263+
partitions_ = index_->num_partitions();
264264
}
265265

266266
/**
@@ -292,49 +292,49 @@ class IndexIVFFlat {
292292
px_datatype_ == TILEDB_UINT32) {
293293
index_ = std::make_unique<
294294
index_impl<ivf_flat_index<uint8_t, uint32_t, uint32_t>>>(
295-
nlist_, max_iterations_, tolerance_, num_threads_);
295+
partitions_, max_iterations_, tolerance_, num_threads_);
296296
} else if (
297297
feature_datatype_ == TILEDB_FLOAT32 && id_datatype_ == TILEDB_UINT32 &&
298298
px_datatype_ == TILEDB_UINT32) {
299299
index_ = std::make_unique<
300300
index_impl<ivf_flat_index<float, uint32_t, uint32_t>>>(
301-
nlist_, max_iterations_, tolerance_, num_threads_);
301+
partitions_, max_iterations_, tolerance_, num_threads_);
302302
} else if (
303303
feature_datatype_ == TILEDB_UINT8 && id_datatype_ == TILEDB_UINT32 &&
304304
px_datatype_ == TILEDB_UINT64) {
305305
index_ = std::make_unique<
306306
index_impl<ivf_flat_index<uint8_t, uint32_t, uint64_t>>>(
307-
nlist_, max_iterations_, tolerance_, num_threads_);
307+
partitions_, max_iterations_, tolerance_, num_threads_);
308308
} else if (
309309
feature_datatype_ == TILEDB_FLOAT32 && id_datatype_ == TILEDB_UINT32 &&
310310
px_datatype_ == TILEDB_UINT64) {
311311
index_ = std::make_unique<
312312
index_impl<ivf_flat_index<float, uint32_t, uint64_t>>>(
313-
nlist_, max_iterations_, tolerance_, num_threads_);
313+
partitions_, max_iterations_, tolerance_, num_threads_);
314314
} else if (
315315
feature_datatype_ == TILEDB_UINT8 && id_datatype_ == TILEDB_UINT64 &&
316316
px_datatype_ == TILEDB_UINT32) {
317317
index_ = std::make_unique<
318318
index_impl<ivf_flat_index<uint8_t, uint64_t, uint32_t>>>(
319-
nlist_, max_iterations_, tolerance_, num_threads_);
319+
partitions_, max_iterations_, tolerance_, num_threads_);
320320
} else if (
321321
feature_datatype_ == TILEDB_FLOAT32 && id_datatype_ == TILEDB_UINT64 &&
322322
px_datatype_ == TILEDB_UINT32) {
323323
index_ = std::make_unique<
324324
index_impl<ivf_flat_index<float, uint64_t, uint32_t>>>(
325-
nlist_, max_iterations_, tolerance_, num_threads_);
325+
partitions_, max_iterations_, tolerance_, num_threads_);
326326
} else if (
327327
feature_datatype_ == TILEDB_UINT8 && id_datatype_ == TILEDB_UINT64 &&
328328
px_datatype_ == TILEDB_UINT64) {
329329
index_ = std::make_unique<
330330
index_impl<ivf_flat_index<uint8_t, uint64_t, uint64_t>>>(
331-
nlist_, max_iterations_, tolerance_, num_threads_);
331+
partitions_, max_iterations_, tolerance_, num_threads_);
332332
} else if (
333333
feature_datatype_ == TILEDB_FLOAT32 && id_datatype_ == TILEDB_UINT64 &&
334334
px_datatype_ == TILEDB_UINT64) {
335335
index_ = std::make_unique<
336336
index_impl<ivf_flat_index<float, uint64_t, uint64_t>>>(
337-
nlist_, max_iterations_, tolerance_, num_threads_);
337+
partitions_, max_iterations_, tolerance_, num_threads_);
338338
}
339339

340340
index_->train(training_set, init);
@@ -346,12 +346,12 @@ class IndexIVFFlat {
346346
}
347347
dimensions_ = index_->dimensions();
348348

349-
if (nlist_ != 0 && nlist_ != index_->num_partitions()) {
349+
if (partitions_ != 0 && partitions_ != index_->num_partitions()) {
350350
throw std::runtime_error(
351-
"nlist mismatch: " + std::to_string(nlist_) +
351+
"partitions mismatch: " + std::to_string(partitions_) +
352352
" != " + std::to_string(index_->num_partitions()));
353353
}
354-
nlist_ = index_->num_partitions();
354+
partitions_ = index_->num_partitions();
355355
}
356356

357357
/**
@@ -440,7 +440,7 @@ class IndexIVFFlat {
440440
}
441441

442442
constexpr auto num_partitions() const {
443-
return nlist_;
443+
return partitions_;
444444
}
445445

446446
constexpr tiledb_datatype_t feature_type() const {
@@ -523,11 +523,11 @@ class IndexIVFFlat {
523523
}
524524

525525
index_impl(
526-
size_t nlist,
526+
size_t partitions,
527527
size_t max_iter,
528528
float tolerance,
529529
std::optional<size_t> num_threads)
530-
: impl_index_(nlist, max_iter, tolerance) {
530+
: impl_index_(partitions, max_iter, tolerance) {
531531
}
532532

533533
index_impl(
@@ -717,7 +717,7 @@ class IndexIVFFlat {
717717
};
718718

719719
uint64_t dimensions_ = 0;
720-
size_t nlist_ = 0;
720+
size_t partitions_ = 0;
721721
uint32_t max_iterations_ = 2;
722722
float tolerance_ = 1e-4;
723723
std::optional<size_t> num_threads_ = std::nullopt;

0 commit comments

Comments
 (0)