diff --git a/src/hnsw.h b/src/hnsw.h index 5ccf683..8f7164b 100644 --- a/src/hnsw.h +++ b/src/hnsw.h @@ -392,7 +392,7 @@ void HnswSetNeighborTuple(char *base, HnswNeighborTuple ntup, HnswElement e, in void HnswAddHeapTid(HnswElement element, ItemPointer heaptid); void HnswInitNeighbors(char *base, HnswElement element, int m, HnswAllocator * alloc); bool HnswInsertTupleOnDisk(Relation index, Datum value, Datum *values, bool *isnull, ItemPointer heap_tid, Relation heapRel, bool building); -void HnswUpdateNeighborPages(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m, bool checkExisting, bool building); +void HnswUpdateNeighborsOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m, bool checkExisting, bool building); void HnswLoadElementFromTuple(HnswElement element, HnswElementTuple etup, bool loadHeaptids, bool loadVec); void HnswLoadElement(HnswElement element, float *distance, Datum *q, Relation index, FmgrInfo *procinfo, Oid collation, bool loadVec); void HnswSetElementTuple(char *base, HnswElementTuple etup, HnswElement element); diff --git a/src/hnswbuild.c b/src/hnswbuild.c index fc67e73..44471a2 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -379,7 +379,7 @@ HnswFindDuplicateInMemory(char *base, HnswElement element) * Add to element and neighbor pages */ static void -WriteNewElementPagesInMemory(char *base, HnswGraph * graph, HnswElement element) +HnswAddElementInMemory(char *base, HnswGraph * graph, HnswElement element) { SpinLockAcquire(&graph->lock); element->next = graph->head; @@ -391,7 +391,7 @@ WriteNewElementPagesInMemory(char *base, HnswGraph * graph, HnswElement element) * Update neighbors */ static void -HnswUpdateNeighborPagesInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswElement e, int m) +HnswUpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswElement e, int m) { for (int lc = e->level; lc >= 0; lc--) { @@ -427,11 +427,11 @@ WriteElementInMemory(FmgrInfo *procinfo, Oid collation, HnswElement element, int if (HnswFindDuplicateInMemory(base, element)) return; - /* Write element and neighbor tuples */ - WriteNewElementPagesInMemory(base, graph, element); + /* Add element */ + HnswAddElementInMemory(base, graph, element); /* Update neighbors */ - HnswUpdateNeighborPagesInMemory(base, procinfo, collation, element, m); + HnswUpdateNeighborsInMemory(base, procinfo, collation, element, m); /* Update entry point if needed (already have lock) */ if (updateEntryPoint) diff --git a/src/hnswinsert.c b/src/hnswinsert.c index 624a40e..1a92ef3 100644 --- a/src/hnswinsert.c +++ b/src/hnswinsert.c @@ -116,7 +116,7 @@ HnswInsertAppendPage(Relation index, Buffer *nbuf, Page *npage, GenericXLogState * Add to element and neighbor pages */ static void -WriteNewElementPages(Relation index, HnswElement e, int m, BlockNumber insertPage, BlockNumber *updatedInsertPage, bool building) +AddElementOnDisk(Relation index, HnswElement e, int m, BlockNumber insertPage, BlockNumber *updatedInsertPage, bool building) { Buffer buf; Page page; @@ -339,7 +339,7 @@ ConnectionExists(HnswElement e, HnswNeighborTuple ntup, int startIdx, int lm) * Update neighbors */ void -HnswUpdateNeighborPages(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m, bool checkExisting, bool building) +HnswUpdateNeighborsOnDisk(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement e, int m, bool checkExisting, bool building) { char *base = NULL; @@ -451,7 +451,7 @@ HnswUpdateNeighborPages(Relation index, FmgrInfo *procinfo, Oid collation, HnswE * Add a heap TID to an existing element */ static bool -HnswAddDuplicate(Relation index, HnswElement element, HnswElement dup, bool building) +HnswAddDuplicateOnDisk(Relation index, HnswElement element, HnswElement dup, bool building) { Buffer buf; Page page; @@ -515,7 +515,7 @@ HnswAddDuplicate(Relation index, HnswElement element, HnswElement dup, bool buil * Find duplicate element */ static bool -HnswFindDuplicate(Relation index, HnswElement element, bool building) +HnswFindDuplicateOnDisk(Relation index, HnswElement element, bool building) { char *base = NULL; HnswNeighborArray *neighbors = HnswGetNeighbors(base, element, 0); @@ -531,7 +531,7 @@ HnswFindDuplicate(Relation index, HnswElement element, bool building) if (!datumIsEqual(value, neighborValue, false, -1)) return false; - if (HnswAddDuplicate(index, element, neighborElement, building)) + if (HnswAddDuplicateOnDisk(index, element, neighborElement, building)) return true; } @@ -547,18 +547,18 @@ WriteElement(Relation index, FmgrInfo *procinfo, Oid collation, HnswElement elem BlockNumber newInsertPage = InvalidBlockNumber; /* Look for duplicate */ - if (HnswFindDuplicate(index, element, building)) + if (HnswFindDuplicateOnDisk(index, element, building)) return; - /* Write element and neighbor tuples */ - WriteNewElementPages(index, element, m, GetInsertPage(index), &newInsertPage, building); + /* Add element */ + AddElementOnDisk(index, element, m, GetInsertPage(index), &newInsertPage, building); /* Update insert page if needed */ if (BlockNumberIsValid(newInsertPage)) HnswUpdateMetaPage(index, 0, NULL, newInsertPage, MAIN_FORKNUM, building); /* Update neighbors */ - HnswUpdateNeighborPages(index, procinfo, collation, element, m, false, building); + HnswUpdateNeighborsOnDisk(index, procinfo, collation, element, m, false, building); /* Update entry point if needed */ if (entryPoint == NULL || element->level > entryPoint->level) diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index 945fc92..7bce111 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -230,7 +230,7 @@ RepairGraphElement(HnswVacuumState * vacuumstate, HnswElement element, HnswEleme UnlockReleaseBuffer(buf); /* Update neighbors */ - HnswUpdateNeighborPages(index, procinfo, collation, element, m, true, false); + HnswUpdateNeighborsOnDisk(index, procinfo, collation, element, m, true, false); } /*