mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-22 03:57:34 +08:00
Compare commits
3 Commits
v0.8.4
...
hnsw-build
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e43b1e660f | ||
|
|
33f5c41623 | ||
|
|
3c99b55cf9 |
@@ -379,7 +379,13 @@ UpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswEleme
|
|||||||
for (int lc = e->level; lc >= 0; lc--)
|
for (int lc = e->level; lc >= 0; lc--)
|
||||||
{
|
{
|
||||||
int lm = HnswGetLayerM(m, lc);
|
int lm = HnswGetLayerM(m, lc);
|
||||||
HnswNeighborArray *neighbors = HnswGetNeighbors(base, e, lc);
|
Size neighborsSize = HNSW_NEIGHBOR_ARRAY_SIZE(lm);
|
||||||
|
HnswNeighborArray *neighbors = palloc(neighborsSize);
|
||||||
|
|
||||||
|
/* Copy neighbors to local memory */
|
||||||
|
LWLockAcquire(&e->lock, LW_SHARED);
|
||||||
|
memcpy(neighbors, HnswGetNeighbors(base, e, lc), neighborsSize);
|
||||||
|
LWLockRelease(&e->lock);
|
||||||
|
|
||||||
for (int i = 0; i < neighbors->length; i++)
|
for (int i = 0; i < neighbors->length; i++)
|
||||||
{
|
{
|
||||||
@@ -389,7 +395,6 @@ UpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswEleme
|
|||||||
/* Keep scan-build happy on Mac x86-64 */
|
/* Keep scan-build happy on Mac x86-64 */
|
||||||
Assert(neighborElement);
|
Assert(neighborElement);
|
||||||
|
|
||||||
/* Use element for lock instead of hc since hc can be replaced */
|
|
||||||
LWLockAcquire(&neighborElement->lock, LW_EXCLUSIVE);
|
LWLockAcquire(&neighborElement->lock, LW_EXCLUSIVE);
|
||||||
HnswUpdateConnection(base, e, hc, lm, lc, NULL, NULL, procinfo, collation);
|
HnswUpdateConnection(base, e, hc, lm, lc, NULL, NULL, procinfo, collation);
|
||||||
LWLockRelease(&neighborElement->lock);
|
LWLockRelease(&neighborElement->lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user