diff --git a/src/hnswutils.c b/src/hnswutils.c index e7aeb03..42d99c2 100644 --- a/src/hnswutils.c +++ b/src/hnswutils.c @@ -227,10 +227,13 @@ HnswGetMetaPageInfo(Relation index, int *m, HnswElement * entryPoint) if (m != NULL) *m = metap->m; - if (BlockNumberIsValid(metap->entryBlkno)) - *entryPoint = HnswInitElementFromBlock(metap->entryBlkno, metap->entryOffno); - else - *entryPoint = NULL; + if (entryPoint != NULL) + { + if (BlockNumberIsValid(metap->entryBlkno)) + *entryPoint = HnswInitElementFromBlock(metap->entryBlkno, metap->entryOffno); + else + *entryPoint = NULL; + } UnlockReleaseBuffer(buf); } diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c index b7d3c7a..49f5b21 100644 --- a/src/hnswvacuum.c +++ b/src/hnswvacuum.c @@ -265,12 +265,7 @@ RepairGraphEntryPoint(HnswVacuumState * vacuumstate) /* Repair if needed */ if (NeedsUpdated(vacuumstate, highestPoint)) - { - /* Get m and entry point */ - HnswGetMetaPageInfo(index, &vacuumstate->m, &entryPoint); - - RepairGraphElement(vacuumstate, highestPoint, entryPoint); - } + RepairGraphElement(vacuumstate, highestPoint, HnswGetEntryPoint(index)); /* Release lock */ UnlockPage(index, HNSW_UPDATE_LOCK, ShareLock); @@ -279,8 +274,8 @@ RepairGraphEntryPoint(HnswVacuumState * vacuumstate) /* Prevent concurrent inserts when possibly updating entry point */ LockPage(index, HNSW_UPDATE_LOCK, ExclusiveLock); - /* Get m and latest entry point */ - HnswGetMetaPageInfo(index, &vacuumstate->m, &entryPoint); + /* Get latest entry point */ + entryPoint = HnswGetEntryPoint(index); if (entryPoint != NULL) { @@ -587,7 +582,6 @@ InitVacuumState(HnswVacuumState * vacuumstate, IndexVacuumInfo *info, IndexBulkD vacuumstate->stats = stats; vacuumstate->callback = callback; vacuumstate->callback_state = callback_state; - vacuumstate->m = 0; /* Get m from metapage later */ vacuumstate->efConstruction = HnswGetEfConstruction(index); vacuumstate->bas = GetAccessStrategy(BAS_BULKREAD); vacuumstate->procinfo = index_getprocinfo(index, 1, HNSW_DISTANCE_PROC); @@ -597,6 +591,9 @@ InitVacuumState(HnswVacuumState * vacuumstate, IndexVacuumInfo *info, IndexBulkD "Hnsw vacuum temporary context", ALLOCSET_DEFAULT_SIZES); + /* Get m from metapage */ + HnswGetMetaPageInfo(index, &vacuumstate->m, NULL); + /* Create hash table */ hash_ctl.keysize = sizeof(ItemPointerData); hash_ctl.entrysize = sizeof(ItemPointerData);