From 78c41facf82d5297c857617ce1afcbeeba456211 Mon Sep 17 00:00:00 2001 From: Huisheng Liu Date: Tue, 3 Oct 2023 11:13:20 -0700 Subject: [PATCH 1/2] add check for .enc extension to support encryption --- include/utils.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/include/utils.h b/include/utils.h index 195dd95ef..bb03d13f1 100644 --- a/include/utils.h +++ b/include/utils.h @@ -57,7 +57,7 @@ typedef int FileHandle; #define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" #define PBWIDTH 60 -inline bool file_exists(const std::string &name, bool dirCheck = false) +inline bool file_exists_impl(const std::string &name, bool dirCheck = false) { int val; #ifndef _WINDOWS @@ -94,6 +94,29 @@ inline bool file_exists(const std::string &name, bool dirCheck = false) } } +inline bool file_exists(const std::string &name, bool dirCheck = false) +{ +#ifdef EXEC_ENV_OLS + bool exists = file_exists_impl(name, dirCheck); + if (exists) + { + return true; + } + if (!dirCheck) + { + // try with .enc extension + std::string enc_name = name + ENCRYPTED_EXTENSION; + return file_exists_impl(enc_name, dirCheck); + } + else + { + return exists; + } +#else + return file_exists_impl(name, dirCheck); +#endif +} + inline void open_file_to_write(std::ofstream &writer, const std::string &filename) { writer.exceptions(std::ofstream::failbit | std::ofstream::badbit); From b3e461099bde906da39a2a176512ce794dfe1769 Mon Sep 17 00:00:00 2001 From: Huisheng Liu Date: Wed, 4 Oct 2023 11:11:36 -0700 Subject: [PATCH 2/2] check rotation_matrix file in file blobs --- src/pq.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pq.cpp b/src/pq.cpp index 86c68ce0a..c59fc2dce 100644 --- a/src/pq.cpp +++ b/src/pq.cpp @@ -133,11 +133,13 @@ void FixedChunkPQTable::load_pq_centroid_bin(const char *pq_table_file, size_t n diskann::cout << "Loaded PQ Pivots: #ctrs: " << NUM_PQ_CENTROIDS << ", #dims: " << this->ndims << ", #chunks: " << this->n_chunks << std::endl; - if (file_exists(rotmat_file)) - { #ifdef EXEC_ENV_OLS + if (files.fileExists(rotmat_file)) + { diskann::load_bin(files, rotmat_file, (float *&)rotmat_tr, nr, nc); #else + if (file_exists(rotmat_file)) + { diskann::load_bin(rotmat_file, rotmat_tr, nr, nc); #endif if (nr != this->ndims || nc != this->ndims)