mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-10 14:46:56 +08:00
Fixed alignment for bit in IVFFlat - fixes #520
This commit is contained in:
@@ -337,14 +337,20 @@ GetMaxDimensions(IvfflatType type)
|
|||||||
static Size
|
static Size
|
||||||
GetItemSize(IvfflatType type, int dimensions)
|
GetItemSize(IvfflatType type, int dimensions)
|
||||||
{
|
{
|
||||||
|
Size size;
|
||||||
|
|
||||||
if (type == IVFFLAT_TYPE_VECTOR)
|
if (type == IVFFLAT_TYPE_VECTOR)
|
||||||
return VECTOR_SIZE(dimensions);
|
size = VECTOR_SIZE(dimensions);
|
||||||
else if (type == IVFFLAT_TYPE_HALFVEC)
|
else if (type == IVFFLAT_TYPE_HALFVEC)
|
||||||
return HALFVEC_SIZE(dimensions);
|
size = HALFVEC_SIZE(dimensions);
|
||||||
else if (type == IVFFLAT_TYPE_BIT)
|
else if (type == IVFFLAT_TYPE_BIT)
|
||||||
return VARBITTOTALLEN(dimensions);
|
size = VARBITTOTALLEN(dimensions);
|
||||||
else
|
else
|
||||||
elog(ERROR, "Unsupported type");
|
elog(ERROR, "Unsupported type");
|
||||||
|
|
||||||
|
/* Ensure items are aligned to prevent UB */
|
||||||
|
/* Only need 4 byte alignment, but prefer MAXALIGN */
|
||||||
|
return MAXALIGN(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user