mirror of
https://github.com/fluencelabs/redis
synced 2025-06-24 22:41:32 +00:00
Lazyfree: Sorted sets convereted to plain SDS. (several commits squashed)
This commit is contained in:
20
src/geo.c
20
src/geo.c
@ -112,7 +112,7 @@ int extractLongLatOrReply(client *c, robj **argv,
|
||||
int longLatFromMember(robj *zobj, robj *member, double *xy) {
|
||||
double score = 0;
|
||||
|
||||
if (zsetScore(zobj, member, &score) == C_ERR) return C_ERR;
|
||||
if (zsetScore(zobj, member->ptr, &score) == C_ERR) return C_ERR;
|
||||
if (!decodeGeohash(score, xy)) return C_ERR;
|
||||
return C_OK;
|
||||
}
|
||||
@ -261,16 +261,14 @@ int geoGetPointsInRange(robj *zobj, double min, double max, double lon, double l
|
||||
}
|
||||
|
||||
while (ln) {
|
||||
robj *o = ln->obj;
|
||||
sds ele = ln->ele;
|
||||
/* Abort when the node is no longer in range. */
|
||||
if (!zslValueLteMax(ln->score, &range))
|
||||
break;
|
||||
|
||||
member = (o->encoding == OBJ_ENCODING_INT) ?
|
||||
sdsfromlonglong((long)o->ptr) :
|
||||
sdsdup(o->ptr);
|
||||
if (geoAppendIfWithinRadius(ga,lon,lat,radius,ln->score,member)
|
||||
== C_ERR) sdsfree(member);
|
||||
ele = sdsdup(ele);
|
||||
if (geoAppendIfWithinRadius(ga,lon,lat,radius,ln->score,ele)
|
||||
== C_ERR) sdsfree(ele);
|
||||
ln = ln->level[0].forward;
|
||||
}
|
||||
}
|
||||
@ -606,7 +604,7 @@ void geohashCommand(client *c) {
|
||||
addReplyMultiBulkLen(c,c->argc-2);
|
||||
for (j = 2; j < c->argc; j++) {
|
||||
double score;
|
||||
if (zsetScore(zobj, c->argv[j], &score) == C_ERR) {
|
||||
if (zsetScore(zobj, c->argv[j]->ptr, &score) == C_ERR) {
|
||||
addReply(c,shared.nullbulk);
|
||||
} else {
|
||||
/* The internal format we use for geocoding is a bit different
|
||||
@ -660,7 +658,7 @@ void geoposCommand(client *c) {
|
||||
addReplyMultiBulkLen(c,c->argc-2);
|
||||
for (j = 2; j < c->argc; j++) {
|
||||
double score;
|
||||
if (zsetScore(zobj, c->argv[j], &score) == C_ERR) {
|
||||
if (zsetScore(zobj, c->argv[j]->ptr, &score) == C_ERR) {
|
||||
addReply(c,shared.nullmultibulk);
|
||||
} else {
|
||||
/* Decode... */
|
||||
@ -700,8 +698,8 @@ void geodistCommand(client *c) {
|
||||
|
||||
/* Get the scores. We need both otherwise NULL is returned. */
|
||||
double score1, score2, xyxy[4];
|
||||
if (zsetScore(zobj, c->argv[2], &score1) == C_ERR ||
|
||||
zsetScore(zobj, c->argv[3], &score2) == C_ERR)
|
||||
if (zsetScore(zobj, c->argv[2]->ptr, &score1) == C_ERR ||
|
||||
zsetScore(zobj, c->argv[3]->ptr, &score2) == C_ERR)
|
||||
{
|
||||
addReply(c,shared.nullbulk);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user