From 8b6eab25a3ca925b05dcba4a3d52a857f377cc76 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 24 Apr 2024 15:34:10 -0700 Subject: [PATCH] Moved IvfflatGetType [skip ci] --- src/ivfbuild.c | 21 +++++++++++++++++++++ src/ivfflat.h | 1 - src/ivfutils.c | 21 --------------------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/ivfbuild.c b/src/ivfbuild.c index ac85949..e95036c 100644 --- a/src/ivfbuild.c +++ b/src/ivfbuild.c @@ -319,6 +319,27 @@ InsertTuples(Relation index, IvfflatBuildState * buildstate, ForkNumber forkNum) } } +/* + * Get type + */ +static IvfflatType +IvfflatGetType(Relation index) +{ + FmgrInfo *procinfo = IvfflatOptionalProcInfo(index, IVFFLAT_TYPE_SUPPORT_PROC); + Oid typid = TupleDescAttr(index->rd_att, 0)->atttypid; + IvfflatType result; + + if (procinfo == NULL) + return IVFFLAT_TYPE_VECTOR; + + result = (IvfflatType) DatumGetInt32(FunctionCall1(procinfo, ObjectIdGetDatum(typid))); + + if (result == IVFFLAT_TYPE_UNSUPPORTED) + elog(ERROR, "type not supported for ivfflat index"); + + return result; +} + /* * Get max dimensions */ diff --git a/src/ivfflat.h b/src/ivfflat.h index 050ca3d..21bcd3a 100644 --- a/src/ivfflat.h +++ b/src/ivfflat.h @@ -281,7 +281,6 @@ VectorArray VectorArrayInit(int maxlen, int dimensions, Size itemsize); void VectorArrayFree(VectorArray arr); void IvfflatKmeans(Relation index, VectorArray samples, VectorArray centers, IvfflatType type); FmgrInfo *IvfflatOptionalProcInfo(Relation index, uint16 procnum); -IvfflatType IvfflatGetType(Relation index); Datum IvfflatNormValue(FmgrInfo *procinfo, Oid collation, Datum value); bool IvfflatCheckNorm(FmgrInfo *procinfo, Oid collation, Datum value); int IvfflatGetLists(Relation index); diff --git a/src/ivfutils.c b/src/ivfutils.c index 0c9d2cf..9b5151d 100644 --- a/src/ivfutils.c +++ b/src/ivfutils.c @@ -61,27 +61,6 @@ IvfflatOptionalProcInfo(Relation index, uint16 procnum) return index_getprocinfo(index, 1, procnum); } -/* - * Get type - */ -IvfflatType -IvfflatGetType(Relation index) -{ - FmgrInfo *procinfo = IvfflatOptionalProcInfo(index, IVFFLAT_TYPE_SUPPORT_PROC); - Oid typid = TupleDescAttr(index->rd_att, 0)->atttypid; - IvfflatType result; - - if (procinfo == NULL) - return IVFFLAT_TYPE_VECTOR; - - result = (IvfflatType) DatumGetInt32(FunctionCall1(procinfo, ObjectIdGetDatum(typid))); - - if (result == IVFFLAT_TYPE_UNSUPPORTED) - elog(ERROR, "type not supported for ivfflat index"); - - return result; -} - /* * Normalize value */