更新时间:2024-10-25 GMT+08:00

HLL操作符

HLL类型支持如下操作符:

表1 HLL操作符

HLL操作符

描述

返回值类型

示例

=

比较hll或hll_hashval的值是否相等。

bool

  • hll
1
2
3
4
5
SELECT (hll_empty() || hll_hash_integer(1)) = (hll_empty() || hll_hash_integer(1));
 ?column?
----------
 t
(1 row)
  • hll_hashval
1
2
3
4
5
SELECT hll_hash_integer(1) = hll_hash_integer(1);
 ?column? 
----------
 t
(1 row)

<> or !=

比较hll或hll_hashval是否不相等。

bool

  • hll
1
2
3
4
5
SELECT (hll_empty() || hll_hash_integer(1)) <> (hll_empty() || hll_hash_integer(2));
 ?column? 
----------
 t
(1 row)
  • hll_hashval
1
2
3
4
5
SELECT hll_hash_integer(1) <> hll_hash_integer(2);
 ?column? 
----------
 t
(1 row)

||

可代表hll_add,hll_union,hll_add_rev三个函数的功能。

hll

  • hll_add
1
2
3
4
5
SELECT hll_empty() || hll_hash_integer(1);
         ?column?         
--------------------------
 \x128b7f8895a3f5af28cafe
(1 row)
  • hll_add_rev
1
2
3
4
5
SELECT hll_hash_integer(1) || hll_empty();
         ?column?         
--------------------------
 \x128b7f8895a3f5af28cafe
(1 row)
  • hll_union
1
2
3
4
5
SELECT (hll_empty() || hll_hash_integer(1)) || (hll_empty() || hll_hash_integer(2));
                 ?column?                 
------------------------------------------
 \x128b7f8895a3f5af28cafeda0ce907e4355b60
(1 row)

#

计算出hll的Dintinct值,同hll_cardinality函数。

integer

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