redis.clients.jedis.GeoRadiusResponse Java Examples

The following examples show how to use redis.clients.jedis.GeoRadiusResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 7 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude,
    double radius, GeoUnit unit) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadius(key, longitude, latitude, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #2
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius,
    GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadiusByMember", key);
  span.setTag("member", member);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  try {
    return super.georadiusByMember(key, member, radius, unit, param);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #3
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius,
    GeoUnit unit) {
  Span span = helper.buildSpan("georadiusByMember", key);
  span.setTag("member", Arrays.toString(member));
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadiusByMember(key, member, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #4
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude,
    double radius, GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  try {
    return super.georadius(key, longitude, latitude, radius, unit, param);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #5
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(byte[] key, double longitude, double latitude,
    double radius, GeoUnit unit) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadius(key, longitude, latitude, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #6
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius,
    GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadiusByMember", key);
  span.setTag("member", Arrays.toString(member));
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  try {
    return super.georadiusByMember(key, member, radius, unit, param);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #7
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude,
    double radius, GeoUnit unit) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadius(key, longitude, latitude, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #8
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius,
    GeoUnit unit) {
  Span span = helper.buildSpan("georadiusByMember", key);
  span.setTag("member", member);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadiusByMember(key, member, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #9
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude,
    double radius, GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  try {
    return super.georadius(key, longitude, latitude, radius, unit, param);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #10
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude,
    double radius, GeoUnit unit) {
  Span span = helper.buildSpan("georadius", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadius(key, longitude, latitude, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #11
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius,
    GeoUnit unit) {
  Span span = helper.buildSpan("georadiusByMember", key);
  span.setTag("member", member);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadiusByMember(key, member, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #12
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 6 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(byte[] key, byte[] member, double radius,
    GeoUnit unit) {
  Span span = helper.buildSpan("georadiusByMember", key);
  span.setTag("member", Arrays.toString(member));
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  try {
    return super.georadiusByMember(key, member, radius, unit);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #13
Source File: GeoCommandsTest.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
@Test
public void georadiusByMemberBinary() {
  jedis.geoadd(bfoo, 13.583333, 37.316667, bA);
  jedis.geoadd(bfoo, 13.361389, 38.115556, bB);
  jedis.geoadd(bfoo, 15.087269, 37.502669, bC);

  List<GeoRadiusResponse> members = jedis.georadiusByMember(bfoo, bA, 100, GeoUnit.KM);
  assertEquals(2, members.size());

  members = jedis.georadiusByMember(bfoo, bA, 100, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending());
  assertEquals(2, members.size());
  assertArrayEquals(bA, members.get(0).getMember());
  assertArrayEquals(bB, members.get(1).getMember());

  members = jedis.georadiusByMember(bfoo, bA, 100, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending().count(1).withCoord().withDist());
  assertEquals(1, members.size());

  GeoRadiusResponse member = members.get(0);
  assertArrayEquals(bA, member.getMember());
  assertTrue(equalsWithinEpsilon(0, member.getDistance()));
  assertTrue(equalsWithinEpsilon(13.583333, member.getCoordinate().getLongitude()));
  assertTrue(equalsWithinEpsilon(37.316667, member.getCoordinate().getLatitude()));
}
 
Example #14
Source File: GeoCommandsTest.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
@Test
public void georadiusByMember() {
  jedis.geoadd("Sicily", 13.583333, 37.316667, "Agrigento");
  jedis.geoadd("Sicily", 13.361389, 38.115556, "Palermo");
  jedis.geoadd("Sicily", 15.087269, 37.502669, "Catania");

  List<GeoRadiusResponse> members = jedis.georadiusByMember("Sicily", "Agrigento", 100,
    GeoUnit.KM);
  assertEquals(2, members.size());

  members = jedis.georadiusByMember("Sicily", "Agrigento", 100, GeoUnit.KM, GeoRadiusParam
      .geoRadiusParam().sortAscending());
  assertEquals(2, members.size());
  assertEquals("Agrigento", members.get(0).getMemberByString());
  assertEquals("Palermo", members.get(1).getMemberByString());

  members = jedis.georadiusByMember("Sicily", "Agrigento", 100, GeoUnit.KM, GeoRadiusParam
      .geoRadiusParam().sortAscending().count(1).withCoord().withDist());
  assertEquals(1, members.size());

  GeoRadiusResponse member = members.get(0);
  assertEquals("Agrigento", member.getMemberByString());
  assertTrue(equalsWithinEpsilon(0, member.getDistance()));
  assertTrue(equalsWithinEpsilon(13.583333, member.getCoordinate().getLongitude()));
  assertTrue(equalsWithinEpsilon(37.316667, member.getCoordinate().getLatitude()));
}
 
Example #15
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude,
    double radius, GeoUnit unit) {
  Span span = helper.buildSpan("georadiusReadonly", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  return helper
      .decorate(span, () -> super.georadiusReadonly(key, longitude, latitude, radius, unit));
}
 
Example #16
Source File: EnhancedJedisCluster.java    From super-cloudops with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(final String key, final double longitude, final double latitude, final double radius,
		final GeoUnit unit) {
	checkArgumentsSpecification(key);
	return new EnhancedJedisClusterCommand<List<GeoRadiusResponse>>(connectionHandler, maxAttempts) {
		@Override
		public List<GeoRadiusResponse> doExecute(Jedis connection) {
			return connection.georadius(key, longitude, latitude, radius, unit);
		}
	}.run(key);
}
 
Example #17
Source File: GeoCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
public void georadiusBinary() {
  // prepare datas
  Map<byte[], GeoCoordinate> bcoordinateMap = new HashMap<byte[], GeoCoordinate>();
  bcoordinateMap.put(bA, new GeoCoordinate(13.361389, 38.115556));
  bcoordinateMap.put(bB, new GeoCoordinate(15.087269, 37.502669));
  jedis.geoadd(bfoo, bcoordinateMap);

  List<GeoRadiusResponse> members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM);
  assertEquals(2, members.size());

  // sort
  members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending());
  assertEquals(2, members.size());
  assertArrayEquals(bB, members.get(0).getMember());
  assertArrayEquals(bA, members.get(1).getMember());

  // sort, count 1
  members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending().count(1));
  assertEquals(1, members.size());

  // sort, count 1, withdist, withcoord
  members = jedis.georadius(bfoo, 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending().count(1).withCoord().withDist());
  assertEquals(1, members.size());
  GeoRadiusResponse response = members.get(0);
  assertTrue(equalsWithinEpsilon(56.4413, response.getDistance()));
  assertTrue(equalsWithinEpsilon(15.087269, response.getCoordinate().getLongitude()));
  assertTrue(equalsWithinEpsilon(37.502669, response.getCoordinate().getLatitude()));
}
 
Example #18
Source File: GeoCommandsTest.java    From cachecloud with Apache License 2.0 5 votes vote down vote up
@Test
public void georadius() {
  // prepare datas
  Map<String, GeoCoordinate> coordinateMap = new HashMap<String, GeoCoordinate>();
  coordinateMap.put("Palermo", new GeoCoordinate(13.361389, 38.115556));
  coordinateMap.put("Catania", new GeoCoordinate(15.087269, 37.502669));
  jedis.geoadd("Sicily", coordinateMap);

  List<GeoRadiusResponse> members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM);
  assertEquals(2, members.size());

  // sort
  members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending());
  assertEquals(2, members.size());
  assertEquals("Catania", members.get(0).getMemberByString());
  assertEquals("Palermo", members.get(1).getMemberByString());

  // sort, count 1
  members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending().count(1));
  assertEquals(1, members.size());

  // sort, count 1, withdist, withcoord
  members = jedis.georadius("Sicily", 15, 37, 200, GeoUnit.KM, GeoRadiusParam.geoRadiusParam()
      .sortAscending().count(1).withCoord().withDist());
  assertEquals(1, members.size());
  GeoRadiusResponse response = members.get(0);
  assertTrue(equalsWithinEpsilon(56.4413, response.getDistance()));
  assertTrue(equalsWithinEpsilon(15.087269, response.getCoordinate().getLongitude()));
  assertTrue(equalsWithinEpsilon(37.502669, response.getCoordinate().getLatitude()));
}
 
Example #19
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius,
    GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadiusByMemberReadonly", key);
  span.setTag("member", Arrays.toString(member));
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  return helper
      .decorate(span, () -> super.georadiusByMemberReadonly(key, member, radius, unit, param));
}
 
Example #20
Source File: JedisSentinel.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius, GeoUnit unit,
                                                         GeoRadiusParam param) {
    try (Jedis jedis = jedisPool.getResource()) {
        return jedis.georadiusByMemberReadonly(key, member, radius, unit, param);
    }
}
 
Example #21
Source File: JedisSentinel.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMember(String key, String member, double radius, GeoUnit unit,
                                                 GeoRadiusParam param) {
    try (Jedis jedis = jedisPool.getResource()) {
        return jedis.georadiusByMember(key, member, radius, unit, param);
    }
}
 
Example #22
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius,
    GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadiusByMemberReadonly", key);
  span.setTag("member", member);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  return helper
      .decorate(span, () -> super.georadiusByMemberReadonly(key, member, radius, unit, param));
}
 
Example #23
Source File: JedisSentinel.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude, double radius,
                                                 GeoUnit unit, GeoRadiusParam param) {
    try (Jedis jedis = jedisPool.getResource()) {
        return jedis.georadiusReadonly(key, longitude, latitude, radius, unit, param);
    }
}
 
Example #24
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude,
    double radius, GeoUnit unit, GeoRadiusParam param) {
  Span span = helper.buildSpan("georadiusReadonly", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  span.setTag("param", TracingHelper.toString(param.getByteParams()));
  return helper
      .decorate(span,
          () -> super.georadiusReadonly(key, longitude, latitude, radius, unit, param));
}
 
Example #25
Source File: JedisSentinel.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius, GeoUnit unit,
                                         GeoRadiusParam param) {
    try (Jedis jedis = jedisPool.getResource()) {
        return jedis.georadius(key, longitude, latitude, radius, unit, param);
    }
}
 
Example #26
Source File: JedisSentinel.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusReadonly(String key, double longitude, double latitude, double radius,
                                                 GeoUnit unit) {
    try (Jedis jedis = jedisPool.getResource()) {
        return jedis.georadiusReadonly(key, longitude, latitude, radius, unit);
    }
}
 
Example #27
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMemberReadonly(String key, String member, double radius,
    GeoUnit unit) {
  Span span = helper.buildSpan("georadiusByMemberReadonly", key);
  span.setTag("member", member);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  return helper
      .decorate(span, () -> super.georadiusByMemberReadonly(key, member, radius, unit));
}
 
Example #28
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, double radius,
    GeoUnit unit) {
  Span span = helper.buildSpan("georadiusByMemberReadonly", key);
  span.setTag("member", Arrays.toString(member));
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  return helper
      .decorate(span, () -> super.georadiusByMemberReadonly(key, member, radius, unit));
}
 
Example #29
Source File: JedisSentinel.java    From conductor with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadius(String key, double longitude, double latitude, double radius,
                                         GeoUnit unit) {
    try (Jedis jedis = jedisPool.getResource()) {
        return jedis.georadius(key, longitude, latitude, radius, unit);
    }
}
 
Example #30
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public List<GeoRadiusResponse> georadiusReadonly(byte[] key, double longitude, double latitude,
    double radius, GeoUnit unit) {
  Span span = helper.buildSpan("georadiusReadonly", key);
  span.setTag("longitude", longitude);
  span.setTag("latitude", latitude);
  span.setTag("radius", radius);
  span.setTag("unit", unit.name());
  return helper
      .decorate(span, () -> super.georadiusReadonly(key, longitude, latitude, radius, unit));
}