返回首页

gbase数据、南大通用产品文档:GBase8c日志函数

更新日期:2024年09月11日

hll 主要存在三种模式Explicit、Sparse、Full。当数据规模比较小的时候会使用Explicit
模式,这种模式下distinct 值的计算是没有误差的;随着distinct 值越来越多,hll 会先后转
换为Sparse 模式和Full 模式,这两种模式在计算结果上没有任何区别,只影响hll 函数的计
算效率和hll 对象的存储空间。下面的函数可以用于查看hll 的一些参数。

hll_print(hll)
描述:打印hll 的一些debug 参数信息。
示例:
gbase=# select hll_print(hll_empty());

GBase 8c SQL 参考手册
南大通用数据技术股份有限公司
299
hll_print
-----------------------------------------------------------------------------
--
type=1(HLL_EMPTY), log2m=14, log2explicit=10, log2sparse=12, duplicatecheck=0
(1 row)

hll_type(hll)
描述:查看当前hll 的类型。返回值具体含义如下:返回值0,表示HLL_UNINIT,未
初始化的hll 对象;
返回值1,
表示HLL_EMPTY,
hll 空对象;
返回值2,
表示HLL_EXPLICIT,
Explicit 模式的hll 对象;返回值3,表示HLL_SPARSE,Sparse 模式的hll 对象;返回值4,
表示HLL_FULL,Full 模式的hll 对象;返回值5,表示HLL_UNDEFINED,不合法的hll
对象。
示例:
gbase=# select hll_type(hll_empty());
hll_type
----------
1
(1 row)

hll_log2m(hll)
描述:查看当前hll 数据结构中的log2m 数值,log2m 是分桶数的对数值,此值会影响
最后hll 计算distinct 误差率,误差率计算公式为±1.04/√(2 ^ log2m)。当显式指定log2m 的
取值为10-16 之间时,hll 会设置分桶数为2log2m。当显示指定log2explicit 为-1 时,会采用
内置默认值。
示例:
gbase=# select hll_log2m(hll_empty());
hll_log2m
-----------
14
(1 row)
gbase=# select hll_log2m(hll_empty(10));
hll_log2m
-----------
10

GBase 8c SQL 参考手册
南大通用数据技术股份有限公司
300
(1 row)
gbase=# select hll_log2m(hll_empty(-1));
hll_log2m
-----------
14
(1 row)

hll_log2explicit(hll)
描述:查看当前hll 数据结构中的log2explicit 数值。hll 通常会由Explicit 模式到Sparse
模式再到Full 模式,这个过程称为promotion hierarchy 策略。可以通过调整log2explicit 值
的大小改变策略,比如log2explicit 为0 的时候就会跳过Explicit 模式而直接进入Sparse 模
式。当显式指定log2explicit 的取值为1-12 之间时,hll 会在数据段长度超过2log2explicit 时
转为Sparse 模式。当显示指定log2explicit 为-1 时,会采用内置默认值。
示例:
gbase=# select hll_log2explicit(hll_empty());
hll_log2explicit
------------------
10
(1 row)
gbase=# select hll_log2explicit(hll_empty(12, 8));
hll_log2explicit
------------------
8
(1 row)
gbase=# select hll_log2explicit(hll_empty(12, -1));
hll_log2explicit
------------------
10
(1 row)

hll_log2sparse(hll)
描述:查看当前hll 数据结构中的log2sparse 数值。hll 通常会由Explicit 模式到Sparse
模式再到Full 模式,这个过程称为promotion hierarchy 策略。可以通过调整log2sparse 值的
大小改变策略,
比如log2sparse 为0 的时候就会跳过Sparse 模式而直接进入Full 模式。
当显

GBase 8c SQL 参考手册
南大通用数据技术股份有限公司
301
式指定Sparse 的取值为1-14 之间时,hll 会在数据段长度超过2log2sparse 时转为Full 模式。
当显示指定log2sparse 为-1 时,会采用内置默认值。
示例:
gbase=# select hll_log2sparse(hll_empty());
hll_log2sparse
----------------
12
(1 row)
gbase=# select hll_log2sparse(hll_empty(12, 8, 10));
hll_log2sparse
----------------
10
(1 row)
gbase=# select hll_log2sparse(hll_empty(12, 8, -1));
hll_log2sparse
----------------
12
(1 row)

hll_duplicatecheck(hll)
描述:是否启用duplicatecheck,0 是关闭,1 是开启。默认关闭,对于有较多重复值出
现的情况,可以开启以提高效率。当显示指定duplicatecheck 为-1 时,会采用内置默认值。
示例:
gbase=# select hll_duplicatecheck(hll_empty());
hll_duplicatecheck
--------------------
0
(1 row)
gbase=# select hll_duplicatecheck(hll_empty(12, 8, 10, 1));
hll_duplicatecheck
--------------------
1
(1 row)
gbase=# select hll_duplicatecheck(hll_empty(12, 8, 10, -1));
hll_duplicatecheck
--------------------

GBase 8c SQL 参考手册
南大通用数据技术股份有限公司
302
0
(1 row)

事务
所有的 DDL 默认开始并自动提交一个事务。所有的 DML 默认开始一个事务,
且不会自动提交 //可以指定 DML 是否自动提交
stmt->setAutoCommit(TRUE/FALSE);
//也可以手动提交或回滚。 conn->commit(); conn->rollback();


此属性用来描述SQL 查询结果后的结果集行数量,
或者为UPDATE、
DELETE、
INSERT 后影响的数据行数。



GBase Python 接口开发手册
南大通用数据技术股份有限公司

- 25 -
类型

默认值
可读写
int
行数
-1
read