Skip to content

Commit aaf4f9b

Browse files
Michael Norrisfacebook-github-bot
Michael Norris
authored andcommitted
Move static functions to header file (#3757)
Summary: Pull Request resolved: #3757 In the telemetry wrapper, we need to wrap read_index to return wrapped index structs. D61049751 This read_index wrapper calls several static functions. These are not callable outside a C++ file. Thus this diff changes them to non static and declares them in the header file. Then the wrapper is able to call them. Differential Revision: D61282004
1 parent afe9c40 commit aaf4f9b

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

faiss/impl/index_read.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace faiss {
6161
* Read
6262
**************************************************************/
6363

64-
static void read_index_header(Index* idx, IOReader* f) {
64+
void read_index_header(Index* idx, IOReader* f) {
6565
READ1(idx->d);
6666
READ1(idx->ntotal);
6767
idx_t dummy;
@@ -230,7 +230,7 @@ InvertedLists* read_InvertedLists(IOReader* f, int io_flags) {
230230
}
231231
}
232232

233-
static void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) {
233+
void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) {
234234
InvertedLists* ils = read_InvertedLists(f, io_flags);
235235
if (ils) {
236236
FAISS_THROW_IF_NOT(ils->nlist == ivf->nlist);
@@ -438,7 +438,7 @@ ProductQuantizer* read_ProductQuantizer(IOReader* reader) {
438438
return pq;
439439
}
440440

441-
static void read_direct_map(DirectMap* dm, IOReader* f) {
441+
void read_direct_map(DirectMap* dm, IOReader* f) {
442442
char maintain_direct_map;
443443
READ1(maintain_direct_map);
444444
dm->type = (DirectMap::Type)maintain_direct_map;
@@ -454,10 +454,10 @@ static void read_direct_map(DirectMap* dm, IOReader* f) {
454454
}
455455
}
456456

457-
static void read_ivf_header(
457+
void read_ivf_header(
458458
IndexIVF* ivf,
459459
IOReader* f,
460-
std::vector<std::vector<idx_t>>* ids = nullptr) {
460+
std::vector<std::vector<idx_t>>* ids) {
461461
read_index_header(ivf, f);
462462
READ1(ivf->nlist);
463463
READ1(ivf->nprobe);

faiss/index_io.h

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef FAISS_INDEX_IO_H
1111
#define FAISS_INDEX_IO_H
1212

13+
#include <faiss/IndexIVF.h>
1314
#include <cstdio>
1415
#include <string>
1516
#include <typeinfo>
@@ -86,6 +87,14 @@ void write_ProductQuantizer(const ProductQuantizer* pq, IOWriter* f);
8687
void write_InvertedLists(const InvertedLists* ils, IOWriter* f);
8788
InvertedLists* read_InvertedLists(IOReader* reader, int io_flags = 0);
8889

90+
void read_index_header(Index* idx, IOReader* f);
91+
void read_direct_map(DirectMap* dm, IOReader* f);
92+
void read_ivf_header(
93+
IndexIVF* ivf,
94+
IOReader* f,
95+
std::vector<std::vector<idx_t>>* ids = nullptr);
96+
void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags);
97+
8998
} // namespace faiss
9099

91100
#endif

0 commit comments

Comments
 (0)