Log Functions
There are three HLL modes: explicit, sparse, and full. When the data size is small, the explicit mode is used. In this mode, distinct values are calculated without errors. As the number of distinct values increases, the HLL mode is switched to the sparse and full modes in sequence. The two modes have no difference in the calculation result, but vary in the calculation efficiency of HLL functions and the storage space of HLL objects. The following functions can be used to view some HLL parameters:
hll_print(hll)
Description: Prints some debugging parameters of an HLL.
Example:
1 2 3 4 5 |
gaussdb=# SELECT hll_print(hll_empty()); hll_print ------------------------------------------------------------------------------- type=1(HLL_EMPTY), log2m=14, log2explicit=10, log2sparse=12, duplicatecheck=0 (1 row) |
hll_type(hll)
Description: Checks the type of the current HLL. The return values are described as follows: 0 indicates HLL_UNINIT, an HLL object that is not initialized. 1 indicates HLL_EMPTY, an empty HLL object. 2 indicates HLL_EXPLICIT, an HLL object in explicit mode. 3 indicates HLL_SPARSE, an HLL object in sparse mode. 4 indicates HLL_FULL, an HLL object in full mode. 5 indicates HLL_UNDEFINED, an invalid HLL object.
Example:
1 2 3 4 5 |
gaussdb=# SELECT hll_type(hll_empty()); hll_type ---------- 1 (1 row) |
hll_log2m(hll)
Description: Checks the value of log2m in the current HLL data structure. log2m is the logarithm of the number of buckets. This value affects the error rate of calculating distinct values by HLL. The error rate = ±1.04/√(2^log2m). When the value of log2m is explicitly set to a value from 10 to 16, HLL sets the number of buckets to 2log2m. When the value of log2explicit is explicitly set to –1, the built-in default value is used.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
gaussdb=# SELECT hll_log2m(hll_empty()); hll_log2m ----------- 14 (1 row) gaussdb=# SELECT hll_log2m(hll_empty(10)); hll_log2m ----------- 10 (1 row) gaussdb=# SELECT hll_log2m(hll_empty(-1)); hll_log2m ----------- 14 (1 row) |
hll_log2explicit(hll)
Description: Queries the value of log2explicit in the current HLL data structure. Generally, the HLL changes from the explicit mode to the sparse mode and then to the full mode. This process is called the promotion hierarchy policy. You can change the value of log2explicit to change the policy. For example, if the value of log2explicit is 0, the explicit mode will be skipped and the sparse mode is directly entered. When the value of log2explicit is explicitly set to a value ranging from 1 to 12, the HLL will switch to the sparse mode when the length of the data segment exceeds 2log2explicit. When the value of log2explicit is explicitly set to –1, the built-in default value is used.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
gaussdb=# SELECT hll_log2explicit(hll_empty()); hll_log2explicit ------------------ 10 (1 row) gaussdb=# SELECT hll_log2explicit(hll_empty(12, 8)); hll_log2explicit ------------------ 8 (1 row) gaussdb=# SELECT hll_log2explicit(hll_empty(12, -1)); hll_log2explicit ------------------ 10 (1 row) |
hll_log2sparse(hll)
Description: Queries the value of log2sparse in the current HLL data structure. Generally, the HLL changes from the explicit mode to the sparse mode and then to the full mode. This process is called the promotion hierarchy policy. You can adjust the value of log2sparse to change the policy. For example, if the value of log2sparse is 0, the system skips the sparse mode and directly enters the full mode. If the value of log2sparse is explicitly set to a value ranging from 1 to 14, the HLL will switch to the full mode when the length of the data segment exceeds 2log2sparse. When the value of log2sparse is explicitly set to –1, the built-in default value is used.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
gaussdb=# SELECT hll_log2sparse(hll_empty()); hll_log2sparse ---------------- 12 (1 row) gaussdb=# SELECT hll_log2sparse(hll_empty(12, 8, 10)); hll_log2sparse ---------------- 10 (1 row) gaussdb=# SELECT hll_log2sparse(hll_empty(12, 8, -1)); hll_log2sparse ---------------- 12 (1 row) |
hll_duplicatecheck(hll)
Description: Specifies whether duplicate check is enabled. 0: disable; 1: enable. This function is disabled by default. If there are many duplicate values, you can enable this function to improve efficiency. When the value of duplicatecheck is explicitly set to –1, the built-in default value is used.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
gaussdb=# SELECT hll_duplicatecheck(hll_empty()); hll_duplicatecheck -------------------- 0 (1 row) gaussdb=# SELECT hll_duplicatecheck(hll_empty(12, 8, 10, 1)); hll_duplicatecheck -------------------- 1 (1 row) gaussdb=# SELECT hll_duplicatecheck(hll_empty(12, 8, 10, -1)); hll_duplicatecheck -------------------- 0 (1 row) |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot