https://github.com/redis/redis/blob/2495b90a647f9f9987202efd29647f81f217b8ad/src/geo.c#L891C22-L891C31
void geohashCommand(client *c) {
char *geoalphabet= "0123456789bcdefghjkmnpqrstuvwxyz";
int j;
/* Look up the requested zset */
robj *zobj = lookupKeyRead(c->db, c->argv[1]);
if (checkType(c, zobj, OBJ_ZSET)) return;
/* Geohash elements one after the other, using a null bulk reply for
* missing elements. */
addReplyArrayLen(c,c->argc-2);
for (j = 2; j < c->argc; j++) {
double score;
if (!zobj || zsetScore(zobj, c->argv[j]->ptr, &score) == C_ERR) {
addReplyNull(c);
}
// ...
}
}
You can see that the geohash command uses zsetScore to query the score, and the internal is a hashtable query. Why does the document(refer: https://redis.io/commands/geohash) say "Time complexity: O(log(N)) for each member requested, where N is the number of elements in the sorted set."
Comment From: enjoy-binbin
yean, zsetScore is using the hashtable, that would be O(1). do you want to raise a PR to fix it or should i take care of it?
Comment From: forthcoming
please help me change it thank you
Comment From: clark-lt
@forthcoming @enjoy-binbin sorted set uses skiplist as main datastructure. Redis Just uses hashtable just to control main key of sorted set (not its data). so O(Log(N)) is correct.
Comment From: forthcoming
@clark-lt https://github.com/redis/redis/blob/unstable/src/t_zset.c#L1310 I still believe in my point of view
Comment From: clark-lt
@forthcoming Oh, I'm sorry. I missed it uses hashtable for zsetScore. You're right. I'm sorry to make confusion.
Comment From: enjoy-binbin
in src/commands, there is a json file with commands in it, just modify it.
and there is a commands.def file, please also search it and modify it too. (or run python utils\generate-command-code.py to re-generate the commands.def)
Comment From: oranagra
i was looking to understand why this error happened, and assumed it might be a copy paste issue. however, looking at the similar GEOPOS, i see it should also be changed, so: 1. let's update it too. 2. i'd like to try to find the history behind this error and make sure we're not just missing something. @itamarhaber FYI.
Comment From: enjoy-binbin
i see GEOPOS complexity is: O(N) where N is the number of members requested. do you mean GEODIST?
Comment From: oranagra
you're right. don't know what i was looking at yesterday.