• antirez's avatar
    GEORADIUS: Don't report duplicates when radius is huge. · 3c23b5ff
    antirez authored
    Georadius works by computing the center + neighbors squares covering all
    the area of the specified position and radius. Then a distance filter is
    used to remove elements which are actually outside the range.
    
    When a huge radius is used, like 5000 km or more, adjacent neighbors may
    collide and be the same, leading to the reporting of the same element
    multiple times. This only happens in the edge case of huge radius but is
    not ideal.
    
    A robust but slow solution would involve qsorting the range to remove
    all the duplicates. However since the collisions are only in adjacent
    boxes, for the way they are ordered in the code, it is much faster to
    just check if the current box is the same as the previous one processed.
    
    This commit adds a regression test for the bug.
    
    Fixes #2767.
    3c23b5ff
geo.c 25.7 KB