ClickHouse/tests/performance/norm_distance_float.xml
2022-07-03 08:01:49 +02:00

96 lines
2.8 KiB
XML

<test>
<substitutions>
<substitution>
<name>element_type</name>
<values>
<value>Float32</value>
<value>Float64</value>
</values>
</substitution>
</substitutions>
<create_query>
CREATE TABLE vecs_{element_type} (
v Array({element_type})
) ENGINE=Memory;
</create_query>
<!-- Gererate arrays with random data -->
<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),
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),
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),
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)
] AS v
FROM system.numbers
LIMIT 10000000
);
</fill_query>
<settings>
<max_threads>1</max_threads>
</settings>
<!-- Norm kinds-->
<substitutions>
<substitution>
<name>norm</name>
<values>
<value>L1</value>
<value>L2</value>
<value>L2Squared</value>
<value>Linf</value>
</values>
</substitution>
</substitutions>
<!-- 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>
<drop_query>DROP TABLE vecs_{element_type}</drop_query>
</test>