mirror of
https://github.com/pgvector/pgvector.git
synced 2026-10-23 10:48:54 +03:00
Fixed conversion warnings [skip ci]
This commit is contained in:
@@ -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]));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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, '{');
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user