2019-06-13 14:04:38 +00:00
|
|
|
DROP TABLE IF EXISTS codecTest;
|
|
|
|
|
|
|
|
CREATE TABLE codecTest (
|
|
|
|
key UInt64,
|
2019-06-19 14:51:48 +00:00
|
|
|
name String,
|
2019-06-13 14:04:38 +00:00
|
|
|
ref_valueF64 Float64,
|
|
|
|
ref_valueF32 Float32,
|
|
|
|
valueF64 Float64 CODEC(Gorilla),
|
|
|
|
valueF32 Float32 CODEC(Gorilla)
|
|
|
|
) Engine = MergeTree ORDER BY key;
|
|
|
|
|
|
|
|
-- best case - same value
|
2019-06-19 14:51:48 +00:00
|
|
|
INSERT INTO codecTest (key, name, ref_valueF64, valueF64, ref_valueF32, valueF32)
|
|
|
|
SELECT number AS n, 'e()', e() AS v, v, v, v FROM system.numbers LIMIT 1, 100;
|
2019-06-13 14:04:38 +00:00
|
|
|
|
|
|
|
-- good case - values that grow insignificantly
|
2019-06-19 14:51:48 +00:00
|
|
|
INSERT INTO codecTest (key, name, ref_valueF64, valueF64, ref_valueF32, valueF32)
|
|
|
|
SELECT number AS n, 'log2(n)', log2(n) AS v, v, v, v FROM system.numbers LIMIT 101, 100;
|
2019-06-13 14:04:38 +00:00
|
|
|
|
|
|
|
-- bad case - values differ significantly
|
2019-06-19 14:51:48 +00:00
|
|
|
INSERT INTO codecTest (key, name, ref_valueF64, valueF64, ref_valueF32, valueF32)
|
|
|
|
SELECT number AS n, 'n*sqrt(n)', n*sqrt(n) AS v, v, v, v FROM system.numbers LIMIT 201, 100;
|
2019-06-13 14:04:38 +00:00
|
|
|
|
2019-06-19 10:38:15 +00:00
|
|
|
-- worst case - almost like a random values
|
2019-06-19 14:51:48 +00:00
|
|
|
INSERT INTO codecTest (key, name, ref_valueF64, valueF64, ref_valueF32, valueF32)
|
|
|
|
SELECT number AS n, 'sin(n*n*n)*n', sin(n * n * n * n* n) AS v, v, v, v FROM system.numbers LIMIT 301, 100;
|
2019-06-13 14:04:38 +00:00
|
|
|
|
|
|
|
|
2019-06-19 14:51:48 +00:00
|
|
|
-- These floating-point values are expected to be BINARY equal, so comparing by-value is Ok here.
|
2019-06-13 14:04:38 +00:00
|
|
|
|
2019-06-19 14:51:48 +00:00
|
|
|
-- referencing previous row key, value, and case name to simplify debugging.
|
2019-06-13 14:04:38 +00:00
|
|
|
SELECT 'F64';
|
|
|
|
SELECT
|
2019-06-19 14:51:48 +00:00
|
|
|
c1.key, c1.name,
|
|
|
|
c1.ref_valueF64, c1.valueF64, c1.ref_valueF64 - c1.valueF64 AS dF64,
|
|
|
|
'prev:',
|
|
|
|
c2.key, c2.ref_valueF64
|
|
|
|
FROM
|
|
|
|
codecTest as c1, codecTest as c2
|
2019-06-13 14:04:38 +00:00
|
|
|
WHERE
|
|
|
|
dF64 != 0
|
2019-06-19 14:51:48 +00:00
|
|
|
AND
|
|
|
|
c2.key = c1.key - 1
|
2019-06-13 14:04:38 +00:00
|
|
|
LIMIT 10;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT 'F32';
|
|
|
|
SELECT
|
2019-06-19 14:51:48 +00:00
|
|
|
c1.key, c1.name,
|
|
|
|
c1.ref_valueF32, c1.valueF32, c1.ref_valueF32 - c1.valueF32 AS dF32,
|
|
|
|
'prev:',
|
|
|
|
c2.key, c2.ref_valueF32
|
|
|
|
FROM
|
|
|
|
codecTest as c1, codecTest as c2
|
2019-06-13 14:04:38 +00:00
|
|
|
WHERE
|
|
|
|
dF32 != 0
|
2019-06-19 14:51:48 +00:00
|
|
|
AND
|
|
|
|
c2.key = c1.key - 1
|
2019-06-13 14:04:38 +00:00
|
|
|
LIMIT 10;
|
|
|
|
|
2020-02-11 18:05:08 +00:00
|
|
|
DROP TABLE IF EXISTS codecTest;
|