@@ -959,14 +959,13 @@ CheckElementCloser(char *base, HnswCandidate * e, List *r, FmgrInfo *procinfo, O
959
959
* Algorithm 4 from paper
960
960
*/
961
961
static List *
962
- SelectNeighbors (char * base , List * c , int lm , int lc , FmgrInfo * procinfo , Oid collation , HnswElement e2 , HnswCandidate * newCandidate , HnswCandidate * * pruned , bool sortCandidates )
962
+ SelectNeighbors (char * base , List * c , int lm , FmgrInfo * procinfo , Oid collation , HnswNeighborArray * neighbors , HnswCandidate * newCandidate , HnswCandidate * * pruned , bool sortCandidates )
963
963
{
964
964
List * r = NIL ;
965
965
List * w = list_copy (c );
966
966
HnswCandidate * * wd ;
967
967
int wdlen = 0 ;
968
968
int wdoff = 0 ;
969
- HnswNeighborArray * neighbors = HnswGetNeighbors (base , e2 , lc );
970
969
bool mustCalculate = !neighbors -> closerSet ;
971
970
List * added = NIL ;
972
971
bool removedAny = false;
@@ -1139,7 +1138,7 @@ HnswUpdateConnection(char *base, HnswElement element, HnswCandidate * hc, int lm
1139
1138
c = lappend (c , & currentNeighbors -> items [i ]);
1140
1139
c = lappend (c , & hc2 );
1141
1140
1142
- SelectNeighbors (base , c , lm , lc , procinfo , collation , hce , & hc2 , & pruned , true);
1141
+ SelectNeighbors (base , c , lm , procinfo , collation , currentNeighbors , & hc2 , & pruned , true);
1143
1142
1144
1143
/* Should not happen */
1145
1144
if (pruned == NULL )
@@ -1278,7 +1277,7 @@ HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint
1278
1277
* sortCandidates to true for in-memory builds to enable closer
1279
1278
* caching, but there does not seem to be a difference in performance.
1280
1279
*/
1281
- neighbors = SelectNeighbors (base , lw , lm , lc , procinfo , collation , element , NULL , NULL , false);
1280
+ neighbors = SelectNeighbors (base , lw , lm , procinfo , collation , HnswGetNeighbors ( base , element , lc ) , NULL , NULL , false);
1282
1281
1283
1282
AddConnections (base , element , neighbors , lc );
1284
1283
0 commit comments