pgvector.git / summary / log / commit / refs
commit a0bd768bcb00ecfd33363d9daa78571eb736fd8e
Author: Andrew Kane <andrew@ankane.org>
Date: Fri Aug 14 00:50:37 2026 +0000
Fixed conversion warnings [skip ci]
src/halfvec.c | 4 ++--
src/hnswbuild.c | 6 +++---
src/hnswutils.c | 4 ++--
src/ivfbuild.c | 2 +-
src/ivfflat.h | 2 +-
src/ivfkmeans.c | 2 +-
src/ivfscan.c | 4 ++--
src/sparsevec.c | 4 ++--
src/sparsevec.h | 6 +++---
src/vector.c | 4 ++--
10 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/halfvec.c b/src/halfvec.c
index e638893b..a6e785b0 100644
--- a/src/halfvec.c
+++ b/src/halfvec.c
@@ -310,7 +310,7 @@ halfvec_out(PG_FUNCTION_ARGS)
*
* 3 bytes for [, ], and \0
*/
- buf = (char *) palloc(add_size(mul_size(FLOAT_SHORTEST_DECIMAL_LEN, dim), 3));
+ buf = (char *) palloc(add_size(mul_size(FLOAT_SHORTEST_DECIMAL_LEN, (Size) dim), 3));
ptr = buf;
AppendChar(ptr, '[');
@@ -519,7 +519,7 @@ halfvec_to_float4(PG_FUNCTION_ARGS)
Datum *datums;
ArrayType *result;
- datums = palloc_array_checked(Datum, vec->dim);
+ datums = palloc_array_checked(Datum, (Size) vec->dim);
for (int i = 0; i < vec->dim; i++)
datums[i] = Float4GetDatum(HalfToFloat4(vec->x[i]));
diff --git a/src/hnswbuild.c b/src/hnswbuild.c
index 12799b24..0c90dac5 100644
--- a/src/hnswbuild.c
+++ b/src/hnswbuild.c
@@ -102,7 +102,7 @@ CreateMetaPage(HnswBuildState * buildstate)
metap = HnswPageGetMeta(page);
metap->magicNumber = HNSW_MAGIC_NUMBER;
metap->version = HNSW_VERSION;
- metap->dimensions = buildstate->dimensions;
+ metap->dimensions = (uint32) buildstate->dimensions;
metap->m = (uint16) buildstate->m;
metap->efConstruction = (uint16) buildstate->efConstruction;
metap->entryBlkno = InvalidBlockNumber;
@@ -934,7 +934,7 @@ HnswBeginParallel(HnswBuildState * buildstate, bool isconcurrent, int request)
char *hnswarea;
HnswLeader *hnswleader = palloc0_object(HnswLeader);
bool leaderparticipates = true;
- long querylen;
+ Size querylen;
#ifdef DISABLE_LEADER_PARTICIPATION
leaderparticipates = false;
@@ -958,7 +958,7 @@ HnswBeginParallel(HnswBuildState * buildstate, bool isconcurrent, int request)
/* Leave space for other objects in shared memory */
/* Docker has a default limit of 64 MB for shm_size */
/* which happens to be the default value of maintenance_work_mem */
- esthnswarea = mul_size(maintenance_work_mem, 1024);
+ esthnswarea = mul_size((Size) maintenance_work_mem, 1024);
estother = 3 * 1024 * 1024;
if (esthnswarea > estother)
esthnswarea -= estother;
diff --git a/src/hnswutils.c b/src/hnswutils.c
index 0cf1595e..6e01dbcd 100644
--- a/src/hnswutils.c
+++ b/src/hnswutils.c
@@ -831,7 +831,7 @@ HnswSearchLayer(char *base, HnswQuery * q, List *ep, int ef, int lc, Relation in
HnswNeighborArray *localNeighborhood = NULL;
Size neighborhoodSize = 0;
int lm = HnswGetLayerM(m, lc);
- HnswUnvisited *unvisited = palloc_array_checked(HnswUnvisited, lm);
+ HnswUnvisited *unvisited = palloc_array_checked(HnswUnvisited, (Size) lm);
int unvisitedLength;
bool inMemory = index == NULL;
@@ -1074,7 +1074,7 @@ SelectNeighbors(char *base, List *c, int lm, HnswSupport * support, bool *closer
if (list_length(w) <= lm)
return w;
- wd = palloc_array_checked(HnswCandidate *, list_length(w));
+ wd = palloc_array_checked(HnswCandidate *, (Size) list_length(w));
/* Ensure order of candidates is deterministic for closer caching */
if (sortCandidates)
diff --git a/src/ivfbuild.c b/src/ivfbuild.c
index ddd0fb50..cc7eebdb 100644
--- a/src/ivfbuild.c
+++ b/src/ivfbuild.c
@@ -840,7 +840,7 @@ IvfflatBeginParallel(IvfflatBuildState * buildstate, bool isconcurrent, int requ
char *ivfcenters;
IvfflatLeader *ivfleader = palloc0_object(IvfflatLeader);
bool leaderparticipates = true;
- long querylen;
+ Size querylen;
#ifdef DISABLE_LEADER_PARTICIPATION
leaderparticipates = false;
diff --git a/src/ivfflat.h b/src/ivfflat.h
index 66830b9b..d8603a26 100644
--- a/src/ivfflat.h
+++ b/src/ivfflat.h
@@ -326,7 +326,7 @@ VectorArrayGet(VectorArray arr, int offset)
if (offset < 0 || offset >= arr->maxlen)
elog(ERROR, "index out of bounds");
- return ((char *) arr->items) + (offset * arr->itemsize);
+ return ((char *) arr->items) + ((Size) offset * arr->itemsize);
}
static inline void
diff --git a/src/ivfkmeans.c b/src/ivfkmeans.c
index 2327a3c8..423d9272 100644
--- a/src/ivfkmeans.c
+++ b/src/ivfkmeans.c
@@ -25,7 +25,7 @@ InitCenters(Relation index, VectorArray samples, VectorArray centers, float *low
{
FmgrInfo *procinfo;
Oid collation;
- float *weight = palloc_array_checked(float, samples->length);
+ float *weight = palloc_array_checked(float, (Size) samples->length);
int numCenters = centers->maxlen;
int numSamples = samples->length;
diff --git a/src/ivfscan.c b/src/ivfscan.c
index c25f3532..1408a8ef 100644
--- a/src/ivfscan.c
+++ b/src/ivfscan.c
@@ -318,9 +318,9 @@ ivfflatbeginscan(Relation index, int nkeys, int norderbys)
so->bas = GetAccessStrategy(BAS_BULKREAD);
so->listQueue = pairingheap_allocate(CompareLists, scan);
- so->listPages = palloc_array_checked(BlockNumber, maxProbes);
+ so->listPages = palloc_array_checked(BlockNumber, (Size) maxProbes);
so->listIndex = 0;
- so->lists = palloc_array_checked(IvfflatScanList, maxProbes);
+ so->lists = palloc_array_checked(IvfflatScanList, (Size) maxProbes);
MemoryContextSwitchTo(oldCtx);
diff --git a/src/sparsevec.c b/src/sparsevec.c
index ab5a6bbf..49283c94 100644
--- a/src/sparsevec.c
+++ b/src/sparsevec.c
@@ -392,7 +392,7 @@ sparsevec_in(PG_FUNCTION_ARGS)
CheckDim(dim);
CheckExpectedDim(typmod, dim);
- qsort(elements, nnz, sizeof(SparseInputElement), CompareIndices);
+ qsort(elements, (Size) nnz, sizeof(SparseInputElement), CompareIndices);
result = InitSparseVector(dim, nnz);
rvalues = SPARSEVEC_VALUES(result);
@@ -449,7 +449,7 @@ sparsevec_out(PG_FUNCTION_ARGS)
*
* 4 bytes for {, }, /, and \0
*/
- buf = (char *) palloc(add_size(mul_size(12 + FLOAT_SHORTEST_DECIMAL_LEN, sparsevec->nnz), 15));
+ buf = (char *) palloc(add_size(mul_size(12 + FLOAT_SHORTEST_DECIMAL_LEN, (Size) sparsevec->nnz), 15));
ptr = buf;
AppendChar(ptr, '{');
diff --git a/src/sparsevec.h b/src/sparsevec.h
index e8ab355c..90c0d72e 100644
--- a/src/sparsevec.h
+++ b/src/sparsevec.h
@@ -35,15 +35,15 @@ SPARSEVEC_SIZE(int nnz)
{
Size size = offsetof(SparseVector, indices);
- size = add_size(size, mul_size(sizeof(int32), nnz));
- size = add_size(size, mul_size(sizeof(float), nnz));
+ size = add_size(size, mul_size(sizeof(int32), (Size) nnz));
+ size = add_size(size, mul_size(sizeof(float), (Size) nnz));
return size;
}
static inline float *
SPARSEVEC_VALUES(SparseVector * x)
{
- return (float *) (((char *) x) + offsetof(SparseVector, indices) + (x->nnz * sizeof(int32)));
+ return (float *) (((char *) x) + offsetof(SparseVector, indices) + ((Size) x->nnz * sizeof(int32)));
}
SparseVector *InitSparseVector(int dim, int nnz);
diff --git a/src/vector.c b/src/vector.c
index d0310dd1..898aafbe 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -305,7 +305,7 @@ vector_out(PG_FUNCTION_ARGS)
*
* 3 bytes for [, ], and \0
*/
- buf = (char *) palloc(add_size(mul_size(FLOAT_SHORTEST_DECIMAL_LEN, dim), 3));
+ buf = (char *) palloc(add_size(mul_size(FLOAT_SHORTEST_DECIMAL_LEN, (Size) dim), 3));
ptr = buf;
AppendChar(ptr, '[');
@@ -522,7 +522,7 @@ vector_to_float4(PG_FUNCTION_ARGS)
Datum *datums;
ArrayType *result;
- datums = palloc_array_checked(Datum, vec->dim);
+ datums = palloc_array_checked(Datum, (Size) vec->dim);
for (int i = 0; i < vec->dim; i++)
datums[i] = Float4GetDatum(vec->x[i]);
[parent: 1b03f094eed3]