mirror of
https://github.com/facebookresearch/faiss.git
synced 2025-06-03 21:54:02 +08:00
Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3999 Fixed the bug causing `merge_flat_ondisk` stress run failures. Running multiple `merge_flat_ondisk` tests simultaneously fails which is causing buck stress-run failures. https://www.internalfb.com/intern/test/562950025349567/ Root cause: we were updating input copy (which was discarded) of the filename template instead of the local copy. Reviewed By: asadoughi Differential Revision: D65074463 fbshipit-source-id: 9f86deeb56975a3be7a15a8f56d602463cad61af
39 lines
883 B
C++
39 lines
883 B
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#ifndef FAISS_TEST_UTIL_H
|
|
#define FAISS_TEST_UTIL_H
|
|
|
|
#include <faiss/IndexIVFPQ.h>
|
|
#include <unistd.h>
|
|
|
|
struct Tempfilename {
|
|
pthread_mutex_t* mutex;
|
|
std::string filename;
|
|
|
|
Tempfilename(pthread_mutex_t* mutex, std::string filename_template) {
|
|
this->mutex = mutex;
|
|
this->filename = filename_template;
|
|
pthread_mutex_lock(mutex);
|
|
int fd = mkstemp(&this->filename[0]);
|
|
close(fd);
|
|
pthread_mutex_unlock(mutex);
|
|
}
|
|
|
|
~Tempfilename() {
|
|
if (access(filename.c_str(), F_OK)) {
|
|
unlink(filename.c_str());
|
|
}
|
|
}
|
|
|
|
const char* c_str() {
|
|
return filename.c_str();
|
|
}
|
|
};
|
|
|
|
#endif // FAISS_TEST_UTIL_H
|