# modify source code
# 步骤1 修改faiss源码
arch="$(uname -m)"
if [ "${arch}" = "aarch64" ]; then
gcc_version="$(gcc -dumpversion)"
if [ "${gcc_version}" = "4.8.5" ];then
sed -i '20i /*' utils/simdlib.h
sed -i '24i */' utils/simdlib.h
fi
fi
sed -i "131 i\\
\\
virtual void search_with_filter (idx_t n, const float *x, idx_t k,\\
float *distances, idx_t *lables, const void *mask = nullptr) const {}\\
" Index.h
sed -i "38 i\\
\\
template <typename IndexT>\\
IndexIDMapTemplate<IndexT>::IndexIDMapTemplate (IndexT *index, std::vector<idx_t> &ids):\\
index (index),\\
own_fields (false)\\
{\\
this->is_trained = index->is_trained;\\
this->metric_type = index->metric_type;\\
this->verbose = index->verbose;\\
this->d = index->d;\\
id_map = ids;\\
}\\
" IndexIDMap.cpp
sed -i "29 i\\
\\
explicit IndexIDMapTemplate (IndexT *index, std::vector<idx_t> &ids);\\
" IndexIDMap.h
sed -i "199 i\\
utils/sorting.h
" CMakeLists.txt
# modify source code end
cd ..
ls
# 步骤2 faiss编译配置
cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
# 步骤3 编译安装
cd build && make -j && make install
cd ../.. && rm -f v1.7.4.tar.gz && rm -rf faiss-1.7.4