Improving naming [skip ci]

This commit is contained in:
Andrew Kane
2023-08-06 14:07:48 -07:00
parent 11e0b87abe
commit 72a8f68dc5
6 changed files with 35 additions and 27 deletions

View File

@@ -232,19 +232,27 @@ typedef HnswScanOpaqueData * HnswScanOpaque;
typedef struct HnswVacuumState
{
/* Info */
Relation index;
IndexBulkDeleteResult *stats;
IndexBulkDeleteCallback callback;
void *callback_state;
/* Settings */
int m;
int efConstruction;
HTAB *deleted;
BufferAccessStrategy bas;
/* Support functions */
FmgrInfo *procinfo;
Oid collation;
/* Variables */
HTAB *deleted;
BufferAccessStrategy bas;
HnswNeighborTuple ntup;
Size nsize;
HnswElementData highestPoint;
/* Memory */
MemoryContext tmpCtx;
} HnswVacuumState;
@@ -258,13 +266,13 @@ Buffer HnswNewBuffer(Relation index, ForkNumber forkNum);
void HnswInitPage(Buffer buf, Page page);
void HnswInitRegisterPage(Relation index, Buffer *buf, Page *page, GenericXLogState **state);
void HnswInit(void);
List *SearchLayer(Datum q, List *ep, int ef, int lc, Relation index, FmgrInfo *procinfo, Oid collation, bool inserting, BlockNumber *skipPage, OffsetNumber *skipOffno);
HnswElement GetEntryPoint(Relation index);
List *HnswSearchLayer(Datum q, List *ep, int ef, int lc, Relation index, FmgrInfo *procinfo, Oid collation, bool inserting, BlockNumber *skipPage, OffsetNumber *skipOffno);
HnswElement HnswGetEntryPoint(Relation index);
HnswElement HnswInitElement(ItemPointer tid, int m, double ml, int maxLevel);
void HnswFreeElement(HnswElement element);
HnswElement HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, FmgrInfo *procinfo, Oid collation, int m, int efConstruction, List **updates, bool vacuuming);
HnswCandidate *EntryCandidate(HnswElement em, Datum q, Relation rel, FmgrInfo *procinfo, Oid collation, bool loadvec);
void UpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum);
HnswCandidate *HnswEntryCandidate(HnswElement em, Datum q, Relation rel, FmgrInfo *procinfo, Oid collation, bool loadvec);
void HnswUpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum);
void HnswSetNeighborTuple(HnswNeighborTuple ntup, HnswElement e, int m);
void HnswAddHeapTid(HnswElement element, ItemPointer heaptid);
void HnswInitNeighbors(HnswElement element, int m);

View File

@@ -182,7 +182,7 @@ CreateElementPages(HnswBuildState * buildstate)
GenericXLogFinish(state);
UnlockReleaseBuffer(buf);
UpdateMetaPage(index, true, buildstate->entryPoint, insertPage, forkNum);
HnswUpdateMetaPage(index, true, buildstate->entryPoint, insertPage, forkNum);
}
/*

View File

@@ -266,7 +266,7 @@ WriteNewElementPages(Relation index, HnswElement e, int m)
/* Update the insert page */
if (insertPage != originalInsertPage && (!OffsetNumberIsValid(freeOffno) || firstFreePage == insertPage))
UpdateMetaPage(index, false, NULL, insertPage, MAIN_FORKNUM);
HnswUpdateMetaPage(index, false, NULL, insertPage, MAIN_FORKNUM);
}
/*
@@ -405,7 +405,7 @@ WriteElement(Relation index, HnswElement element, int m, List *updates, HnswElem
/* Update metapage if needed */
if (entryPoint == NULL || element->level > entryPoint->level)
UpdateMetaPage(index, true, element, InvalidBlockNumber, MAIN_FORKNUM);
HnswUpdateMetaPage(index, true, element, InvalidBlockNumber, MAIN_FORKNUM);
}
/*
@@ -442,7 +442,7 @@ HnswInsertTuple(Relation index, Datum *values, bool *isnull, ItemPointer heap_ti
element->vec = DatumGetVector(value);
/* Get entry point */
entryPoint = GetEntryPoint(index);
entryPoint = HnswGetEntryPoint(index);
/* Insert element in graph */
dup = HnswInsertElement(element, entryPoint, index, procinfo, collation, m, efConstruction, &updates, false);

View File

