diff --git a/faiss/impl/index_read.cpp b/faiss/impl/index_read.cpp index aa041c0fac..b3350d236b 100644 --- a/faiss/impl/index_read.cpp +++ b/faiss/impl/index_read.cpp @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +#include #include #include @@ -61,7 +62,7 @@ namespace faiss { * Read **************************************************************/ -static void read_index_header(Index* idx, IOReader* f) { +void read_index_header(Index* idx, IOReader* f) { READ1(idx->d); READ1(idx->ntotal); idx_t dummy; @@ -230,7 +231,7 @@ InvertedLists* read_InvertedLists(IOReader* f, int io_flags) { } } -static void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) { +void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags) { InvertedLists* ils = read_InvertedLists(f, io_flags); if (ils) { FAISS_THROW_IF_NOT(ils->nlist == ivf->nlist); @@ -438,7 +439,7 @@ ProductQuantizer* read_ProductQuantizer(IOReader* reader) { return pq; } -static void read_direct_map(DirectMap* dm, IOReader* f) { +void read_direct_map(DirectMap* dm, IOReader* f) { char maintain_direct_map; READ1(maintain_direct_map); dm->type = (DirectMap::Type)maintain_direct_map; @@ -454,10 +455,10 @@ static void read_direct_map(DirectMap* dm, IOReader* f) { } } -static void read_ivf_header( +void read_ivf_header( IndexIVF* ivf, IOReader* f, - std::vector>* ids = nullptr) { + std::vector>* ids) { read_index_header(ivf, f); READ1(ivf->nlist); READ1(ivf->nprobe); diff --git a/faiss/impl/index_read_utils.h b/faiss/impl/index_read_utils.h new file mode 100644 index 0000000000..0d31e4b600 --- /dev/null +++ b/faiss/impl/index_read_utils.h @@ -0,0 +1,30 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// Utils for index_read + +#ifndef FAISS_INDEX_READ_UTILS_H +#define FAISS_INDEX_READ_UTILS_H + +#include +#include + +#pragma once + +namespace faiss { + +void read_index_header(Index* idx, IOReader* f); +void read_direct_map(DirectMap* dm, IOReader* f); +void read_ivf_header( + IndexIVF* ivf, + IOReader* f, + std::vector>* ids = nullptr); +void read_InvertedLists(IndexIVF* ivf, IOReader* f, int io_flags); + +} // namespace faiss + +#endif