diff --git a/c_api/AutoTune_c.cpp b/c_api/AutoTune_c.cpp index 70be977efc..008d6f8482 100644 --- a/c_api/AutoTune_c.cpp +++ b/c_api/AutoTune_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/AutoTune_c.h b/c_api/AutoTune_c.h index 3709a3eb39..908f355a4d 100644 --- a/c_api/AutoTune_c.h +++ b/c_api/AutoTune_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/AuxIndexStructures_c.cpp b/c_api/AuxIndexStructures_c.cpp index f8bb373fde..c1ef0dc8c0 100644 --- a/c_api/AuxIndexStructures_c.cpp +++ b/c_api/AuxIndexStructures_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -14,14 +13,13 @@ #include "macros_impl.h" #include -extern "C" { - using faiss::BufferList; using faiss::IDSelector; using faiss::IDSelectorBatch; using faiss::IDSelectorRange; using faiss::RangeSearchResult; using faiss::RangeSearchPartialResult; +using faiss::RangeQueryResult; DEFINE_GETTER(RangeSearchResult, size_t, nq) @@ -140,6 +138,17 @@ int faiss_BufferList_copy_range( } CATCH_AND_HANDLE } +DEFINE_GETTER(RangeQueryResult, idx_t, qno) +DEFINE_GETTER(RangeQueryResult, size_t, nres) +DEFINE_GETTER_PERMISSIVE(RangeQueryResult, FaissRangeSearchPartialResult*, pres) + +int faiss_RangeQueryResult_add(FaissRangeQueryResult* qr, float dis, idx_t id) { + try { + reinterpret_cast(qr)->add(dis, id); + return 0; + } CATCH_AND_HANDLE +} + DEFINE_GETTER_PERMISSIVE(RangeSearchPartialResult, FaissRangeSearchResult*, res) int faiss_RangeSearchPartialResult_new( @@ -170,38 +179,15 @@ int faiss_RangeSearchPartialResult_set_lims( } CATCH_AND_HANDLE } -/// called by range_search after do_allocation -int faiss_RangeSearchPartialResult_set_result( - FaissRangeSearchPartialResult* res, int incremental) { - try { - reinterpret_cast(res)->set_result( - static_cast(incremental)); - return 0; - } CATCH_AND_HANDLE -} - -DEFINE_GETTER_SUBCLASS(QueryResult, RangeSearchPartialResult, idx_t, qno) -DEFINE_GETTER_SUBCLASS(QueryResult, RangeSearchPartialResult, size_t, nres) -DEFINE_GETTER_SUBCLASS_PERMISSIVE(QueryResult, RangeSearchPartialResult, FaissRangeSearchPartialResult*, pres) - int faiss_RangeSearchPartialResult_new_result( - FaissRangeSearchPartialResult* res, idx_t qno, FaissQueryResult** qr) { + FaissRangeSearchPartialResult* res, idx_t qno, FaissRangeQueryResult** qr) { try { - RangeSearchPartialResult::QueryResult* q = + auto q = &reinterpret_cast(res)->new_result(qno); if (qr) { - *qr = reinterpret_cast(q); + *qr = reinterpret_cast(&q); } return 0; } CATCH_AND_HANDLE } - -int faiss_QueryResult_add(FaissQueryResult* qr, float dis, idx_t id) { - try { - reinterpret_cast(qr)->add(dis, id); - return 0; - } CATCH_AND_HANDLE -} - -} diff --git a/c_api/AuxIndexStructures_c.h b/c_api/AuxIndexStructures_c.h index dc3c29e22a..b7cbad9e39 100644 --- a/c_api/AuxIndexStructures_c.h +++ b/c_api/AuxIndexStructures_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -103,6 +102,15 @@ int faiss_BufferList_copy_range( /// the entries in the buffers are split per query FAISS_DECLARE_CLASS(RangeSearchPartialResult) +/// result structure for a single query +FAISS_DECLARE_CLASS(RangeQueryResult) +FAISS_DECLARE_GETTER(RangeQueryResult, idx_t, qno) +FAISS_DECLARE_GETTER(RangeQueryResult, size_t, nres) +FAISS_DECLARE_GETTER(RangeQueryResult, FaissRangeSearchPartialResult*, pres) + +int faiss_RangeQueryResult_add(FaissRangeQueryResult* qr, float dis, idx_t id); + + FAISS_DECLARE_GETTER(RangeSearchPartialResult, FaissRangeSearchResult*, res) int faiss_RangeSearchPartialResult_new( @@ -115,20 +123,8 @@ int faiss_RangeSearchPartialResult_finalize( int faiss_RangeSearchPartialResult_set_lims( FaissRangeSearchPartialResult* res); -/// called by range_search after do_allocation -int faiss_RangeSearchPartialResult_set_result( - FaissRangeSearchPartialResult* res, int incremental); - -/// result structure for a single query -FAISS_DECLARE_CLASS(QueryResult) -FAISS_DECLARE_GETTER(QueryResult, idx_t, qno) -FAISS_DECLARE_GETTER(QueryResult, size_t, nres) -FAISS_DECLARE_GETTER(QueryResult, FaissRangeSearchPartialResult*, pres) - int faiss_RangeSearchPartialResult_new_result( - FaissRangeSearchPartialResult* res, idx_t qno, FaissQueryResult** qr); - -int faiss_QueryResult_add(FaissQueryResult* qr, float dis, idx_t id); + FaissRangeSearchPartialResult* res, idx_t qno, FaissRangeQueryResult** qr); #ifdef __cplusplus } diff --git a/c_api/Clustering_c.cpp b/c_api/Clustering_c.cpp index f7951a5e99..1687ed1e45 100644 --- a/c_api/Clustering_c.cpp +++ b/c_api/Clustering_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/Clustering_c.h b/c_api/Clustering_c.h index 768e434b35..75f25ba4f5 100644 --- a/c_api/Clustering_c.h +++ b/c_api/Clustering_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexFlat_c.cpp b/c_api/IndexFlat_c.cpp index ba3454ceb4..4b741922e8 100644 --- a/c_api/IndexFlat_c.cpp +++ b/c_api/IndexFlat_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexFlat_c.h b/c_api/IndexFlat_c.h index 4f45c98553..072ba7dcf3 100644 --- a/c_api/IndexFlat_c.h +++ b/c_api/IndexFlat_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexIVFFlat_c.cpp b/c_api/IndexIVFFlat_c.cpp index 3930f53e8b..a93e22e3b7 100644 --- a/c_api/IndexIVFFlat_c.cpp +++ b/c_api/IndexIVFFlat_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexIVFFlat_c.h b/c_api/IndexIVFFlat_c.h index a8b27f17f2..84e2d79b36 100644 --- a/c_api/IndexIVFFlat_c.h +++ b/c_api/IndexIVFFlat_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexIVF_c.cpp b/c_api/IndexIVF_c.cpp index 53fcaa3938..92469a16e5 100644 --- a/c_api/IndexIVF_c.cpp +++ b/c_api/IndexIVF_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -80,12 +79,12 @@ int faiss_IndexIVF_make_direct_map(FaissIndexIVF* index, } double faiss_IndexIVF_imbalance_factor (const FaissIndexIVF* index) { - return reinterpret_cast(index)->imbalance_factor(); + return reinterpret_cast(index)->invlists->imbalance_factor(); } /// display some stats about the inverted lists void faiss_IndexIVF_print_stats (const FaissIndexIVF* index) { - reinterpret_cast(index)->print_stats(); + reinterpret_cast(index)->invlists->print_stats(); } void faiss_IndexIVFStats_reset(FaissIndexIVFStats* stats) { diff --git a/c_api/IndexIVF_c.h b/c_api/IndexIVF_c.h index 0d2459d8ed..c35def97cf 100644 --- a/c_api/IndexIVF_c.h +++ b/c_api/IndexIVF_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -106,10 +105,13 @@ size_t faiss_IndexIVF_get_list_size(const FaissIndexIVF* index, int faiss_IndexIVF_make_direct_map(FaissIndexIVF* index, int new_maintain_direct_map); -/// 1= perfectly balanced, >1: imbalanced +/** Check the inverted lists' imbalance factor. + * + * 1= perfectly balanced, >1: imbalanced + */ double faiss_IndexIVF_imbalance_factor (const FaissIndexIVF* index); -/// display some stats about the inverted lists +/// display some stats about the inverted lists of the index void faiss_IndexIVF_print_stats (const FaissIndexIVF* index); diff --git a/c_api/IndexLSH_c.cpp b/c_api/IndexLSH_c.cpp index 7e29ac852c..39a348f807 100644 --- a/c_api/IndexLSH_c.cpp +++ b/c_api/IndexLSH_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexLSH_c.h b/c_api/IndexLSH_c.h index 136b4dd98c..4a3dab418d 100644 --- a/c_api/IndexLSH_c.h +++ b/c_api/IndexLSH_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/IndexShards_c.cpp b/c_api/IndexShards_c.cpp new file mode 100644 index 0000000000..e66aeb7ed0 --- /dev/null +++ b/c_api/IndexShards_c.cpp @@ -0,0 +1,44 @@ +#include "IndexShards_c.h" +#include "IndexShards.h" +#include "macros_impl.h" + +using faiss::Index; +using faiss::IndexShards; + +DEFINE_GETTER(IndexShards, int, own_fields) +DEFINE_SETTER(IndexShards, int, own_fields) + +DEFINE_GETTER(IndexShards, int, successive_ids) +DEFINE_SETTER(IndexShards, int, successive_ids) + +int faiss_IndexShards_new(FaissIndexShards** p_index, idx_t d) { + try { + auto out = new IndexShards(d); + *p_index = reinterpret_cast(out); + } CATCH_AND_HANDLE +} + +int faiss_IndexShards_new_with_options(FaissIndexShards** p_index, idx_t d, int threaded, int successive_ids) { + try { + auto out = new IndexShards(d, static_cast(threaded), static_cast(successive_ids)); + *p_index = reinterpret_cast(out); + } CATCH_AND_HANDLE +} + +int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard) { + try { + reinterpret_cast(index)->add_shard( + reinterpret_cast(shard)); + } CATCH_AND_HANDLE +} + +int faiss_IndexShards_sync_with_shard_indexes(FaissIndexShards* index) { + try { + reinterpret_cast(index)->sync_with_shard_indexes(); + } CATCH_AND_HANDLE +} + +FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i) { + auto shard = reinterpret_cast(index)->at(i); + return reinterpret_cast(shard); +} diff --git a/c_api/IndexShards_c.h b/c_api/IndexShards_c.h new file mode 100644 index 0000000000..7e6a30b2a9 --- /dev/null +++ b/c_api/IndexShards_c.h @@ -0,0 +1,42 @@ +/** + * 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. + */ + +// Copyright 2004-present Facebook. All Rights Reserved. +// -*- c++ -*- + +#ifndef INDEXSHARDS_C_H +#define INDEXSHARDS_C_H + +#include "faiss_c.h" +#include "Index_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** Index that concatenates the results from several sub-indexes + */ +FAISS_DECLARE_CLASS_INHERITED(IndexShards, Index) + +FAISS_DECLARE_GETTER_SETTER(IndexShards, int, own_fields) +FAISS_DECLARE_GETTER_SETTER(IndexShards, int, successive_ids) + +int faiss_IndexShards_new(FaissIndexShards** p_index, idx_t d); + +int faiss_IndexShards_new_with_options(FaissIndexShards** p_index, idx_t d, int threaded, int successive_ids); + +int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard); + +/// update metric_type and ntotal +int faiss_IndexShards_sync_with_shard_indexes(FaissIndexShards* index); + +FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i); + +#ifdef __cplusplus +} +#endif +#endif \ No newline at end of file diff --git a/c_api/Index_c.cpp b/c_api/Index_c.cpp index e1e426253e..a0773e9ae9 100644 --- a/c_api/Index_c.cpp +++ b/c_api/Index_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/Index_c.h b/c_api/Index_c.h index be4787f428..1b456ad8f4 100644 --- a/c_api/Index_c.h +++ b/c_api/Index_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/Makefile b/c_api/Makefile index 5795a1ddad..b3a3061b7c 100644 --- a/c_api/Makefile +++ b/c_api/Makefile @@ -1,7 +1,6 @@ -# Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. +# Copyright (c) Facebook, Inc. and its affiliates. # -# This source code is licensed under the BSD+Patents license found in the +# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. .SUFFIXES: .cpp .o @@ -13,8 +12,9 @@ DEBUGFLAG=-DNDEBUG # no debugging LIBNAME=libfaiss CLIBNAME=libfaiss_c -LIBCOBJ=error_impl.o Index_c.o IndexFlat_c.o Clustering_c.o AuxIndexStructures_c.o \ - AutoTune_c.o IndexIVF_c.o IndexIVFFlat_c.o IndexLSH_c.o index_io_c.o MetaIndexes_c.o +LIBCOBJ=error_impl.o Index_c.o IndexFlat_c.o Clustering_c.o AutoTune_c.o \ + AuxIndexStructures_c.o IndexIVF_c.o IndexIVFFlat_c.o IndexLSH_c.o \ + index_io_c.o MetaIndexes_c.o IndexShards_c.o # Build static and shared object files by default all: $(CLIBNAME).a $(CLIBNAME).$(SHAREDEXT) @@ -59,6 +59,9 @@ IndexIVFFlat_c.o: IndexIVFFlat_c.cpp IndexIVFFlat_c.h ../IndexIVFFlat.h macros_i IndexLSH_c.o: CXXFLAGS += -I.. $(DEBUGFLAG) IndexLSH_c.o: IndexLSH_c.cpp IndexLSH_c.h ../IndexLSH.h macros_impl.h +IndexShards_c.o: CXXFLAGS += -I.. $(DEBUGFLAG) +IndexShards_c.o: IndexShards_c.cpp IndexShards_c.h ../Index.h ../IndexShards.h macros_impl.h + Clustering_c.o: CXXFLAGS += -I.. $(DEBUGFLAG) Clustering_c.o: Clustering_c.cpp Clustering_c.h ../Clustering.h macros_impl.h diff --git a/c_api/MetaIndexes_c.cpp b/c_api/MetaIndexes_c.cpp index b02a9680a2..d1a6191932 100644 --- a/c_api/MetaIndexes_c.cpp +++ b/c_api/MetaIndexes_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -16,7 +15,6 @@ using faiss::Index; using faiss::IndexIDMap; using faiss::IndexIDMap2; -using faiss::IndexShards; DEFINE_GETTER(IndexIDMap, int, own_fields) DEFINE_SETTER(IndexIDMap, int, own_fields) @@ -49,58 +47,3 @@ int faiss_IndexIDMap2_construct_rev_map(FaissIndexIDMap2* index) { } CATCH_AND_HANDLE } -DEFINE_GETTER(IndexShards, int, own_fields) -DEFINE_SETTER(IndexShards, int, own_fields) - -DEFINE_GETTER(IndexShards, int, threaded) -DEFINE_SETTER(IndexShards, int, threaded) - -DEFINE_GETTER(IndexShards, int, successive_ids) -DEFINE_SETTER(IndexShards, int, successive_ids) - -int faiss_IndexShards_new(FaissIndexShards** p_index, idx_t d) { - try { - auto out = new IndexShards(d); - *p_index = reinterpret_cast(out); - } CATCH_AND_HANDLE -} - -int faiss_IndexShards_new_with_options(FaissIndexShards** p_index, idx_t d, int threaded, int successive_ids) { - try { - auto out = new IndexShards(d, static_cast(threaded), static_cast(successive_ids)); - *p_index = reinterpret_cast(out); - } CATCH_AND_HANDLE -} - -/** get a pointer to the index' shards (the `shard_indexes` field). The - * outputs of this function become invalid after any operation that can modify the index. - * - * @param index opaque pointer to index object - * @param p_shard_indexes output, the pointer to the beginning of `shard_indexes`. - * @param p_size output, the current length of `shard_indexes`. - */ -void faiss_IndexShards_shard_indexes(FaissIndexShards* index, FaissIndex** p_shard_indexes, size_t* p_size) { - auto idx = reinterpret_cast(index); - if (p_shard_indexes) - *p_shard_indexes = reinterpret_cast(idx->shard_indexes.data()); - if (p_size) - *p_size = idx->shard_indexes.size(); -} - -int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard) { - try { - reinterpret_cast(index)->add_shard( - reinterpret_cast(shard)); - } CATCH_AND_HANDLE -} - -int faiss_IndexShards_sync_with_shard_indexes(FaissIndexShards* index) { - try { - reinterpret_cast(index)->sync_with_shard_indexes(); - } CATCH_AND_HANDLE -} - -FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i) { - auto shard = reinterpret_cast(index)->at(i); - return reinterpret_cast(shard); -} diff --git a/c_api/MetaIndexes_c.h b/c_api/MetaIndexes_c.h index 2ab4ed6c82..d07bb3f906 100644 --- a/c_api/MetaIndexes_c.h +++ b/c_api/MetaIndexes_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -44,34 +43,6 @@ int faiss_IndexIDMap2_new(FaissIndexIDMap2** p_index, FaissIndex* index); /// make the rev_map from scratch int faiss_IndexIDMap2_construct_rev_map(FaissIndexIDMap2* index); -/** Index that concatenates the results from several sub-indexes - */ -FAISS_DECLARE_CLASS_INHERITED(IndexShards, Index) - -FAISS_DECLARE_GETTER_SETTER(IndexShards, int, own_fields) -FAISS_DECLARE_GETTER_SETTER(IndexShards, int, threaded) -FAISS_DECLARE_GETTER_SETTER(IndexShards, int, successive_ids) - -int faiss_IndexShards_new(FaissIndexShards** p_index, idx_t d); - -int faiss_IndexShards_new_with_options(FaissIndexShards** p_index, idx_t d, int threaded, int successive_ids); - -/** get a pointer to the index' shards (the `shard_indexes` field). The - * outputs of this function become invalid after any operation that can modify the index. - * - * @param index opaque pointer to index object - * @param p_shard_indexes output, the pointer to the beginning of `shard_indexes`. - * @param p_size output, the current length of `shard_indexes`. - */ -void faiss_IndexShards_shard_indexes(FaissIndexShards* index, FaissIndex** p_shard_indexes, size_t* p_size); - -int faiss_IndexShards_add_shard(FaissIndexShards* index, FaissIndex* shard); - -/// update metric_type and ntotal -int faiss_IndexShards_sync_with_shard_indexes(FaissIndexShards* index); - -FaissIndex* faiss_IndexShards_at(FaissIndexShards* index, int i); - #ifdef __cplusplus } #endif diff --git a/c_api/error_c.h b/c_api/error_c.h index 6fd81cd464..5aa5664feb 100644 --- a/c_api/error_c.h +++ b/c_api/error_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -16,10 +15,16 @@ extern "C" { #endif +/// An error code which depends on the exception thrown from the previous +/// operation. See `faiss_get_last_error` to retrieve the error message. typedef enum FaissErrorCode { + /// No error OK = 0, + /// Any exception other than Faiss or standard C++ library exceptions UNKNOWN_EXCEPT = -1, + /// Faiss library exception FAISS_EXCEPT = -2, + /// Standard C++ library exception STD_EXCEPT = -4 } FaissErrorCode; diff --git a/c_api/error_impl.cpp b/c_api/error_impl.cpp index 807670d54d..25793eb0e8 100644 --- a/c_api/error_impl.cpp +++ b/c_api/error_impl.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/error_impl.h b/c_api/error_impl.h index 8f72d3e8cc..b44254ad94 100644 --- a/c_api/error_impl.h +++ b/c_api/error_impl.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/example_c.c b/c_api/example_c.c index 5f4e90695d..f3d50e3af6 100644 --- a/c_api/example_c.c +++ b/c_api/example_c.c @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/faiss_c.h b/c_api/faiss_c.h index 5c9aaf2cea..3305604a85 100644 --- a/c_api/faiss_c.h +++ b/c_api/faiss_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuAutoTune_c.cpp b/c_api/gpu/GpuAutoTune_c.cpp index 1319b38dae..7336d5d7d3 100644 --- a/c_api/gpu/GpuAutoTune_c.cpp +++ b/c_api/gpu/GpuAutoTune_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuAutoTune_c.h b/c_api/gpu/GpuAutoTune_c.h index cb989d2528..5dbd15c977 100644 --- a/c_api/gpu/GpuAutoTune_c.h +++ b/c_api/gpu/GpuAutoTune_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuClonerOptions_c.cpp b/c_api/gpu/GpuClonerOptions_c.cpp index ac7772e54f..c61fc5e34c 100644 --- a/c_api/gpu/GpuClonerOptions_c.cpp +++ b/c_api/gpu/GpuClonerOptions_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuClonerOptions_c.h b/c_api/gpu/GpuClonerOptions_c.h index 7b6817b374..94ff403e7a 100644 --- a/c_api/gpu/GpuClonerOptions_c.h +++ b/c_api/gpu/GpuClonerOptions_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuIndex_c.cpp b/c_api/gpu/GpuIndex_c.cpp index 96c814f70e..bdef82766e 100644 --- a/c_api/gpu/GpuIndex_c.cpp +++ b/c_api/gpu/GpuIndex_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuIndex_c.h b/c_api/gpu/GpuIndex_c.h index 2f56738ccc..664c76101f 100644 --- a/c_api/gpu/GpuIndex_c.h +++ b/c_api/gpu/GpuIndex_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuIndicesOptions_c.h b/c_api/gpu/GpuIndicesOptions_c.h index e52bb55e25..6a49773bc6 100644 --- a/c_api/gpu/GpuIndicesOptions_c.h +++ b/c_api/gpu/GpuIndicesOptions_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuResources_c.cpp b/c_api/gpu/GpuResources_c.cpp index 2a375758e6..3f6525125d 100644 --- a/c_api/gpu/GpuResources_c.cpp +++ b/c_api/gpu/GpuResources_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/GpuResources_c.h b/c_api/gpu/GpuResources_c.h index 980bfa7101..bb9cefde36 100644 --- a/c_api/gpu/GpuResources_c.h +++ b/c_api/gpu/GpuResources_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/Makefile b/c_api/gpu/Makefile index 2fcc785e0a..a2c87b9832 100644 --- a/c_api/gpu/Makefile +++ b/c_api/gpu/Makefile @@ -1,7 +1,6 @@ -# Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. +# Copyright (c) Facebook, Inc. and its affiliates. # -# This source code is licensed under the BSD+Patents license found in the +# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. .SUFFIXES: .cpp .o diff --git a/c_api/gpu/StandardGpuResources_c.cpp b/c_api/gpu/StandardGpuResources_c.cpp index d25da77877..84afb027eb 100644 --- a/c_api/gpu/StandardGpuResources_c.cpp +++ b/c_api/gpu/StandardGpuResources_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -36,12 +35,6 @@ int faiss_StandardGpuResources_setTempMemory(FaissStandardGpuResources* res, siz } CATCH_AND_HANDLE } -int faiss_StandardGpuResources_setTempMemoryFraction(FaissStandardGpuResources* res, float fraction) { - try { - reinterpret_cast(res)->setTempMemoryFraction(fraction); - } CATCH_AND_HANDLE -} - int faiss_StandardGpuResources_setPinnedMemory(FaissStandardGpuResources* res, size_t size) { try { reinterpret_cast(res)->setPinnedMemory(size); diff --git a/c_api/gpu/StandardGpuResources_c.h b/c_api/gpu/StandardGpuResources_c.h index c87a1600f5..f9a3c854f0 100644 --- a/c_api/gpu/StandardGpuResources_c.h +++ b/c_api/gpu/StandardGpuResources_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ @@ -37,10 +36,6 @@ int faiss_StandardGpuResources_noTempMemory(FaissStandardGpuResources*); /// all devices as temporary memory int faiss_StandardGpuResources_setTempMemory(FaissStandardGpuResources*, size_t size); -/// Specify that we wish to use a certain fraction of memory on -/// all devices as temporary memory -int faiss_StandardGpuResources_setTempMemoryFraction(FaissStandardGpuResources*, float fraction); - /// Set amount of pinned memory to allocate, for async GPU <-> CPU /// transfers int faiss_StandardGpuResources_setPinnedMemory(FaissStandardGpuResources*, size_t size); diff --git a/c_api/gpu/example_gpu_c.c b/c_api/gpu/example_gpu_c.c index 9121df79cc..c8122884fb 100644 --- a/c_api/gpu/example_gpu_c.c +++ b/c_api/gpu/example_gpu_c.c @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/gpu/macros_impl.h b/c_api/gpu/macros_impl.h index bef971fe79..3f6ea5844a 100644 --- a/c_api/gpu/macros_impl.h +++ b/c_api/gpu/macros_impl.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/index_io_c.cpp b/c_api/index_io_c.cpp index 40aa5017cc..479045e1fb 100644 --- a/c_api/index_io_c.cpp +++ b/c_api/index_io_c.cpp @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/index_io_c.h b/c_api/index_io_c.h index 68f4c1ccdb..f20ce2e644 100644 --- a/c_api/index_io_c.h +++ b/c_api/index_io_c.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ diff --git a/c_api/macros_impl.h b/c_api/macros_impl.h index dd778eb8f1..af07938018 100644 --- a/c_api/macros_impl.h +++ b/c_api/macros_impl.h @@ -1,8 +1,7 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. + * Copyright (c) Facebook, Inc. and its affiliates. * - * This source code is licensed under the BSD+Patents license found in the + * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */