Improved test [skip ci]

This commit is contained in:
Andrew Kane committed 2026-12-02 21:14:07 -08:00
1 parent 48ebde7859
commit 222596b450
1 file changed
+18 -13
+18 -13
View File
@@ -14,23 +14,28 @@ $node->safe_psql("postgres", "CREATE EXTENSION vector;");
$node->safe_psql("postgres", "CREATE TABLE tst (i serial, v sparsevec(100000));");
$node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v sparsevec_l2_ops);");
sub random_sparsevec
{
my @elements;
my %indices;
for (1 .. int(rand(1001)))
{
my $index = int(rand(100000)) + 1;
if (!exists($indices{$index}))
{
my $value = rand();
push(@elements, "$index:$value");
$indices{$index} = 1;
}
}
return "{" . join(",", @elements) . "}/100000";
}
for (1 .. 3)
{
for (1 .. 100)
{
my @elements;
my %indices;
for (1 .. int(rand(1001)))
{
my $index = int(rand(100000)) + 1;
if (!exists($indices{$index}))
{
my $value = rand();
push(@elements, "$index:$value");
$indices{$index} = 1;
}
}
my $embedding = "{" . join(",", @elements) . "}/100000";
my $embedding = random_sparsevec();
$node->safe_psql("postgres", "INSERT INTO tst (v) VALUES ('$embedding');");
}