云数据库 GAUSSDB-HLL函数和操作符:功能函数

时间:2024-11-02 18:50:29

功能函数

  • hll_empty()

    描述:创建一个空的hll。

    返回值类型:hll

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_empty();
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000002b05000000000000000000000000000000000000
    (1 row)
    
  • hll_empty(int32 log2m)

    描述:创建空的hll并指定参数log2m,取值范围是10到16。若输入-1,则采用内置默认值。

    返回值类型:hll

    示例:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    gaussdb=# SELECT hll_empty(10);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000002b04000000000000000000000000000000000000
    (1 row)
    
    gaussdb=# SELECT hll_empty(-1);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000002b05000000000000000000000000000000000000
    (1 row)
    
  • hll_empty(int32 log2m, int32 log2explicit)

    描述:创建空的hll并依次指定参数log2m、log2explicit。log2explicit取值范围是0到12,0表示直接跳过Explicit模式。该参数可以用来设置Explicit模式的阈值大小,在数据段长度达到2log2explicit后切换为Sparse模式或者Full模式。若输入-1,则log2explicit采用内置默认值。

    返回值类型: hll

    示例:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    gaussdb=# SELECT hll_empty(10, 4);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000001304000000000000000000000000000000000000
    (1 row)
    
    gaussdb=# SELECT hll_empty(10, -1);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000002b04000000000000000000000000000000000000
    (1 row)
    
  • hll_empty(int32 log2m, int32 log2explicit, int64 log2sparse)

    描述:创建空的hll并依次指定参数log2m、log2explicit、log2sparse。log2sparse取值范围是0到14,0表示直接跳过Sparse模式。该参数可以用来设置Sparse模式的阈值大小,在数据段长度达到2log2sparse后切换为Full模式。若输入-1,则log2sparse采用内置默认值。

    返回值类型:hll

    示例:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    gaussdb=# SELECT hll_empty(10, 4, 8);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000001204000000000000000000000000000000000000
    (1 row)
    
    gaussdb=# SELECT hll_empty(10, 4, -1);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000001304000000000000000000000000000000000000
    (1 row)
    
  • hll_empty(int32 log2m, int32 log2explicit, int64 log2sparse, int32 duplicatecheck)

    描述:创建空的hll并依次指定参数log2m、log2explicit、log2sparse、duplicatecheck。duplicatecheck取0或者1,表示是否开启该模式,默认情况下该模式会关闭。若输入-1,则duplicatecheck采用内置默认值。

    返回值类型:hll

    示例:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    gaussdb=# SELECT hll_empty(10, 4, 8, 0);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000001204000000000000000000000000000000000000
    (1 row)
    
    gaussdb=# SELECT hll_empty(10, 4, 8, -1);
                             hll_empty
    ------------------------------------------------------------
     \x484c4c00000000001204000000000000000000000000000000000000
    (1 row)
    
  • hll_add(hll, hll_hashval)

    描述:把hll_hashval加入到hll中。

    返回值类型:hll

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_add(hll_empty(), hll_hash_integer(1));
                                      hll_add
    ----------------------------------------------------------------------------
     \x484c4c08000002002b0900000000000000f03f3e2921ff133fbaed3e2921ff133fbaed00
    (1 row)
    
  • hll_add_rev(hll_hashval, hll)

    描述:把hll_hashval加入到hll中,和hll_add功能一样,只是参数位置进行了交换。

    返回值类型:hll

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_add_rev(hll_hash_integer(1), hll_empty());
                                    hll_add_rev
    ----------------------------------------------------------------------------
     \x484c4c08000002002b0900000000000000f03f3e2921ff133fbaed3e2921ff133fbaed00
    (1 row)
    
  • hll_eq(hll, hll)

    描述:比较两个hll是否相等。

    返回值类型:bool

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_eq(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2)));
     hll_eq 
    --------
     f
    (1 row)
    
  • hll_ne(hll, hll)

    描述:比较两个hll是否不相等。

    返回值类型:bool

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_ne(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2)));
     hll_ne 
    --------
     t
    (1 row)
    
  • hll_cardinality(hll)

    描述:计算hll的distinct值。

    返回值类型:int

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_cardinality(hll_empty() || hll_hash_integer(1));
     hll_cardinality 
    -----------------
                   1
    (1 row)
    
  • hll_union(hll, hll)

    描述:把两个hll数据结构union成一个。

    返回值类型:hll

    示例:

    1
    2
    3
    4
    5
    gaussdb=# SELECT hll_union(hll_add(hll_empty(), hll_hash_integer(1)), hll_add(hll_empty(), hll_hash_integer(2)));
                                             hll_union
    --------------------------------------------------------------------------------------------
     \x484c4c10002000002b090000000000000000400000000000000000b3ccc49320cca1ae3e2921ff133fbaed00
    (1 row)
    
support.huaweicloud.com/centralized-devg-v3-gaussdb/gaussdb-12-0351.html