Skip duplicate center check for bit [skip ci]

This commit is contained in:
Andrew Kane
2024-04-16 17:20:48 -07:00
parent 04af15c9d6
commit 4e2b76e627
3 changed files with 20 additions and 14 deletions

View File

@@ -707,14 +707,14 @@ CheckCenters(Relation index, VectorArray centers, IvfflatType type)
elog(ERROR, "Unsupported type"); elog(ERROR, "Unsupported type");
} }
if (type != IVFFLAT_TYPE_BIT)
{
/* Ensure no duplicate centers */ /* Ensure no duplicate centers */
/* Fine to sort in-place */ /* Fine to sort in-place */
if (type == IVFFLAT_TYPE_VECTOR) if (type == IVFFLAT_TYPE_VECTOR)
qsort(centers->items, centers->length, centers->itemsize, CompareVectors); qsort(centers->items, centers->length, centers->itemsize, CompareVectors);
else if (type == IVFFLAT_TYPE_HALFVEC) else if (type == IVFFLAT_TYPE_HALFVEC)
qsort(centers->items, centers->length, centers->itemsize, CompareHalfVectors); qsort(centers->items, centers->length, centers->itemsize, CompareHalfVectors);
else if (type == IVFFLAT_TYPE_BIT)
qsort(centers->items, centers->length, centers->itemsize, CompareBitVectors);
else else
elog(ERROR, "Unsupported type"); elog(ERROR, "Unsupported type");
@@ -723,6 +723,7 @@ CheckCenters(Relation index, VectorArray centers, IvfflatType type)
if (datumIsEqual(PointerGetDatum(VectorArrayGet(centers, i)), PointerGetDatum(VectorArrayGet(centers, i - 1)), false, -1)) if (datumIsEqual(PointerGetDatum(VectorArrayGet(centers, i)), PointerGetDatum(VectorArrayGet(centers, i - 1)), false, -1))
elog(ERROR, "Duplicate centers detected. Please report a bug."); elog(ERROR, "Duplicate centers detected. Please report a bug.");
} }
}
/* Ensure no zero vectors for cosine distance */ /* Ensure no zero vectors for cosine distance */
/* Check NORM_PROC instead of KMEANS_NORM_PROC */ /* Check NORM_PROC instead of KMEANS_NORM_PROC */

View File

@@ -29,4 +29,8 @@ DETAIL: This will cause low recall.
HINT: Drop the index until the table has more data. HINT: Drop the index until the table has more data.
CREATE INDEX ON t USING ivfflat ((val::bit(64001)) bit_hamming_ops) WITH (lists = 1); CREATE INDEX ON t USING ivfflat ((val::bit(64001)) bit_hamming_ops) WITH (lists = 1);
ERROR: column cannot have more than 64000 dimensions for ivfflat index ERROR: column cannot have more than 64000 dimensions for ivfflat index
CREATE INDEX ON t USING ivfflat ((val::bit(2)) bit_hamming_ops) WITH (lists = 5);
NOTICE: ivfflat index created with little data
DETAIL: This will cause low recall.
HINT: Drop the index until the table has more data.
DROP TABLE t; DROP TABLE t;

View File

@@ -16,4 +16,5 @@ CREATE TABLE t (val varbit(3));
CREATE INDEX ON t USING ivfflat (val bit_hamming_ops) WITH (lists = 1); CREATE INDEX ON t USING ivfflat (val bit_hamming_ops) WITH (lists = 1);
CREATE INDEX ON t USING ivfflat ((val::bit(3)) bit_hamming_ops) WITH (lists = 1); CREATE INDEX ON t USING ivfflat ((val::bit(3)) bit_hamming_ops) WITH (lists = 1);
CREATE INDEX ON t USING ivfflat ((val::bit(64001)) bit_hamming_ops) WITH (lists = 1); CREATE INDEX ON t USING ivfflat ((val::bit(64001)) bit_hamming_ops) WITH (lists = 1);
CREATE INDEX ON t USING ivfflat ((val::bit(2)) bit_hamming_ops) WITH (lists = 5);
DROP TABLE t; DROP TABLE t;