diff --git a/test/t/038_hnsw_sparsevec_vacuum_insert.pl b/test/t/038_hnsw_sparsevec_vacuum_insert.pl index ce78c5a2..df2e3738 100644 --- a/test/t/038_hnsw_sparsevec_vacuum_insert.pl +++ b/test/t/038_hnsw_sparsevec_vacuum_insert.pl @@ -16,9 +16,10 @@ $node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v sparsevec_l2_ops sub random_sparsevec { + my ($nnz) = @_; my @elements; my %indices; - for (1 .. int(rand(1001))) + while (keys %indices < $nnz) { my $index = int(rand(100000)) + 1; if (!exists($indices{$index})) @@ -37,7 +38,7 @@ for (1 .. 3) { for (1 .. 100) { - my $embedding = random_sparsevec(); + my $embedding = random_sparsevec(int(rand(1001))); $node->safe_psql("postgres", "INSERT INTO tst (v) VALUES ('$embedding');"); }