ClickHouse/tests/performance/norm_distance.xml

101 lines
3.2 KiB
XML
Raw Normal View History

<test>
2022-05-23 12:08:15 +00:00
<substitutions>
<substitution>
<name>element_type</name>
<values>
<value>UInt8</value>
<value>Int16</value>
<value>Int32</value>
<value>Int64</value>
<value>Float32</value>
<value>Float64</value>
</values>
</substitution>
</substitutions>
<create_query>
2022-05-23 12:08:15 +00:00
CREATE TABLE vecs_{element_type} (
v Array({element_type})
) ENGINE=Memory;
</create_query>
<!-- Gererate arrays with random data -->
2022-05-23 12:08:15 +00:00
<fill_query>
INSERT INTO vecs_{element_type}
SELECT v FROM (
SELECT
number AS n,
[
rand(n*10),
rand(n*10+1),
rand(n*10+2),
rand(n*10+3),
rand(n*10+4),
rand(n*10+5),
rand(n*10+6),
rand(n*10+7),
rand(n*10+8),
rand(n*10+9)
] AS v
FROM system.numbers
2022-05-23 12:08:15 +00:00
LIMIT 10000000
);
2022-05-23 12:08:15 +00:00
</fill_query>
<!-- The same data in the form of tuples -->
<create_query>
2022-05-23 12:08:15 +00:00
CREATE TABLE tuples_{element_type} (
t Tuple(
{element_type},
{element_type},
{element_type},
{element_type},
{element_type},
{element_type},
{element_type},
{element_type},
{element_type},
{element_type}
)
) ENGINE=Memory;
</create_query>
2022-05-23 12:08:15 +00:00
<fill_query>
INSERT INTO tuples_{element_type}
SELECT (v[1], v[2], v[3], v[4], v[5], v[6], v[7], v[8], v[9], v[10]) FROM vecs_{element_type};
</fill_query>
2022-05-23 15:01:19 +00:00
<settings>
<max_threads>1</max_threads>
</settings>
2022-05-23 16:27:41 +00:00
<!-- Norm kinds-->
<substitutions>
<substitution>
<name>norm</name>
<values>
<value>L1</value>
<value>L2</value>
<value>Linf</value>
</values>
</substitution>
</substitutions>
2022-05-23 16:27:41 +00:00
<!-- Tuples -->
<query>SELECT sum(dist) FROM (SELECT {norm}Norm(t) AS dist FROM tuples_{element_type})</query>
<query>WITH (SELECT t FROM tuples_{element_type} limit 1) AS a SELECT sum(dist) FROM (SELECT {norm}Distance(a, t) AS dist FROM tuples_{element_type})</query>
2022-05-23 12:08:15 +00:00
<query>WITH (SELECT t FROM tuples_{element_type} limit 1) AS a SELECT sum(dist) FROM (SELECT cosineDistance(a, t) AS dist FROM tuples_{element_type})</query>
<!-- Arrays -->
<query>SELECT sum(dist) FROM (SELECT {norm}Norm(v) AS dist FROM vecs_{element_type})</query>
<query>WITH (SELECT v FROM vecs_{element_type} limit 1) AS a SELECT sum(dist) FROM (SELECT {norm}Distance(a, v) AS dist FROM vecs_{element_type})</query>
<query>WITH (SELECT v FROM vecs_{element_type} limit 1) AS a SELECT sum(dist) FROM (SELECT cosineDistance(a, v) AS dist FROM vecs_{element_type})</query>
2022-05-23 12:08:15 +00:00
<drop_query>DROP TABLE vecs_{element_type}</drop_query>
<drop_query>DROP TABLE tuples_{element_type}</drop_query>
</test>