Unverified Commit b04b3e94 authored by shengjun.li's avatar shengjun.li Committed by GitHub
Browse files

#1897 add heap_swap_top (#1898)



* add heap_swap_top

Signed-off-by: default avatarshengjun.li <shengjun.li@zilliz.com>

* fix wrong code

Signed-off-by: default avatarshengjun.li <shengjun.li@zilliz.com>
parent 3bc17d8c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -10,11 +10,10 @@ Please mark all change in change log and use the issue from GitHub
-   \#1789 Fix multi-client search cause server crash
-   \#1832 Fix crash in tracing module
-   \#1873 Fix index file serialize to incorrect path
-   \#1881 Fix Annoy index search failure
-   \#1881 Fix bad alloc when index files lost

## Feature
-   \#261  Integrate ANNOY into Milvus
-   \#1603 BinaryFlat add 2 Metric: Substructure and Superstructure
-   \#1655 GPU index support delete vectors
-   \#1660 IVF PQ CPU support deleted vectors searching
-   \#1661 HNSW support deleted vectors searching
@@ -29,6 +28,7 @@ Please mark all change in change log and use the issue from GitHub
-   \#1882 Add index annoy into http module
-   \#1885 Optimize knowhere unittest
-   \#1886 Refactor log on search and insert request
-   \#1897 Heap pop and push can be realized by heap_swap_top

## Task

+2 −4
Original line number Diff line number Diff line
@@ -420,9 +420,8 @@ struct IVFBinaryScannerL2: BinaryInvertedListScanner {
                uint32_t dis = hc.hamming (codes);

                if (dis < simi[0]) {
                    heap_pop<C> (k, simi, idxi);
                    idx_t id = store_pairs ? (list_no << 32 | j) : ids[j];
                    heap_push<C> (k, simi, idxi, dis, id);
                    heap_swap_top<C> (k, simi, idxi, dis, id);
                    nup++;
                }
            }
@@ -470,9 +469,8 @@ struct IVFBinaryScannerJaccard: BinaryInvertedListScanner {
                float dis = hc.compute (codes);

                if (dis < psimi[0]) {
                    heap_pop<C> (k, psimi, idxi);
                    idx_t id = store_pairs ? (list_no << 32 | j) : ids[j];
                    heap_push<C> (k, psimi, idxi, dis, id);
                    heap_swap_top<C> (k, psimi, idxi, dis, id);
                    nup++;
                }
            }
+1 −2
Original line number Diff line number Diff line
@@ -159,9 +159,8 @@ struct IVFFlatScanner: InvertedListScanner {
                float dis = metric == METRIC_INNER_PRODUCT ?
                            fvec_inner_product (xi, yj, d) : fvec_L2sqr (xi, yj, d);
                if (C::cmp (simi[0], dis)) {
                    heap_pop<C> (k, simi, idxi);
                    int64_t id = store_pairs ? (list_no << 32 | j) : ids[j];
                    heap_push<C> (k, simi, idxi, dis, id);
                    heap_swap_top<C> (k, simi, idxi, dis, id);
                    nup++;
                }
            }
+1 −2
Original line number Diff line number Diff line
@@ -805,8 +805,7 @@ struct KnnSearchResults {
            idx_t id = ids ? ids[j] : (key << 32 | j);
            if (bitset != nullptr && bitset->test((faiss::ConcurrentBitset::id_type_t)id))
                return;
            heap_pop<C> (k, heap_sim, heap_ids);
            heap_push<C> (k, heap_sim, heap_ids, dis, id);
            heap_swap_top<C> (k, heap_sim, heap_ids, dis, id);
            nup++;
        }
    }
+1 −2
Original line number Diff line number Diff line
@@ -171,9 +171,8 @@ void IndexIVFPQR::search_preassigned (idx_t n, const float *x, idx_t k,
                float dis = fvec_L2sqr (residual_1, residual_2, d);

                if (dis < heap_sim[0]) {
                    maxheap_pop (k, heap_sim, heap_ids);
                    idx_t id_or_pair = store_pairs ? sl : id;
                    maxheap_push (k, heap_sim, heap_ids, dis, id_or_pair);
                    maxheap_swap_top (k, heap_sim, heap_ids, dis, id_or_pair);
                }
                n_refine ++;
            }
Loading