Updated on 2023-02-08 GMT+08:00

HLL Operators

=

Description: Compares the values of hll and hll_hashval types to check whether they are the same.

Return type: bool

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
--hll
select (hll_empty() || hll_hash_integer(1)) = (hll_empty() || hll_hash_integer(1));
column 
----------
 t
(1 row)

--hll_hashval
select hll_hash_integer(1) = hll_hash_integer(1);
 ?column? 
----------
 t
(1 row)

<> or !=

Description: Compares the values of hll and hll_hashval types to check whether they are different.

Return type: bool

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
--hll
select (hll_empty() || hll_hash_integer(1)) <> (hll_empty() || hll_hash_integer(2));
 ?column? 
----------
 t
(1 row)

--hll_hashval
select hll_hash_integer(1) <> hll_hash_integer(2);
 ?column? 
----------
 t
(1 row)

||

Description: Represents the functions of hll_add, hll_union, and hll_add_rev.

Return type: hll

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
--hll_add
select hll_empty() || hll_hash_integer(1);
         ?column?         
--------------------------
 \x128b7f8895a3f5af28cafe
(1 row)
 
--hll_add_rev
select hll_hash_integer(1) || hll_empty();
         ?column?         
--------------------------
 \x128b7f8895a3f5af28cafe
(1 row)
 
--hll_union
select (hll_empty() || hll_hash_integer(1)) || (hll_empty() || hll_hash_integer(2));
                 ?column?                 
------------------------------------------
 \x128b7f8895a3f5af28cafeda0ce907e4355b60
(1 row)

#

Description: Calculates the number of distinct values of an HLL. It works the same as the hll_cardinality function.

Return type: integer

Example:

1
2
3
4
5
select #(hll_empty() || hll_hash_integer(1));
 ?column? 
----------
        1
(1 row)