File: cumulative_add_cardinality_correction.out

package info (click to toggle)
postgresql-hll 2.18-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 58,720 kB
  • sloc: ansic: 2,805; sql: 2,160; cpp: 201; makefile: 22; sh: 1
file content (68 lines) | stat: -rw-r--r-- 2,117 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
-- ================================================================
-- Setup the table
--
set extra_float_digits=0;
SELECT hll_set_output_version(1);
 hll_set_output_version 
------------------------
                      1
(1 row)

-- This test relies on a non-standard fixed sparse-to-compressed
-- threshold value.
--
SELECT hll_set_max_sparse(0);
 hll_set_max_sparse 
--------------------
                 -1
(1 row)

DROP TABLE IF EXISTS test_msgfjqhm;
NOTICE:  table "test_msgfjqhm" does not exist, skipping
CREATE TABLE test_msgfjqhm (
    recno                       SERIAL,
    cardinality                 double precision,
    raw_value                   bigint,
    union_compressed_multiset   hll
);
-- Copy the CSV data into the table
--
\copy test_msgfjqhm (cardinality, raw_value, union_compressed_multiset) from sql/data/cumulative_add_cardinality_correction.csv with csv header
SELECT COUNT(*) FROM test_msgfjqhm;
 count 
-------
  6144
(1 row)

--  Test incremental adding.
SELECT curr.recno,
       curr.union_compressed_multiset,
       hll_add(prev.union_compressed_multiset, hll_hashval(curr.raw_value))
  FROM test_msgfjqhm prev, test_msgfjqhm curr
 WHERE curr.recno > 1
   AND curr.recno = prev.recno + 1
   AND curr.union_compressed_multiset != 
       hll_add(prev.union_compressed_multiset, hll_hashval(curr.raw_value))
 ORDER BY curr.recno;
 recno | union_compressed_multiset | hll_add 
-------+---------------------------+---------
(0 rows)

--  Test cardinality of incremental adds.
SELECT curr.recno,
       curr.cardinality,
       hll_cardinality(hll_add(prev.union_compressed_multiset,
                       hll_hashval(curr.raw_value)))
  FROM test_msgfjqhm prev, test_msgfjqhm curr
 WHERE curr.recno > 1
   AND curr.recno = prev.recno + 1
   AND round(curr.cardinality::numeric, 10) != 
       round(hll_cardinality(hll_add(prev.union_compressed_multiset,
                             hll_hashval(curr.raw_value)))::numeric,
             10)
 ORDER BY curr.recno;
 recno | cardinality | hll_cardinality 
-------+-------------+-----------------
(0 rows)

DROP TABLE test_msgfjqhm;