mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-11 15:16:54 +08:00
Use consistent style in TAP tests, part 2 [skip ci]
This commit is contained in:
@@ -53,11 +53,13 @@ my $array_sql = join(",", ('random()') x $dim);
|
|||||||
# Initialize primary node
|
# Initialize primary node
|
||||||
$node_primary = get_new_node('primary');
|
$node_primary = get_new_node('primary');
|
||||||
$node_primary->init(allows_streaming => 1);
|
$node_primary->init(allows_streaming => 1);
|
||||||
if ($dim > 32) {
|
if ($dim > 32)
|
||||||
|
{
|
||||||
# TODO use wal_keep_segments for Postgres < 13
|
# TODO use wal_keep_segments for Postgres < 13
|
||||||
$node_primary->append_conf('postgresql.conf', qq(wal_keep_size = 1GB));
|
$node_primary->append_conf('postgresql.conf', qq(wal_keep_size = 1GB));
|
||||||
}
|
}
|
||||||
if ($dim > 1500) {
|
if ($dim > 1500)
|
||||||
|
{
|
||||||
$node_primary->append_conf('postgresql.conf', qq(maintenance_work_mem = 128MB));
|
$node_primary->append_conf('postgresql.conf', qq(maintenance_work_mem = 128MB));
|
||||||
}
|
}
|
||||||
$node_primary->start;
|
$node_primary->start;
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ sub test_recall
|
|||||||
));
|
));
|
||||||
like($explain, qr/Index Scan using idx on tst/);
|
like($explain, qr/Index Scan using idx on tst/);
|
||||||
|
|
||||||
for my $i (0 .. $#queries) {
|
for my $i (0 .. $#queries)
|
||||||
|
{
|
||||||
my $actual = $node->safe_psql("postgres", qq(
|
my $actual = $node->safe_psql("postgres", qq(
|
||||||
SET enable_seqscan = off;
|
SET enable_seqscan = off;
|
||||||
SET ivfflat.probes = $probes;
|
SET ivfflat.probes = $probes;
|
||||||
@@ -33,8 +34,10 @@ sub test_recall
|
|||||||
|
|
||||||
my @expected_ids = split("\n", $expected[$i]);
|
my @expected_ids = split("\n", $expected[$i]);
|
||||||
|
|
||||||
foreach (@expected_ids) {
|
foreach (@expected_ids)
|
||||||
if (exists($actual_set{$_})) {
|
{
|
||||||
|
if (exists($actual_set{$_}))
|
||||||
|
{
|
||||||
$correct++;
|
$correct++;
|
||||||
}
|
}
|
||||||
$total++;
|
$total++;
|
||||||
@@ -74,7 +77,8 @@ foreach (@operators)
|
|||||||
|
|
||||||
# Get exact results
|
# Get exact results
|
||||||
@expected = ();
|
@expected = ();
|
||||||
foreach (@queries) {
|
foreach (@queries)
|
||||||
|
{
|
||||||
my $res = $node->safe_psql("postgres", "SELECT i FROM tst ORDER BY v $operator '$_' LIMIT $limit;");
|
my $res = $node->safe_psql("postgres", "SELECT i FROM tst ORDER BY v $operator '$_' LIMIT $limit;");
|
||||||
push(@expected, $res);
|
push(@expected, $res);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ sub test_index_replay
|
|||||||
or die "Timed out while waiting for replica 1 to catch up";
|
or die "Timed out while waiting for replica 1 to catch up";
|
||||||
|
|
||||||
my @r = ();
|
my @r = ();
|
||||||
for (1 .. $dim) {
|
for (1 .. $dim)
|
||||||
|
{
|
||||||
push(@r, rand());
|
push(@r, rand());
|
||||||
}
|
}
|
||||||
my $sql = join(",", @r);
|
my $sql = join(",", @r);
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use Test::More;
|
|||||||
my $dim = 3;
|
my $dim = 3;
|
||||||
|
|
||||||
my @r = ();
|
my @r = ();
|
||||||
for (1 .. $dim) {
|
for (1 .. $dim)
|
||||||
|
{
|
||||||
my $v = int(rand(1000)) + 1;
|
my $v = int(rand(1000)) + 1;
|
||||||
push(@r, "i % $v");
|
push(@r, "i % $v");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ sub test_recall
|
|||||||
));
|
));
|
||||||
like($explain, qr/Index Scan/);
|
like($explain, qr/Index Scan/);
|
||||||
|
|
||||||
for my $i (0 .. $#queries) {
|
for my $i (0 .. $#queries)
|
||||||
|
{
|
||||||
my $actual = $node->safe_psql("postgres", qq(
|
my $actual = $node->safe_psql("postgres", qq(
|
||||||
SET enable_seqscan = off;
|
SET enable_seqscan = off;
|
||||||
SELECT i FROM tst ORDER BY v $operator '$queries[$i]' LIMIT $limit;
|
SELECT i FROM tst ORDER BY v $operator '$queries[$i]' LIMIT $limit;
|
||||||
@@ -31,8 +32,10 @@ sub test_recall
|
|||||||
|
|
||||||
my @expected_ids = split("\n", $expected[$i]);
|
my @expected_ids = split("\n", $expected[$i]);
|
||||||
|
|
||||||
foreach (@expected_ids) {
|
foreach (@expected_ids)
|
||||||
if (exists($actual_set{$_})) {
|
{
|
||||||
|
if (exists($actual_set{$_}))
|
||||||
|
{
|
||||||
$correct++;
|
$correct++;
|
||||||
}
|
}
|
||||||
$total++;
|
$total++;
|
||||||
@@ -89,9 +92,12 @@ foreach (@operators)
|
|||||||
}
|
}
|
||||||
$node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v $opclass);");
|
$node->safe_psql("postgres", "CREATE INDEX ON tst USING hnsw (v $opclass);");
|
||||||
|
|
||||||
if ($operator eq "<#>") {
|
if ($operator eq "<#>")
|
||||||
|
{
|
||||||
test_recall(0.80, $operator);
|
test_recall(0.80, $operator);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
test_recall(0.99, $operator);
|
test_recall(0.99, $operator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ sub test_recall
|
|||||||
));
|
));
|
||||||
like($explain, qr/Index Scan/);
|
like($explain, qr/Index Scan/);
|
||||||
|
|
||||||
for my $i (0 .. $#queries) {
|
for my $i (0 .. $#queries)
|
||||||
|
{
|
||||||
my $actual = $node->safe_psql("postgres", qq(
|
my $actual = $node->safe_psql("postgres", qq(
|
||||||
SET enable_seqscan = off;
|
SET enable_seqscan = off;
|
||||||
SELECT i FROM tst ORDER BY v $operator '$queries[$i]' LIMIT $limit;
|
SELECT i FROM tst ORDER BY v $operator '$queries[$i]' LIMIT $limit;
|
||||||
@@ -31,8 +32,10 @@ sub test_recall
|
|||||||
|
|
||||||
my @expected_ids = split("\n", $expected[$i]);
|
my @expected_ids = split("\n", $expected[$i]);
|
||||||
|
|
||||||
foreach (@expected_ids) {
|
foreach (@expected_ids)
|
||||||
if (exists($actual_set{$_})) {
|
{
|
||||||
|
if (exists($actual_set{$_}))
|
||||||
|
{
|
||||||
$correct++;
|
$correct++;
|
||||||
}
|
}
|
||||||
$total++;
|
$total++;
|
||||||
@@ -101,9 +104,12 @@ foreach (@operators)
|
|||||||
push(@expected, $res);
|
push(@expected, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($operator eq "<#>") {
|
if ($operator eq "<#>")
|
||||||
|
{
|
||||||
test_recall(0.80, $operator);
|
test_recall(0.80, $operator);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
test_recall(0.99, $operator);
|
test_recall(0.99, $operator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user