1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
From 7413dc16572ffd672835c1391b08409472771093 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Fri, 16 Mar 2018 16:57:53 +0100
Subject: [PATCH] Aesthetic changes to PR #4749.
---
src/hyperloglog.c | 80 +++++++++++++++++++++++------------------------
1 file changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 77109c8..68d591c 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -403,7 +403,7 @@ uint64_t MurmurHash64A (const void * key, int len, unsigned int seed) {
#if (BYTE_ORDER == LITTLE_ENDIAN)
#ifdef USE_ALIGNED_ACCESS
- memcpy(&k,data,sizeof(uint64_t));
+ memcpy(&k,data,sizeof(uint64_t));
#else
k = *((uint64_t*)data);
#endif
@@ -512,7 +512,7 @@ int hllDenseAdd(uint8_t *registers, unsigned char *ele, size_t elesize) {
}
/* Compute the register histogram in the dense representation. */
-void hllDenseRegHisto(uint8_t *registers, int* regHisto) {
+void hllDenseRegHisto(uint8_t *registers, int* reghisto) {
int j;
/* Redis default is to use 16384 registers 6 bits each. The code works
@@ -541,22 +541,22 @@ void hllDenseRegHisto(uint8_t *registers, int* regHisto) {
r14 = (r[10] >> 4 | r[11] << 4) & 63;
r15 = (r[11] >> 2) & 63;
- regHisto[r0] += 1;
- regHisto[r1] += 1;
- regHisto[r2] += 1;
- regHisto[r3] += 1;
- regHisto[r4] += 1;
- regHisto[r5] += 1;
- regHisto[r6] += 1;
- regHisto[r7] += 1;
- regHisto[r8] += 1;
- regHisto[r9] += 1;
- regHisto[r10] += 1;
- regHisto[r11] += 1;
- regHisto[r12] += 1;
- regHisto[r13] += 1;
- regHisto[r14] += 1;
- regHisto[r15] += 1;
+ reghisto[r0]++;
+ reghisto[r1]++;
+ reghisto[r2]++;
+ reghisto[r3]++;
+ reghisto[r4]++;
+ reghisto[r5]++;
+ reghisto[r6]++;
+ reghisto[r7]++;
+ reghisto[r8]++;
+ reghisto[r9]++;
+ reghisto[r10]++;
+ reghisto[r11]++;
+ reghisto[r12]++;
+ reghisto[r13]++;
+ reghisto[r14]++;
+ reghisto[r15]++;
r += 12;
}
@@ -564,7 +564,7 @@ void hllDenseRegHisto(uint8_t *registers, int* regHisto) {
for(j = 0; j < HLL_REGISTERS; j++) {
unsigned long reg;
HLL_DENSE_GET_REGISTER(reg,registers,j);
- regHisto[reg] += 1;
+ reghisto[reg]++;
}
}
}
@@ -904,7 +904,7 @@ int hllSparseAdd(robj *o, unsigned char *ele, size_t elesize) {
}
/* Compute the register histogram in the sparse representation. */
-void hllSparseRegHisto(uint8_t *sparse, int sparselen, int *invalid, int* regHisto) {
+void hllSparseRegHisto(uint8_t *sparse, int sparselen, int *invalid, int* reghisto) {
int idx = 0, runlen, regval;
uint8_t *end = sparse+sparselen, *p = sparse;
@@ -912,18 +912,18 @@ void hllSparseRegHisto(uint8_t *sparse, int sparselen, int *invalid, int* regHis
if (HLL_SPARSE_IS_ZERO(p)) {
runlen = HLL_SPARSE_ZERO_LEN(p);
idx += runlen;
- regHisto[0] += runlen;
+ reghisto[0] += runlen;
p++;
} else if (HLL_SPARSE_IS_XZERO(p)) {
runlen = HLL_SPARSE_XZERO_LEN(p);
idx += runlen;
- regHisto[0] += runlen;
+ reghisto[0] += runlen;
p += 2;
} else {
runlen = HLL_SPARSE_VAL_LEN(p);
regval = HLL_SPARSE_VAL_VALUE(p);
idx += runlen;
- regHisto[regval] += runlen;
+ reghisto[regval] += runlen;
p++;
}
}
@@ -938,24 +938,24 @@ void hllSparseRegHisto(uint8_t *sparse, int sparselen, int *invalid, int* regHis
/* Implements the register histogram calculation for uint8_t data type
* which is only used internally as speedup for PFCOUNT with multiple keys. */
-void hllRawRegHisto(uint8_t *registers, int* regHisto) {
+void hllRawRegHisto(uint8_t *registers, int* reghisto) {
uint64_t *word = (uint64_t*) registers;
uint8_t *bytes;
int j;
for (j = 0; j < HLL_REGISTERS/8; j++) {
if (*word == 0) {
- regHisto[0] += 8;
+ reghisto[0] += 8;
} else {
bytes = (uint8_t*) word;
- regHisto[bytes[0]] += 1;
- regHisto[bytes[1]] += 1;
- regHisto[bytes[2]] += 1;
- regHisto[bytes[3]] += 1;
- regHisto[bytes[4]] += 1;
- regHisto[bytes[5]] += 1;
- regHisto[bytes[6]] += 1;
- regHisto[bytes[7]] += 1;
+ reghisto[bytes[0]]++;
+ reghisto[bytes[1]]++;
+ reghisto[bytes[2]]++;
+ reghisto[bytes[3]]++;
+ reghisto[bytes[4]]++;
+ reghisto[bytes[5]]++;
+ reghisto[bytes[6]]++;
+ reghisto[bytes[7]]++;
}
word++;
}
@@ -1011,16 +1011,16 @@ uint64_t hllCount(struct hllhdr *hdr, int *invalid) {
double E;
int j;
double alphaInf = 0.5 / log(2.);
- int regHisto[HLL_Q+2] = {0};
+ int reghisto[HLL_Q+2] = {0};
/* Compute register histogram */
if (hdr->encoding == HLL_DENSE) {
- hllDenseRegHisto(hdr->registers,regHisto);
+ hllDenseRegHisto(hdr->registers,reghisto);
} else if (hdr->encoding == HLL_SPARSE) {
hllSparseRegHisto(hdr->registers,
- sdslen((sds)hdr)-HLL_HDR_SIZE,invalid,regHisto);
+ sdslen((sds)hdr)-HLL_HDR_SIZE,invalid,reghisto);
} else if (hdr->encoding == HLL_RAW) {
- hllRawRegHisto(hdr->registers,regHisto);
+ hllRawRegHisto(hdr->registers,reghisto);
} else {
serverPanic("Unknown HyperLogLog encoding in hllCount()");
}
@@ -1028,12 +1028,12 @@ uint64_t hllCount(struct hllhdr *hdr, int *invalid) {
/* Estimate cardinality form register histogram. See:
* "New cardinality estimation algorithms for HyperLogLog sketches"
* Otmar Ertl, arXiv:1702.01284 */
- double z = m * hllTau((m-regHisto[HLL_Q+1])/(double)m);
+ double z = m * hllTau((m-reghisto[HLL_Q+1])/(double)m);
for (j = HLL_Q; j >= 1; --j) {
- z += regHisto[j];
+ z += reghisto[j];
z *= 0.5;
}
- z += m * hllSigma(regHisto[0]/(double)m);
+ z += m * hllSigma(reghisto[0]/(double)m);
E = llroundl(alphaInf*m*m/z);
return (uint64_t) E;
--
2.23.0
|