element_type
UInt8
Int16
Int32
Int64
Float32
Float64
CREATE TABLE vecs_{element_type} (
v Array({element_type})
) ENGINE=Memory;
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
LIMIT 10000000
);
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;
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};
1
norm
L1
L2
Linf
SELECT sum(dist) FROM (SELECT {norm}Norm(t) AS dist FROM tuples_{element_type})
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})
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})
SELECT sum(dist) FROM (SELECT {norm}Norm(v) AS dist FROM vecs_{element_type})
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})
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})
DROP TABLE vecs_{element_type}
DROP TABLE tuples_{element_type}