index/gamma_hnsw.cc
void greedy_update_nearest(const GammaHNSW& hnsw,
                           DistanceComputer& qdis,
                           int level,
                           storage_idx_t& nearest,
                           float& d_nearest)
{
  for(;;) {
    storage_idx_t prev_nearest = nearest;

    size_t begin, end;
    hnsw.neighbor_range(nearest, level, &begin, &end);
    for(size_t i = begin; i < end; i++) {
      storage_idx_t v = hnsw.neighbors[i];
      if (v < 0) break;
      float dis = qdis(v);
      if (dis < d_nearest) {
        nearest = v;
        d_nearest = dis;
      }
    }
    if (nearest == prev_nearest) {
      return;
    }
  }
}
/// greedily update a nearest vector at a given level
greedily update a nearest vector at a given level
greedily update a nearest vector at a given level
void greedy_update_nearest(const GammaHNSW& hnsw,
                           DistanceComputer& qdis,
                           int level,
                           storage_idx_t& nearest,
                           float& d_nearest)
{
  for(;;) {
    storage_idx_t prev_nearest = nearest;
    size_t begin, end;
    hnsw.neighbor_range(nearest, level, &begin, &end);
    for(size_t i = begin; i < end; i++) {
      storage_idx_t v = hnsw.neighbors[i];
      if (v < 0) break;
      float dis = qdis(v);
      if (dis < d_nearest) {
        nearest = v;
        d_nearest = dis;
      }
    }
    if (nearest == prev_nearest) {
      return;
    }
  }
}
void greedy_update_nearest ( const GammaHNSW & hnsw , DistanceComputer & qdis , int level , storage_idx_t & nearest , float & d_nearest ) { for ( ; ; ) { storage_idx_t prev_nearest = nearest ; size_t begin , end ; hnsw . neighbor_range ( nearest , level , & begin , & end ) ; for ( size_t i = begin ; i < end ; i ++ ) { storage_idx_t v = hnsw . neighbors [ i ] ; if ( v < 0 ) break ; float dis = qdis ( v ) ; if ( dis < d_nearest ) { nearest = v ; d_nearest = dis ; } } if ( nearest == prev_nearest ) { return ; } } }
greedily update a nearest vector at a given level
greedily update a nearest vector at a given level