mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-06 17:28:40 +00:00
Added HNSW_USE_READ_STREAM [skip ci]
This commit is contained in:
1 parent
0c05dc667c
commit
085a7773ef
3 files changed
+16
-12
No files matched your search
+7
-3
@@ -19,6 +19,10 @@
|
||||
#include "vector.h"
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#define HNSW_USE_READ_STREAM
|
||||
#endif
|
||||
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
#include "storage/read_stream.h"
|
||||
#endif
|
||||
|
||||
@@ -411,7 +415,7 @@ typedef union
|
||||
ItemPointerData indextid;
|
||||
} HnswUnvisited;
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
typedef struct HnswReadStreamData
|
||||
{
|
||||
HnswUnvisited *unvisited;
|
||||
@@ -422,7 +426,7 @@ typedef struct HnswReadStreamData
|
||||
|
||||
typedef struct HnswReadStream
|
||||
{
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
HnswReadStreamData streamData;
|
||||
ReadStream *stream;
|
||||
#else
|
||||
@@ -513,7 +517,7 @@ void HnswCheckDim(int expected, const HnswTypeInfo * typeInfo, Oid collation, D
|
||||
const HnswTypeInfo *HnswGetTypeInfo(Relation index);
|
||||
PGDLLEXPORT void HnswParallelBuildMain(dsm_segment *seg, shm_toc *toc);
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
void HnswInitReadStream(HnswReadStream * readStream, Relation index, bool maintenance);
|
||||
void HnswEndReadStream(HnswReadStream * readStream);
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ hnswbeginscan(Relation index, int nkeys, int norderbys)
|
||||
/* Set support functions */
|
||||
HnswInitSupport(&so->support, index);
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
HnswInitReadStream(&so->readStream, index, false);
|
||||
#endif
|
||||
|
||||
@@ -347,7 +347,7 @@ hnswendscan(IndexScanDesc scan)
|
||||
{
|
||||
HnswScanOpaque so = (HnswScanOpaque) scan->opaque;
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
HnswEndReadStream(&so->readStream);
|
||||
#endif
|
||||
MemoryContextDelete(so->tmpCtx);
|
||||
|
||||
+7
-7
@@ -22,7 +22,7 @@
|
||||
#include "varatt.h"
|
||||
#endif
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
#include "storage/read_stream.h"
|
||||
#endif
|
||||
|
||||
@@ -825,7 +825,7 @@ HnswLoadUnvisitedFromDisk(HnswElement element, HnswUnvisited * unvisited, int *u
|
||||
}
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
/*
|
||||
* Get next block number for read stream
|
||||
*/
|
||||
@@ -950,13 +950,13 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
|
||||
HnswLoadUnvisitedFromMemory(base, cElement, unvisited, &unvisitedLength, v, lc, localNeighborhood, neighborhoodSize);
|
||||
else
|
||||
{
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
HnswReadStreamData *streamData = &readStream->streamData;
|
||||
#endif
|
||||
|
||||
HnswLoadUnvisitedFromDisk(cElement, unvisited, &unvisitedLength, v, index, m, lm, lc);
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
streamData->unvisited = unvisited;
|
||||
streamData->unvisitedLength = unvisitedLength;
|
||||
streamData->visited = 0;
|
||||
@@ -991,7 +991,7 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
|
||||
Buffer buf;
|
||||
OffsetNumber offno;
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
void *offnoPtr;
|
||||
|
||||
buf = read_stream_next_buffer(readStream->stream, &offnoPtr);
|
||||
@@ -1375,7 +1375,7 @@ HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint
|
||||
bool inMemory = index == NULL;
|
||||
HnswReadStream readStream;
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
if (!inMemory)
|
||||
HnswInitReadStream(&readStream, index, maintenance);
|
||||
#endif
|
||||
@@ -1447,7 +1447,7 @@ HnswFindElementNeighbors(char *base, HnswElement element, HnswElement entryPoint
|
||||
ep = w;
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM >= 190000
|
||||
#ifdef HNSW_USE_READ_STREAM
|
||||
if (!inMemory)
|
||||
HnswEndReadStream(&readStream);
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user