Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
0b9f09c4
Commit
0b9f09c4
authored
Apr 12, 2014
by
antirez
Browse files
Increment pointer while iterating sparse HLL object.
parent
e526d326
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/hyperloglog.c
View file @
0b9f09c4
...
@@ -581,9 +581,11 @@ sds hllSparseToDense(sds sparse) {
...
@@ -581,9 +581,11 @@ sds hllSparseToDense(sds sparse) {
if
(
HLL_SPARSE_IS_ZERO
(
p
))
{
if
(
HLL_SPARSE_IS_ZERO
(
p
))
{
runlen
=
HLL_SPARSE_ZERO_LEN
(
p
);
runlen
=
HLL_SPARSE_ZERO_LEN
(
p
);
idx
+=
runlen
;
idx
+=
runlen
;
p
++
;
}
else
if
(
HLL_SPARSE_IS_XZERO
(
p
))
{
}
else
if
(
HLL_SPARSE_IS_XZERO
(
p
))
{
runlen
=
HLL_SPARSE_XZERO_LEN
(
p
);
runlen
=
HLL_SPARSE_XZERO_LEN
(
p
);
idx
+=
runlen
;
idx
+=
runlen
;
p
+=
2
;
}
else
{
}
else
{
runlen
=
HLL_SPARSE_VAL_LEN
(
p
);
runlen
=
HLL_SPARSE_VAL_LEN
(
p
);
regval
=
HLL_SPARSE_VAL_VALUE
(
p
);
regval
=
HLL_SPARSE_VAL_VALUE
(
p
);
...
@@ -591,6 +593,7 @@ sds hllSparseToDense(sds sparse) {
...
@@ -591,6 +593,7 @@ sds hllSparseToDense(sds sparse) {
HLL_DENSE_SET_REGISTER
(
hdr
->
registers
,
idx
,
regval
);
HLL_DENSE_SET_REGISTER
(
hdr
->
registers
,
idx
,
regval
);
idx
++
;
idx
++
;
}
}
p
++
;
}
}
}
}
...
@@ -821,16 +824,19 @@ double hllSparseSum(uint8_t *sparse, int sparselen, double *PE, int *ezp) {
...
@@ -821,16 +824,19 @@ double hllSparseSum(uint8_t *sparse, int sparselen, double *PE, int *ezp) {
idx
+=
runlen
;
idx
+=
runlen
;
ez
+=
runlen
;
ez
+=
runlen
;
E
+=
1
;
/* 2^(-reg[j]) is 1 when m is 0. */
E
+=
1
;
/* 2^(-reg[j]) is 1 when m is 0. */
p
++
;
}
else
if
(
HLL_SPARSE_IS_XZERO
(
p
))
{
}
else
if
(
HLL_SPARSE_IS_XZERO
(
p
))
{
runlen
=
HLL_SPARSE_XZERO_LEN
(
p
);
runlen
=
HLL_SPARSE_XZERO_LEN
(
p
);
idx
+=
runlen
;
idx
+=
runlen
;
ez
+=
runlen
;
ez
+=
runlen
;
E
+=
1
;
/* 2^(-reg[j]) is 1 when m is 0. */
E
+=
1
;
/* 2^(-reg[j]) is 1 when m is 0. */
p
+=
2
;
}
else
{
}
else
{
runlen
=
HLL_SPARSE_VAL_LEN
(
p
);
runlen
=
HLL_SPARSE_VAL_LEN
(
p
);
regval
=
HLL_SPARSE_VAL_VALUE
(
p
);
regval
=
HLL_SPARSE_VAL_VALUE
(
p
);
idx
+=
runlen
;
idx
+=
runlen
;
E
+=
PE
[
regval
]
*
runlen
;
E
+=
PE
[
regval
]
*
runlen
;
p
++
;
}
}
}
}
redisAssert
(
idx
==
HLL_REGISTERS
);
redisAssert
(
idx
==
HLL_REGISTERS
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment