MCPcopy Create free account
hub / github.com/Vanzaseses/hmdp / loadShopData

Method loadShopData

NoteFromVisit/src/test/java/com/sengang/test.java:75–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73 }
74
75 @Test
76 public void loadShopData(){
77 List<Shop> list = shopService.list();
78 //店铺分组,typeId为key,shopId为value,坐标为score
79 Map<Long, List<Shop>> map = list.stream().collect(Collectors.groupingBy(Shop::getTypeId));
80 for (Map.Entry<Long, List<Shop>> entry : map.entrySet()) {
81 //相同店铺类型的店铺列表
82 List<Shop> values = entry.getValue();
83 Long typeId = entry.getKey();
84 String key = RedisConstants.SHOP_GEO_KEY+typeId;
85 List<RedisGeoCommands.GeoLocation<String>> locations = new ArrayList<>(values.size());
86
87 //遍历店铺,每个店铺存入redis
88 for (Shop value : values) {
89 Long id = value.getId();
90// stringRedisTemplate.opsForGeo().add(key.toString(),new Point(value.getX(),value.getY()),value.getId().toString());
91 locations.add(new RedisGeoCommands.GeoLocation<>(value.getId().toString(),new Point(value.getX(),value.getY())));
92 }
93 //存入redis
94 stringRedisTemplate.opsForGeo().add(key,locations);
95 }
96 }
97 @Test
98 public void testHyperLoglog(){
99 String[] values = new String[1000];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected