@@ -959,14 +959,14 @@ 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 , FmgrInfo * procinfo , Oid collation , HnswNeighborArray * neighbors , HnswCandidate * newCandidate , HnswCandidate * * pruned , bool sortCandidates )
962
+ SelectNeighbors (char * base , List * c , int lm , FmgrInfo * procinfo , Oid collation , bool * closerSet , 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
- bool mustCalculate = !neighbors -> closerSet ;
969
+ bool mustCalculate = !( * closerSet ) ;
970
970
List * added = NIL ;
971
971
bool removedAny = false;
972
972
@@ -1043,7 +1043,7 @@ SelectNeighbors(char *base, List *c, int lm, FmgrInfo *procinfo, Oid collation,
1043
1043
}
1044
1044
1045
1045
/* Cached value can only be used in future if sorted deterministically */
1046
- neighbors -> closerSet = sortCandidates ;
1046
+ * closerSet = sortCandidates ;
1047
1047
1048
1048
/* Keep pruned connections */
1049
1049
while (wdoff < wdlen && list_length (r ) < lm )
@@ -1104,7 +1104,7 @@ HnswUpdateConnection(char *base, HnswNeighborArray * neighbors, HnswElement newE
1104
1104
c = lappend (c , & neighbors -> items [i ]);
1105
1105
c = lappend (c , & newHc );
1106
1106
1107
- SelectNeighbors (base , c , lm , procinfo , collation , neighbors , & newHc , & pruned , true);
1107
+ SelectNeighbors (base , c , lm , procinfo , collation , & neighbors -> closerSet , & newHc , & pruned , true);
1108
1108
1109
1109
/* Should not happen */
1110
1110
if (pruned == NULL )
@@ -1242,7 +1242,7 @@ HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint
1242
1242
* sortCandidates to true for in-memory builds to enable closer
1243
1243
* caching, but there does not seem to be a difference in performance.
1244
1244
*/
1245
- neighbors = SelectNeighbors (base , lw , lm , procinfo , collation , HnswGetNeighbors (base , element , lc ), NULL , NULL , false);
1245
+ neighbors = SelectNeighbors (base , lw , lm , procinfo , collation , & HnswGetNeighbors (base , element , lc )-> closerSet , NULL , NULL , false);
1246
1246
1247
1247
AddConnections (base , element , neighbors , lc );
1248
1248
0 commit comments