pgvector.git / summary / log / commit / refs
commit db747e5aa0ebd229cb384ce3941c2449bc3f4951
Author: Andrew Kane <andrew@ankane.org>
Date: Sun Sep 03 17:34:44 2023 +0000
Get lists from metapage
src/ivfflat.h | 1 +
src/ivfscan.c | 20 +++++++++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/ivfflat.h b/src/ivfflat.h
index 4e701e2f..170137dc 100644
--- a/src/ivfflat.h
+++ b/src/ivfflat.h
@@ -244,6 +244,7 @@ typedef struct IvfflatScanList
typedef struct IvfflatScanOpaqueData
{
int probes;
+ int dimensions;
bool first;
Buffer buf;
diff --git a/src/ivfscan.c b/src/ivfscan.c
index 6caf2b7d..81d3a371 100644
--- a/src/ivfscan.c
+++ b/src/ivfscan.c
@@ -183,26 +183,24 @@ GetScanItems(IndexScanDesc scan, Datum value)
}
/*
- * Get dimensions from metapage
+ * Get the metapage info
*/
-static int
-GetDimensions(Relation index)
+static void
+IvfflatGetMetaPageInfo(Relation index, int *lists, int *dimensions)
{
Buffer buf;
Page page;
IvfflatMetaPage metap;
- int dimensions;
buf = ReadBuffer(index, IVFFLAT_METAPAGE_BLKNO);
LockBuffer(buf, BUFFER_LOCK_SHARE);
page = BufferGetPage(buf);
metap = IvfflatPageGetMeta(page);
- dimensions = metap->dimensions;
+ *lists = metap->dimensions;
+ *dimensions = metap->dimensions;
UnlockReleaseBuffer(buf);
-
- return dimensions;
}
/*
@@ -214,6 +212,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
IndexScanDesc scan;
IvfflatScanOpaque so;
int lists;
+ int dimensions;
AttrNumber attNums[] = {1};
Oid sortOperators[] = {Float8LessOperator};
Oid sortCollations[] = {InvalidOid};
@@ -221,7 +220,9 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
int probes = ivfflat_probes;
scan = RelationGetIndexScan(index, nkeys, norderbys);
- lists = IvfflatGetLists(scan->indexRelation);
+
+ /* Get lists and dimensions from metapage */
+ IvfflatGetMetaPageInfo(index, &lists, &dimensions);
if (probes > lists)
probes = lists;
@@ -230,6 +231,7 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
so->buf = InvalidBuffer;
so->first = true;
so->probes = probes;
+ so->dimensions = dimensions;
/* Set support functions */
so->procinfo = index_getprocinfo(index, 1, IVFFLAT_DISTANCE_PROC);
@@ -311,7 +313,7 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
elog(ERROR, "cannot scan ivfflat index without order");
if (scan->orderByData->sk_flags & SK_ISNULL)
- value = PointerGetDatum(InitVector(GetDimensions(scan->indexRelation)));
+ value = PointerGetDatum(InitVector(so->dimensions));
else
{
value = scan->orderByData->sk_argument;
[parent: 2179414c0597]