@@ -18,20 +18,20 @@ GetScanItems(IndexScanDesc scan, Datum q)
Oid collation = so->collation;
List *ep = NIL;
List *w;
HnswElement entryPoint = GetEntryPoint(index);
HnswElement entryPoint = HnswGetEntryPoint(index);
if (entryPoint == NULL)
return;
ep = lappend(ep, EntryCandidate(entryPoint, q, index, procinfo, collation, false));
ep = lappend(ep, HnswEntryCandidate(entryPoint, q, index, procinfo, collation, false));
for (int lc = entryPoint->level; lc >= 1; lc--)
{
w = SearchLayer(q, ep, 1, lc, index, procinfo, collation, false, NULL, NULL);
w = HnswSearchLayer(q, ep, 1, lc, index, procinfo, collation, false, NULL, NULL);
ep = w;
}
so->w = SearchLayer(q, ep, hnsw_ef_search, 0, index, procinfo, collation, false, NULL, NULL);
so->w = HnswSearchLayer(q, ep, hnsw_ef_search, 0, index, procinfo, collation, false, NULL, NULL);
}
/*

View File

@@ -141,7 +141,7 @@ CreateElementFromBlock(BlockNumber blkno, OffsetNumber offno)
* Get the entry point
*/
HnswElement
GetEntryPoint(Relation index)
HnswGetEntryPoint(Relation index)
{
Buffer buf;
Page page;
@@ -668,7 +668,7 @@ AddToVisited(HTAB *v, HnswCandidate * hc, Relation index, bool *found)
* Algorithm 2 from paper
*/
List *
SearchLayer(Datum q, List *ep, int ef, int lc, Relation index, FmgrInfo *procinfo, Oid collation, bool inserting, BlockNumber *skipPage, OffsetNumber *skipOffno)
HnswSearchLayer(Datum q, List *ep, int ef, int lc, Relation index, FmgrInfo *procinfo, Oid collation, bool inserting, BlockNumber *skipPage, OffsetNumber *skipOffno)
{
ListCell *lc2;
@@ -791,7 +791,7 @@ SearchLayer(Datum q, List *ep, int ef, int lc, Relation index, FmgrInfo *procinf
* Create a candidate for the entry point
*/
HnswCandidate *
EntryCandidate(HnswElement entryPoint, Datum q, Relation index, FmgrInfo *procinfo, Oid collation, bool loadvec)
HnswEntryCandidate(HnswElement entryPoint, Datum q, Relation index, FmgrInfo *procinfo, Oid collation, bool loadvec)
{
HnswCandidate *hc = palloc(sizeof(HnswCandidate));
@@ -848,7 +848,7 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
/* Get entry point and level */
if (entryPoint != NULL)
{
entryCandidate = EntryCandidate(entryPoint, q, index, procinfo, collation, true);
entryCandidate = HnswEntryCandidate(entryPoint, q, index, procinfo, collation, true);
ep = lappend(ep, entryCandidate);
entryLevel = entryPoint->level;
removeEntryPoint = vacuuming && list_length(entryPoint->heaptids) == 0;
@@ -861,7 +861,7 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
for (int lc = entryLevel; lc >= level + 1; lc--)
{
w = SearchLayer(q, ep, 1, lc, index, procinfo, collation, true, skipPage, skipOffno);
w = HnswSearchLayer(q, ep, 1, lc, index, procinfo, collation, true, skipPage, skipOffno);
ep = w;
}
@@ -872,7 +872,7 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
{
int lm = HnswGetLayerM(m, lc);
w = SearchLayer(q, ep, efConstruction, lc, index, procinfo, collation, true, skipPage, skipOffno);
w = HnswSearchLayer(q, ep, efConstruction, lc, index, procinfo, collation, true, skipPage, skipOffno);
if (removeEntryPoint)
w = list_delete_ptr(w, entryCandidate);
newNeighbors[lc] = SelectNeighbors(w, lm, lc, procinfo, collation, NULL);
@@ -904,7 +904,7 @@ HnswInsertElement(HnswElement element, HnswElement entryPoint, Relation index, F
* Update the metapage
*/
void
UpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum)
HnswUpdateMetaPage(Relation index, bool updateEntry, HnswElement entryPoint, BlockNumber insertPage, ForkNumber forkNum)
{
Buffer buf;
Page page;

View File

@@ -31,7 +31,7 @@ RemoveHeapTids(HnswVacuumState * vacuumstate)
HnswElement highestPoint = &vacuumstate->highestPoint;
Relation index = vacuumstate->index;
BufferAccessStrategy bas = vacuumstate->bas;
HnswElement entryPoint = GetEntryPoint(vacuumstate->index);
HnswElement entryPoint = HnswGetEntryPoint(vacuumstate->index);
/* Store separately since highestPoint.level is uint8 */
int highestLevel = -1;
@@ -201,7 +201,7 @@ RepairGraphElement(HnswVacuumState * vacuumstate, HnswElement element)
return;
/* Refresh entry point for each element */
entryPoint = GetEntryPoint(index);
entryPoint = HnswGetEntryPoint(index);
/* Special case for entry point */
if (element->blkno == entryPoint->blkno && element->offno == entryPoint->offno)
@@ -261,7 +261,7 @@ RepairGraphEntryPoint(HnswVacuumState * vacuumstate)
RepairGraphElement(vacuumstate, highestPoint);
}
entryPoint = GetEntryPoint(index);
entryPoint = HnswGetEntryPoint(index);
if (entryPoint != NULL)
{
ItemPointerData epData;
@@ -269,7 +269,7 @@ RepairGraphEntryPoint(HnswVacuumState * vacuumstate)
ItemPointerSet(&epData, entryPoint->blkno, entryPoint->offno);
if (DeletedContains(vacuumstate->deleted, &epData))
UpdateMetaPage(index, true, highestPoint, InvalidBlockNumber, MAIN_FORKNUM);
HnswUpdateMetaPage(index, true, highestPoint, InvalidBlockNumber, MAIN_FORKNUM);
else
{
/* Highest point will be used to repair */
@@ -484,7 +484,7 @@ MarkDeleted(HnswVacuumState * vacuumstate)
UnlockReleaseBuffer(buf);
}
UpdateMetaPage(index, false, NULL, insertPage, MAIN_FORKNUM);
HnswUpdateMetaPage(index, false, NULL, insertPage, MAIN_FORKNUM);
}
/*