Skip to content

Commit ed8d52a

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 c0b32d2 commit ed8d52a

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

faiss/impl/index_read.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#include <faiss/impl/index_read_utils.h>
89
#include <faiss/index_io.h>
910

1011
#include <faiss/impl/io_macros.h>
@@ -61,7 +62,7 @@ namespace faiss {
6162
* Read
6263
**************************************************************/
6364

64-
static void read_index_header(Index* idx, IOReader* f) {
65+
void read_index_header(Index* idx, IOReader* f) {
6566
READ1(idx->d);
6667
READ1(idx->ntotal);
6768
idx_t dummy;
@@ -230,7 +231,7 @@ InvertedLists* read_InvertedLists(IOReader* f, int io_flags) {
230231
}
231232
}
232233

233-
static void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) {
234+
void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) {
234235
InvertedLists* ils = read_InvertedLists(f, io_flags);
235236
if (ils) {
236237
FAISS_THROW_IF_NOT(ils->nlist == ivf->nlist);
@@ -438,7 +439,7 @@ ProductQuantizer* read_ProductQuantizer(IOReader* reader) {
438439
return pq;
439440
}
440441

441-
static void read_direct_map(DirectMap* dm, IOReader* f) {
442+
void read_direct_map(DirectMap* dm, IOReader* f) {
442443
char maintain_direct_map;
443444
READ1(maintain_direct_map);
444445
dm->type = (DirectMap::Type)maintain_direct_map;
@@ -454,10 +455,10 @@ static void read_direct_map(DirectMap* dm, IOReader* f) {
454455
}
455456
}
456457

457-
static void read_ivf_header(
458+
void read_ivf_header(
458459
IndexIVF* ivf,
459460
IOReader* f,
460-
std::vector<std::vector<idx_t>>* ids = nullptr) {
461+
std::vector<std::vector<idx_t>>* ids) {
461462
read_index_header(ivf, f);
462463
READ1(ivf->nlist);
463464
READ1(ivf->nprobe);

faiss/impl/index_read_utils.h

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Utils for index_read
9+
10+
#ifndef FAISS_INDEX_READ_UTILS_H
11+
#define FAISS_INDEX_READ_UTILS_H
12+
13+
#include <faiss/IndexIVF.h>
14+
#include <faiss/impl/io.h>
15+
16+
#pragma once
17+
18+
namespace faiss {
19+
20+
void read_index_header(Index* idx, IOReader* f);
21+
void read_direct_map(DirectMap* dm, IOReader* f);
22+
void read_ivf_header(
23+
IndexIVF* ivf,
24+
IOReader* f,
25+
std::vector<std::vector<idx_t>>* ids = nullptr);
26+
void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags);
27+
28+
} // namespace faiss
29+
30+
#endif

0 commit comments

Comments
 (0)