mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-01 18:21:16 +08:00
Added SPARSEVEC_MAX_NNZ
This commit is contained in:
@@ -70,6 +70,11 @@ CheckNnz(int nnz, int dim)
|
||||
(errcode(ERRCODE_DATA_EXCEPTION),
|
||||
errmsg("sparsevec must have at least one element")));
|
||||
|
||||
if (nnz > SPARSEVEC_MAX_NNZ)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("sparsevec cannot have more than %d non-zero elements", SPARSEVEC_MAX_NNZ)));
|
||||
|
||||
if (nnz > dim)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
@@ -190,6 +195,11 @@ sparsevec_in(PG_FUNCTION_ARGS)
|
||||
pt++;
|
||||
}
|
||||
|
||||
if (maxNnz > SPARSEVEC_MAX_NNZ)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
||||
errmsg("sparsevec cannot have more than %d non-zero elements", SPARSEVEC_MAX_NNZ)));
|
||||
|
||||
indices = palloc(maxNnz * sizeof(int32));
|
||||
values = palloc(maxNnz * sizeof(float));
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SPARSEVEC_H
|
||||
|
||||
#define SPARSEVEC_MAX_DIM 100000
|
||||
#define SPARSEVEC_MAX_NNZ 16000
|
||||
|
||||
/* Ensure values are aligned */
|
||||
#define SPARSEVEC_SIZE(_nnz) (offsetof(SparseVector, indices) + MAXALIGN((_nnz) * sizeof(int32)) + (_nnz * sizeof(float)))
|
||||
|
||||
Reference in New Issue
Block a user