pgvector.git / summary / log / commit / refs
commit 0959e69529ebdd27247d71aba1635db3f2c21691
Author: Andrew Kane <andrew@ankane.org>
Date: Sat Apr 27 00:24:15 2024 +0000
Added comments [skip ci]
src/sparsevec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/sparsevec.c b/src/sparsevec.c
index 9fec38a0..8cd37731 100644
--- a/src/sparsevec.c
+++ b/src/sparsevec.c
@@ -539,6 +539,7 @@ sparsevec_recv(PG_FUNCTION_ARGS)
result = InitSparseVector(dim, nnz);
values = SPARSEVEC_VALUES(result);
+ /* Binary representation uses zero-based numbering for indices */
for (int i = 0; i < nnz; i++)
{
result->indices[i] = pq_getmsgint(buf, sizeof(int32));
@@ -549,6 +550,7 @@ sparsevec_recv(PG_FUNCTION_ARGS)
{
values[i] = pq_getmsgfloat4(buf);
CheckElement(values[i]);
+
if (values[i] == 0)
ereport(ERROR,
(errcode(ERRCODE_DATA_EXCEPTION),
@@ -573,8 +575,11 @@ sparsevec_send(PG_FUNCTION_ARGS)
pq_sendint(&buf, svec->dim, sizeof(int32));
pq_sendint(&buf, svec->nnz, sizeof(int32));
pq_sendint(&buf, svec->unused, sizeof(int32));
+
+ /* Binary representation uses zero-based numbering for indices */
for (int i = 0; i < svec->nnz; i++)
pq_sendint(&buf, svec->indices[i], sizeof(int32));
+
for (int i = 0; i < svec->nnz; i++)
pq_sendfloat4(&buf, values[i]);
[parent: 1e9490717945]