Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5afcca34
Commit
5afcca34
authored
Mar 31, 2014
by
antirez
Browse files
HyperLogLog API prefix modified from "P" to "PF".
Using both the initials of Philippe Flajolet instead of just "P".
parent
ba4e2083
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/hyperloglog.c
View file @
5afcca34
...
@@ -435,8 +435,8 @@ uint64_t hllCount(uint8_t *registers) {
...
@@ -435,8 +435,8 @@ uint64_t hllCount(uint8_t *registers) {
/* ========================== HyperLogLog commands ========================== */
/* ========================== HyperLogLog commands ========================== */
/* PADD var ele ele ele ... ele => :0 or :1 */
/* P
F
ADD var ele ele ele ... ele => :0 or :1 */
void
paddCommand
(
redisClient
*
c
)
{
void
p
f
addCommand
(
redisClient
*
c
)
{
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
robj
*
o
=
lookupKeyWrite
(
c
->
db
,
c
->
argv
[
1
]);
uint8_t
*
registers
;
uint8_t
*
registers
;
int
updated
=
0
,
j
;
int
updated
=
0
,
j
;
...
@@ -482,8 +482,8 @@ void paddCommand(redisClient *c) {
...
@@ -482,8 +482,8 @@ void paddCommand(redisClient *c) {
addReply
(
c
,
updated
?
shared
.
cone
:
shared
.
czero
);
addReply
(
c
,
updated
?
shared
.
cone
:
shared
.
czero
);
}
}
/* PCOUNT var -> approximated cardinality of set. */
/* P
F
COUNT var -> approximated cardinality of set. */
void
pcountCommand
(
redisClient
*
c
)
{
void
p
f
countCommand
(
redisClient
*
c
)
{
robj
*
o
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
1
]);
robj
*
o
=
lookupKeyRead
(
c
->
db
,
c
->
argv
[
1
]);
uint8_t
*
registers
;
uint8_t
*
registers
;
uint64_t
card
;
uint64_t
card
;
...
@@ -540,8 +540,8 @@ void pcountCommand(redisClient *c) {
...
@@ -540,8 +540,8 @@ void pcountCommand(redisClient *c) {
}
}
}
}
/* PMERGE dest src1 src2 src3 ... srcN => OK */
/* P
F
MERGE dest src1 src2 src3 ... srcN => OK */
void
pmergeCommand
(
redisClient
*
c
)
{
void
p
f
mergeCommand
(
redisClient
*
c
)
{
uint8_t
max
[
REDIS_HLL_REGISTERS
];
uint8_t
max
[
REDIS_HLL_REGISTERS
];
uint8_t
*
registers
;
uint8_t
*
registers
;
int
j
,
i
;
int
j
,
i
;
...
@@ -614,7 +614,7 @@ void pmergeCommand(redisClient *c) {
...
@@ -614,7 +614,7 @@ void pmergeCommand(redisClient *c) {
* the correct value to be retained and not affect adjacent values. */
* the correct value to be retained and not affect adjacent values. */
#define REDIS_HLL_TEST_CYCLES 1000
#define REDIS_HLL_TEST_CYCLES 1000
void
pselftestCommand
(
redisClient
*
c
)
{
void
p
f
selftestCommand
(
redisClient
*
c
)
{
int
j
,
i
;
int
j
,
i
;
sds
bitcounters
=
sdsnewlen
(
NULL
,
REDIS_HLL_SIZE
);
sds
bitcounters
=
sdsnewlen
(
NULL
,
REDIS_HLL_SIZE
);
uint8_t
bytecounters
[
REDIS_HLL_REGISTERS
];
uint8_t
bytecounters
[
REDIS_HLL_REGISTERS
];
...
...
src/redis.c
View file @
5afcca34
...
@@ -268,10 +268,10 @@ struct redisCommand redisCommandTable[] = {
...
@@ -268,10 +268,10 @@ struct redisCommand redisCommandTable[] = {
{
"bitcount"
,
bitcountCommand
,
-
2
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"bitcount"
,
bitcountCommand
,
-
2
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"bitpos"
,
bitposCommand
,
-
3
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"bitpos"
,
bitposCommand
,
-
3
,
"r"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"wait"
,
waitCommand
,
3
,
"rs"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"wait"
,
waitCommand
,
3
,
"rs"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"pselftest"
,
pselftestCommand
,
1
,
"r"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"p
f
selftest"
,
p
f
selftestCommand
,
1
,
"r"
,
0
,
NULL
,
0
,
0
,
0
,
0
,
0
},
{
"padd"
,
paddCommand
,
-
2
,
"wm"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"p
f
add"
,
p
f
addCommand
,
-
2
,
"wm"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"pcount"
,
pcountCommand
,
2
,
"w"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"p
f
count"
,
p
f
countCommand
,
2
,
"w"
,
0
,
NULL
,
1
,
1
,
1
,
0
,
0
},
{
"pmerge"
,
pmergeCommand
,
-
2
,
"wm"
,
0
,
NULL
,
1
,
-
1
,
1
,
0
,
0
}
{
"p
f
merge"
,
p
f
mergeCommand
,
-
2
,
"wm"
,
0
,
NULL
,
1
,
-
1
,
1
,
0
,
0
}
};
};
struct
evictionPoolEntry
*
evictionPoolAlloc
(
void
);
struct
evictionPoolEntry
*
evictionPoolAlloc
(
void
);
...
...
src/redis.h
View file @
5afcca34
...
@@ -1448,10 +1448,10 @@ void bitcountCommand(redisClient *c);
...
@@ -1448,10 +1448,10 @@ void bitcountCommand(redisClient *c);
void
bitposCommand
(
redisClient
*
c
);
void
bitposCommand
(
redisClient
*
c
);
void
replconfCommand
(
redisClient
*
c
);
void
replconfCommand
(
redisClient
*
c
);
void
waitCommand
(
redisClient
*
c
);
void
waitCommand
(
redisClient
*
c
);
void
pselftestCommand
(
redisClient
*
c
);
void
p
f
selftestCommand
(
redisClient
*
c
);
void
paddCommand
(
redisClient
*
c
);
void
p
f
addCommand
(
redisClient
*
c
);
void
pcountCommand
(
redisClient
*
c
);
void
p
f
countCommand
(
redisClient
*
c
);
void
pmergeCommand
(
redisClient
*
c
);
void
p
f
mergeCommand
(
redisClient
*
c
);
#if defined(__GNUC__)
#if defined(__GNUC__)
void
*
calloc
(
size_t
count
,
size_t
size
)
__attribute__
((
deprecated
));
void
*
calloc
(
size_t
count
,
size_t
size
)
__attribute__
((
deprecated
));
...
...
utils/hyperloglog/hll-err.rb
View file @
5afcca34
...
@@ -18,9 +18,9 @@ while true do
...
@@ -18,9 +18,9 @@ while true do
elements
<<
ele
elements
<<
ele
i
+=
1
i
+=
1
}
}
r
.
padd
(
'hll'
,
*
elements
)
r
.
p
f
add
(
'hll'
,
*
elements
)
}
}
approx
=
r
.
pcount
(
'hll'
)
approx
=
r
.
p
f
count
(
'hll'
)
abs_err
=
(
approx
-
i
).
abs
abs_err
=
(
approx
-
i
).
abs
rel_err
=
100
.
to_f
*
abs_err
/
i
rel_err
=
100
.
to_f
*
abs_err
/
i
puts
"
#{
i
}
vs
#{
approx
}
:
#{
rel_err
}
%"
puts
"
#{
i
}
vs
#{
approx
}
:
#{
rel_err
}
%"
...
...
utils/hyperloglog/hll-gnuplot-graph.rb
View file @
5afcca34
...
@@ -30,9 +30,9 @@ def run_experiment(r,seed,max,step)
...
@@ -30,9 +30,9 @@ def run_experiment(r,seed,max,step)
elements
<<
ele
elements
<<
ele
i
+=
1
i
+=
1
}
}
r
.
padd
(
'hll'
,
*
elements
)
r
.
p
f
add
(
'hll'
,
*
elements
)
}
}
approx
=
r
.
pcount
(
'hll'
)
approx
=
r
.
p
f
count
(
'hll'
)
err
=
approx
-
i
err
=
approx
-
i
rel_err
=
100
.
to_f
*
err
/
i
rel_err
=
100
.
to_f
*
err
/
i
samples
<<
[
i
,
rel_err
]
samples
<<
[
i
,
rel_err
]
...
...
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