Skip to content

Commit be4e9a9

Browse files
committed
Added macros for IvfflatScanList [skip ci]
1 parent d5e8fc9 commit be4e9a9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/ivfscan.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@
1515
#include "utils/memutils.h"
1616
#endif
1717

18+
#define GetScanList(ptr) pairingheap_container(IvfflatScanList, ph_node, ptr)
19+
#define GetScanListConst(ptr) pairingheap_const_container(IvfflatScanList, ph_node, ptr)
20+
1821
/*
1922
* Compare list distances
2023
*/
2124
static int
2225
CompareLists(const pairingheap_node *a, const pairingheap_node *b, void *arg)
2326
{
24-
if (((const IvfflatScanList *) a)->distance > ((const IvfflatScanList *) b)->distance)
27+
if (GetScanListConst(a)->distance > GetScanListConst(b)->distance)
2528
return 1;
2629

27-
if (((const IvfflatScanList *) a)->distance < ((const IvfflatScanList *) b)->distance)
30+
if (GetScanListConst(a)->distance < GetScanListConst(b)->distance)
2831
return -1;
2932

3033
return 0;
@@ -76,22 +79,22 @@ GetScanLists(IndexScanDesc scan, Datum value)
7679

7780
/* Calculate max distance */
7881
if (listCount == so->probes)
79-
maxDistance = ((IvfflatScanList *) pairingheap_first(so->listQueue))->distance;
82+
maxDistance = GetScanList(pairingheap_first(so->listQueue))->distance;
8083
}
8184
else if (distance < maxDistance)
8285
{
8386
IvfflatScanList *scanlist;
8487

8588
/* Remove */
86-
scanlist = (IvfflatScanList *) pairingheap_remove_first(so->listQueue);
89+
scanlist = GetScanList(pairingheap_remove_first(so->listQueue));
8790

8891
/* Reuse */
8992
scanlist->startPage = list->startPage;
9093
scanlist->distance = distance;
9194
pairingheap_add(so->listQueue, &scanlist->ph_node);
9295

9396
/* Update max distance */
94-
maxDistance = ((IvfflatScanList *) pairingheap_first(so->listQueue))->distance;
97+
maxDistance = GetScanList(pairingheap_first(so->listQueue))->distance;
9598
}
9699
}
97100

@@ -122,7 +125,7 @@ GetScanItems(IndexScanDesc scan, Datum value)
122125
/* Search closest probes lists */
123126
while (!pairingheap_is_empty(so->listQueue))
124127
{
125-
BlockNumber searchPage = ((IvfflatScanList *) pairingheap_remove_first(so->listQueue))->startPage;
128+
BlockNumber searchPage = GetScanList(pairingheap_remove_first(so->listQueue))->startPage;
126129

127130
/* Search all entry pages for list */
128131
while (BlockNumberIsValid(searchPage))

0 commit comments

Comments
 (0)