Improved code [skip ci]

This commit is contained in:
Andrew Kane
2025-07-11 17:11:39 -07:00
parent 911935b695
commit f6e9a56415

View File

@@ -849,9 +849,13 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
HnswUnvisited *unvisited = palloc(lm * sizeof(HnswUnvisited)); HnswUnvisited *unvisited = palloc(lm * sizeof(HnswUnvisited));
int unvisitedLength; int unvisitedLength;
bool inMemory = index == NULL; bool inMemory = index == NULL;
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
HnswReadStreamData streamData; HnswReadStreamData streamData;
ReadStream *stream = inMemory ? NULL : read_stream_begin_relation(READ_STREAM_DEFAULT, NULL, index, MAIN_FORKNUM, HnswReadStreamNextBlock, &streamData, sizeof(OffsetNumber)); ReadStream *stream;
if (!inMemory)
stream = read_stream_begin_relation(READ_STREAM_DEFAULT, NULL, index, MAIN_FORKNUM, HnswReadStreamNextBlock, &streamData, sizeof(OffsetNumber));
#endif #endif
if (v == NULL) if (v == NULL)
@@ -921,6 +925,7 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
read_stream_reset(stream); read_stream_reset(stream);
streamData.unvisited = unvisited; streamData.unvisited = unvisited;
streamData.unvisitedLength = unvisitedLength; streamData.unvisitedLength = unvisitedLength;
streamData.index = 0; streamData.index = 0;
@@ -951,10 +956,10 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
OffsetNumber offno; OffsetNumber offno;
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
OffsetNumber *offnoPtr; void *offnoPtr;
buf = read_stream_next_buffer(stream, (void **) &offnoPtr); buf = read_stream_next_buffer(stream, &offnoPtr);
offno = *offnoPtr; offno = *((OffsetNumber *) offnoPtr);
#else #else
ItemPointer indextid = &unvisited[i].indextid; ItemPointer indextid = &unvisited[i].indextid;
@@ -1021,7 +1026,7 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
} }
#if PG_VERSION_NUM >= 170000 #if PG_VERSION_NUM >= 170000
if (stream) if (!inMemory)
read_stream_end(stream); read_stream_end(stream);
#endif #endif