Pass Page.size() to GEORADIUS COUNT.

We now reuse the page size to initially limit Geo results within Redis.

Closes #1242
This commit is contained in:
Mark Paluch
2023-05-08 10:19:11 +02:00
parent a147385431
commit aadfae62a4
2 changed files with 33 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.data.keyvalue.core.SortAccessor;
import org.springframework.data.keyvalue.core.SpelSortAccessor;
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation;
import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs;
import org.springframework.data.redis.core.convert.GeoIndexedPropertyValue;
import org.springframework.data.redis.core.convert.RedisData;
import org.springframework.data.redis.repository.query.RedisOperationChain;
@@ -104,8 +105,14 @@ class RedisQueryEngine extends QueryEngine<RedisKeyValueAdapter, RedisOperationC
if (criteria.getNear() != null) {
GeoRadiusCommandArgs limit = GeoRadiusCommandArgs.newGeoRadiusArgs();
if (rows > 0) {
limit = limit.limit(rows);
}
GeoResults<GeoLocation<byte[]>> x = connection.geoRadius(geoKey(keyspace + ":", criteria.getNear()),
new Circle(criteria.getNear().getPoint(), criteria.getNear().getDistance()));
new Circle(criteria.getNear().getPoint(), criteria.getNear().getDistance()), limit);
for (GeoResult<GeoLocation<byte[]>> y : x) {
allKeys.add(y.getContent().getName());
}