Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct CommonData {
};

CommonData cd;

std::string temp_filename_template = "/tmp/faiss_tmp_XXXXXX";
/// perform a search on shards, then merge and search again and
/// compare results.
int compare_merged(
Expand All @@ -71,7 +71,7 @@ int compare_merged(
std::vector<float> refD(k * nq);

index_shards->search(nq, cd.queries.data(), k, refD.data(), refI.data());
Tempfilename filename(&temp_file_mutex, "/tmp/faiss_tmp_XXXXXX");
Tempfilename filename(&temp_file_mutex, temp_filename_template);

std::vector<idx_t> newI(k * nq);
std::vector<float> newD(k * nq);
Expand Down Expand Up @@ -191,7 +191,7 @@ TEST(MERGE, merge_flat_vt) {
TEST(MERGE, merge_flat_ondisk) {
faiss::IndexShards index_shards(d, false, false);
index_shards.own_indices = true;
Tempfilename filename(&temp_file_mutex, "/tmp/faiss_tmp_XXXXXX");
Tempfilename filename(&temp_file_mutex, temp_filename_template);

for (int i = 0; i < nindex; i++) {
auto ivf = new faiss::IndexIVFFlat(&cd.quantizer, d, nlist);
Expand Down
7 changes: 3 additions & 4 deletions tests/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@

#include <faiss/IndexIVFPQ.h>
#include <unistd.h>
#include <cstdlib>

struct Tempfilename {
pthread_mutex_t* mutex;
std::string filename;

Tempfilename(pthread_mutex_t* mutex, std::string filename) {
Tempfilename(pthread_mutex_t* mutex, std::string filename_template) {
this->mutex = mutex;
this->filename = filename;
this->filename = filename_template;
pthread_mutex_lock(mutex);
int fd = mkstemp(&filename[0]);
int fd = mkstemp(&this->filename[0]);
close(fd);
pthread_mutex_unlock(mutex);
}
Expand Down