diff --git a/src/hnswbuild.c b/src/hnswbuild.c index a9c737c..947f52e 100644 --- a/src/hnswbuild.c +++ b/src/hnswbuild.c @@ -671,6 +671,12 @@ HnswSharedMemoryAlloc(Size size, void *state) static void InitBuildState(HnswBuildState * buildstate, Relation heap, Relation index, IndexInfo *indexInfo, ForkNumber forkNum) { + int maxDimensions = HNSW_MAX_DIM; + Oid typid = TupleDescAttr(index->rd_att, 0)->atttypid; + + if (typid == BITOID || typid == VARBITOID) + maxDimensions *= 32; + buildstate->heap = heap; buildstate->index = index; buildstate->indexInfo = indexInfo; @@ -684,8 +690,8 @@ InitBuildState(HnswBuildState * buildstate, Relation heap, Relation index, Index if (buildstate->dimensions < 0) elog(ERROR, "column does not have dimensions"); - if (buildstate->dimensions > HNSW_MAX_DIM) - elog(ERROR, "column cannot have more than %d dimensions for hnsw index", HNSW_MAX_DIM); + if (buildstate->dimensions > maxDimensions) + elog(ERROR, "column cannot have more than %d dimensions for hnsw index", maxDimensions); if (buildstate->efConstruction < 2 * buildstate->m) elog(ERROR, "ef_construction must be greater than or equal to 2 * m");