Skip to content

Commit becd718

Browse files
committed
HyperLogLogTests
1 parent f8b76c0 commit becd718

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

java-redis/src/test/java/org/cp/javaredis/HyperLogLogTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,26 @@ public void compareTest() {
4242
System.out.println("set count: " + set.size());
4343
}
4444

45+
@Test
46+
public void mergeTest() {
47+
RHyperLogLog<String> today = redisson.getHyperLogLog("UV_" + LocalDate.now());
48+
RHyperLogLog<String> nextDay = redisson.getHyperLogLog("UV_" + LocalDate.now().plusDays(1));
49+
today.delete();
50+
HashSet<String> set = new HashSet<>();
51+
Random random = new Random();
52+
for (int i = 0; i < 1000; i++) {
53+
String userId = "id_" + random.nextInt(1000);
54+
today.add(userId);
55+
set.add(userId);
56+
}
57+
for (int i = 0; i < 1000; i++) {
58+
String userId = "id_" + random.nextInt(2000);
59+
nextDay.add(userId);
60+
set.add(userId);
61+
}
62+
today.mergeWith(nextDay.getName());
63+
System.out.println("RHyperLogLog: " + today.count());
64+
System.out.println("set count: " + set.size());
65+
}
66+
4567
}

0 commit comments

Comments
 (0)