mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-01 02:02:10 +08:00
Use datum for lists
This commit is contained in:
@@ -506,11 +506,9 @@ CreateListPages(Relation index, VectorArray centers, int dimensions,
|
||||
Buffer buf;
|
||||
Page page;
|
||||
GenericXLogState *state;
|
||||
Size listSize;
|
||||
IvfflatList list;
|
||||
|
||||
listSize = MAXALIGN(IVFFLAT_LIST_SIZE(dimensions));
|
||||
list = palloc(listSize);
|
||||
list = palloc0(BLCKSZ);
|
||||
|
||||
buf = IvfflatNewBuffer(index, forkNum);
|
||||
IvfflatInitRegisterPage(index, &buf, &page, &state);
|
||||
@@ -518,11 +516,13 @@ CreateListPages(Relation index, VectorArray centers, int dimensions,
|
||||
for (int i = 0; i < lists; i++)
|
||||
{
|
||||
OffsetNumber offno;
|
||||
Datum center = PointerGetDatum(VectorArrayGet(centers, i));
|
||||
Size listSize = MAXALIGN(IVFFLAT_LIST_SIZE(center));
|
||||
|
||||
/* Load list */
|
||||
list->startPage = InvalidBlockNumber;
|
||||
list->insertPage = InvalidBlockNumber;
|
||||
memcpy(&list->center, VectorArrayGet(centers, i), VECTOR_SIZE(dimensions));
|
||||
memcpy(&list->center, DatumGetPointer(center), VARSIZE_ANY(center));
|
||||
|
||||
/* Ensure free space */
|
||||
if (PageGetFreeSpace(page) < listSize)
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#define PROGRESS_IVFFLAT_PHASE_ASSIGN 3
|
||||
#define PROGRESS_IVFFLAT_PHASE_LOAD 4
|
||||
|
||||
#define IVFFLAT_LIST_SIZE(_dim) (offsetof(IvfflatListData, center) + VECTOR_SIZE(_dim))
|
||||
#define IVFFLAT_LIST_SIZE(_datum) (offsetof(IvfflatListData, center) + VARSIZE_ANY(_datum))
|
||||
|
||||
#define IvfflatPageGetOpaque(page) ((IvfflatPageOpaque) PageGetSpecialPointer(page))
|
||||
#define IvfflatPageGetMeta(page) ((IvfflatMetaPageData *) PageGetContents(page))
|
||||
@@ -229,7 +229,7 @@ typedef struct IvfflatListData
|
||||
{
|
||||
BlockNumber startPage;
|
||||
BlockNumber insertPage;
|
||||
Vector center;
|
||||
char center[FLEXIBLE_ARRAY_MEMBER];
|
||||
} IvfflatListData;
|
||||
|
||||
typedef IvfflatListData * IvfflatList;
|
||||
|
||||
Reference in New Issue
Block a user