mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-04 00:08:30 +00:00
Improved test [skip ci]
This commit is contained in:
1 parent
48ebde7859
commit
222596b450
1 file changed
+18
-13
@@ -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');");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user