mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-11 23:26:55 +08:00
Removed HnswPtrSetNull to avoid setting relptr_off directly
This commit is contained in:
@@ -106,7 +106,6 @@
|
|||||||
#define HnswPtrAccess(base, hp) ((base) == NULL ? (hp).ptr : relptr_access(base, (hp).relptr))
|
#define HnswPtrAccess(base, hp) ((base) == NULL ? (hp).ptr : relptr_access(base, (hp).relptr))
|
||||||
#define HnswPtrStore(base, hp, value) ((base) == NULL ? (void) ((hp).ptr = (value)) : (void) relptr_store(base, (hp).relptr, value))
|
#define HnswPtrStore(base, hp, value) ((base) == NULL ? (void) ((hp).ptr = (value)) : (void) relptr_store(base, (hp).relptr, value))
|
||||||
#define HnswPtrIsNull(base, hp) ((base) == NULL ? (hp).ptr == NULL : relptr_is_null((hp).relptr))
|
#define HnswPtrIsNull(base, hp) ((base) == NULL ? (hp).ptr == NULL : relptr_is_null((hp).relptr))
|
||||||
#define HnswPtrSetNull(base, hp) ((base) == NULL ? (void) ((hp).ptr = NULL) : (void) ((hp).relptr.relptr_off = 0))
|
|
||||||
#define HnswPtrEqual(base, hp1, hp2) ((base) == NULL ? (hp1).ptr == (hp2).ptr : relptr_offset((hp1).relptr) == relptr_offset((hp2).relptr))
|
#define HnswPtrEqual(base, hp1, hp2) ((base) == NULL ? (hp1).ptr == (hp2).ptr : relptr_offset((hp1).relptr) == relptr_offset((hp2).relptr))
|
||||||
|
|
||||||
/* For code paths dedicated to each type */
|
/* For code paths dedicated to each type */
|
||||||
|
|||||||
@@ -551,8 +551,8 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
|||||||
static void
|
static void
|
||||||
InitGraph(HnswGraph * graph, char *base, long memoryTotal)
|
InitGraph(HnswGraph * graph, char *base, long memoryTotal)
|
||||||
{
|
{
|
||||||
HnswPtrSetNull(base, graph->head);
|
HnswPtrStore(base, graph->head, (HnswElement) NULL);
|
||||||
HnswPtrSetNull(base, graph->entryPoint);
|
HnswPtrStore(base, graph->entryPoint, (HnswElement) NULL);
|
||||||
graph->memoryUsed = 0;
|
graph->memoryUsed = 0;
|
||||||
graph->memoryTotal = memoryTotal;
|
graph->memoryTotal = memoryTotal;
|
||||||
graph->flushed = false;
|
graph->flushed = false;
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ HnswInitElement(char *base, ItemPointer heaptid, int m, double ml, int maxLevel,
|
|||||||
|
|
||||||
HnswInitNeighbors(base, element, m, allocator);
|
HnswInitNeighbors(base, element, m, allocator);
|
||||||
|
|
||||||
HnswPtrSetNull(base, element->value);
|
HnswPtrStore(base, element->value, (Pointer) NULL);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
@@ -295,11 +295,12 @@ HnswElement
|
|||||||
HnswInitElementFromBlock(BlockNumber blkno, OffsetNumber offno)
|
HnswInitElementFromBlock(BlockNumber blkno, OffsetNumber offno)
|
||||||
{
|
{
|
||||||
HnswElement element = palloc(sizeof(HnswElementData));
|
HnswElement element = palloc(sizeof(HnswElementData));
|
||||||
|
char *base = NULL;
|
||||||
|
|
||||||
element->blkno = blkno;
|
element->blkno = blkno;
|
||||||
element->offno = offno;
|
element->offno = offno;
|
||||||
HnswPtrSetNull(NULL, element->neighbors);
|
HnswPtrStore(base, element->neighbors, (HnswNeighborArrayPtr *) NULL);
|
||||||
HnswPtrSetNull(NULL, element->value);
|
HnswPtrStore(base, element->value, (Pointer) NULL);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ RepairGraphEntryPoint(HnswVacuumState * vacuumstate)
|
|||||||
{
|
{
|
||||||
/* Reset neighbors from previous update */
|
/* Reset neighbors from previous update */
|
||||||
if (highestPoint != NULL)
|
if (highestPoint != NULL)
|
||||||
HnswPtrSetNull(NULL, highestPoint->neighbors);
|
HnswPtrStore((char *) NULL, highestPoint->neighbors, (HnswNeighborArrayPtr *) NULL);
|
||||||
|
|
||||||
RepairGraphElement(vacuumstate, entryPoint, highestPoint);
|
RepairGraphElement(vacuumstate, entryPoint, highestPoint);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user