MCPcopy Create free account
hub / github.com/F-Stack/f-stack / hllSparseRegHisto

Function hllSparseRegHisto

app/redis-6.2.6/src/hyperloglog.c:911–935  ·  view source on GitHub ↗

Compute the register histogram in the sparse representation. */

Source from the content-addressed store, hash-verified

909
910/* Compute the register histogram in the sparse representation. */
911void hllSparseRegHisto(uint8_t *sparse, int sparselen, int *invalid, int* reghisto) {
912 int idx = 0, runlen, regval;
913 uint8_t *end = sparse+sparselen, *p = sparse;
914
915 while(p < end) {
916 if (HLL_SPARSE_IS_ZERO(p)) {
917 runlen = HLL_SPARSE_ZERO_LEN(p);
918 idx += runlen;
919 reghisto[0] += runlen;
920 p++;
921 } else if (HLL_SPARSE_IS_XZERO(p)) {
922 runlen = HLL_SPARSE_XZERO_LEN(p);
923 idx += runlen;
924 reghisto[0] += runlen;
925 p += 2;
926 } else {
927 runlen = HLL_SPARSE_VAL_LEN(p);
928 regval = HLL_SPARSE_VAL_VALUE(p);
929 idx += runlen;
930 reghisto[regval] += runlen;
931 p++;
932 }
933 }
934 if (idx != HLL_REGISTERS && invalid) *invalid = 1;
935}
936
937/* ========================= HyperLogLog Count ==============================
938 * This is the core of the algorithm where the approximated count is computed.

Callers 1

hllCountFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected