You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by ti...@apache.org on 2022/09/11 03:43:02 UTC
[incubator-kvrocks] branch unstable updated: fix: georadius should return empty set if the key does not exist (#845)
This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new fa01b03 fix: georadius should return empty set if the key does not exist (#845)
fa01b03 is described below
commit fa01b036f2f61ec98f4c7bbec57f96db7009eba6
Author: ColinChamber <95...@users.noreply.github.com>
AuthorDate: Sun Sep 11 11:42:57 2022 +0800
fix: georadius should return empty set if the key does not exist (#845)
---
src/redis_geo.cc | 2 +-
tests/tcl/tests/unit/geo.tcl | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/redis_geo.cc b/src/redis_geo.cc
index 7a460c8..ecffbd1 100644
--- a/src/redis_geo.cc
+++ b/src/redis_geo.cc
@@ -97,7 +97,7 @@ rocksdb::Status Geo::Radius(const Slice &user_key,
AppendNamespacePrefix(user_key, &ns_key);
ZSetMetadata metadata(false);
rocksdb::Status s = ZSet::GetMetadata(ns_key, &metadata);
- if (!s.ok()) return s;
+ if (!s.ok()) return s.IsNotFound() ? rocksdb::Status::OK() : s;
/* Get all neighbor geohash boxes for our radius search */
GeoHashRadius georadius = GeoHashHelper::GetAreasByRadiusWGS84(longitude, latitude, radius_meters);
diff --git a/tests/tcl/tests/unit/geo.tcl b/tests/tcl/tests/unit/geo.tcl
index 8f0dde1..3eedc0d 100644
--- a/tests/tcl/tests/unit/geo.tcl
+++ b/tests/tcl/tests/unit/geo.tcl
@@ -319,6 +319,11 @@ start_server {tags {"geo"}} {
set e
} {*syntax*}
+ test {GEORADIUS missing key} {
+ r del points
+ assert_equal {} [r georadius points 13.361389 38.115556 50 km]
+ }
+
# test {GEOSEARCHSTORE STORE option: syntax error} {
# catch {r geosearchstore abc points fromlonlat 13.361389 38.115556 byradius 50 km store abc} e
# set e