Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
/data/users/matthijs/github_faiss/faiss/index_io.h
1 
2 /**
3  * Copyright (c) 2015-present, Facebook, Inc.
4  * All rights reserved.
5  *
6  * This source code is licensed under the CC-by-NC license found in the
7  * LICENSE file in the root directory of this source tree.
8  */
9 
10 // Copyright 2004-present Facebook. All Rights Reserved
11 // -*- c++ -*-
12 // I/O code for indexes
13 
14 #ifndef FAISS_INDEX_IO_H
15 #define FAISS_INDEX_IO_H
16 
17 #include <cstdio>
18 
19 namespace faiss {
20 
21 struct Index;
22 struct VectorTransform;
23 struct IndexIVF;
24 struct ProductQuantizer;
25 
26 void write_index (const Index *idx, FILE *f);
27 void write_index (const Index *idx, const char *fname);
28 
29 /**
30  * mmap'ing currently works only for IndexIVFPQCompact, the
31  * IndexIVFPQCompact destructor will unmap the file.
32  */
33 Index *read_index (FILE * f, bool try_mmap = false);
34 Index *read_index (const char *fname, bool try_mmap = false);
35 
36 
37 
38 void write_VectorTransform (const VectorTransform *vt, const char *fname);
39 VectorTransform *read_VectorTransform (const char *fname);
40 
41 ProductQuantizer * read_ProductQuantizer (const char*fname);
42 void write_ProductQuantizer (const ProductQuantizer*pq, const char *fname);
43 
44 
45 
46 /* cloning functions */
47 Index *clone_index (const Index *);
48 
49 /** Cloner class, useful to override classes with other cloning
50  * functions. The cloning function above just calls
51  * Cloner::clone_Index. */
52 struct Cloner {
53  virtual VectorTransform *clone_VectorTransform (const VectorTransform *);
54  virtual Index *clone_Index (const Index *);
55  virtual IndexIVF *clone_IndexIVF (const IndexIVF *);
56  virtual ~Cloner() {}
57 };
58 
59 }
60 
61 #endif
Index * read_index(FILE *f, bool try_mmap)
Definition: index_io.cpp:476