Commit ed809ce1 authored by Lizz's avatar Lizz Committed by Matthijs Douze

Implement remove_ids in IndexPQ (#407)

* Implement remove_ids in IndexPQ

* Update IndexPQ.cpp
parent 1ae74944
......@@ -21,6 +21,7 @@
#include <algorithm>
#include "FaissAssert.h"
#include "AuxIndexStructures.h"
#include "hamming.h"
namespace faiss {
......@@ -84,6 +85,27 @@ void IndexPQ::add (idx_t n, const float *x)
}
long IndexPQ::remove_ids (const IDSelector & sel)
{
idx_t j = 0;
for (idx_t i = 0; i < ntotal; i++) {
if (sel.is_member (i)) {
// should be removed
} else {
if (i > j) {
memmove (&codes[pq.code_size * j], &codes[pq.code_size * i], pq.code_size);
}
j++;
}
}
long nremove = ntotal - j;
if (nremove > 0) {
ntotal = j;
codes.resize (ntotal * pq.code_size);
}
return nremove;
}
void IndexPQ::reset()
{
......
......@@ -83,6 +83,11 @@ struct IndexPQ: Index {
Search_type_t search_type;
/** remove some ids. NB that Because of the structure of the
* indexing structre, the semantics of this operation are
* different from the usual ones: the new ids are shifted */
long remove_ids(const IDSelector& sel) override;
// just encode the sign of the components, instead of using the PQ encoder
// used only for the queries
bool encode_signs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment