org.redisson.api.RHyperLogLog Java Examples

The following examples show how to use org.redisson.api.RHyperLogLog. 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: HyperLogLogExamples.java    From redisson-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();

    RHyperLogLog<String> hyperLogLog = redisson.getHyperLogLog("hyperLogLog");
    hyperLogLog.add("1");
    hyperLogLog.add("2");
    hyperLogLog.add("3");
    hyperLogLog.addAll(Arrays.asList("10", "20", "30"));
    
    RHyperLogLog<String> hyperLogLog1 = redisson.getHyperLogLog("hyperLogLog1");
    hyperLogLog1.add("4");
    hyperLogLog1.add("5");
    hyperLogLog1.add("6");
    
    RHyperLogLog<String> hyperLogLog2 = redisson.getHyperLogLog("hyperLogLog2");
    hyperLogLog1.add("4");
    hyperLogLog1.add("5");
    hyperLogLog1.add("6");
    
    hyperLogLog2.mergeWith(hyperLogLog1.getName());
    hyperLogLog2.countWith(hyperLogLog1.getName());

    redisson.shutdown();
}
 
Example #2
Source File: RedissonHyperLogLogTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testMerge() {
    RHyperLogLog<String> hll1 = redisson.getHyperLogLog("hll1");
    Assert.assertTrue(hll1.add("foo"));
    Assert.assertTrue(hll1.add("bar"));
    Assert.assertTrue(hll1.add("zap"));
    Assert.assertTrue(hll1.add("a"));

    RHyperLogLog<String> hll2 = redisson.getHyperLogLog("hll2");
    Assert.assertTrue(hll2.add("a"));
    Assert.assertTrue(hll2.add("b"));
    Assert.assertTrue(hll2.add("c"));
    Assert.assertTrue(hll2.add("foo"));
    Assert.assertFalse(hll2.add("c"));

    RHyperLogLog<String> hll3 = redisson.getHyperLogLog("hll3");
    hll3.mergeWith("hll1", "hll2");

    Assert.assertEquals(6L, hll3.count());
}
 
Example #3
Source File: RedissonHyperLogLogTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddAll() {
    RHyperLogLog<Integer> log = redisson.getHyperLogLog("log");
    log.addAll(Arrays.asList(1, 2, 3));
    
    Assert.assertEquals(3L, log.count());
}
 
Example #4
Source File: RedissonHyperLogLogTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testAdd() {
    RHyperLogLog<Integer> log = redisson.getHyperLogLog("log");
    log.add(1);
    log.add(2);
    log.add(3);

    Assert.assertEquals(3L, log.count());
}
 
Example #5
Source File: TracingRedissonClient.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public <V> RHyperLogLog<V> getHyperLogLog(String name) {
  return redissonClient.getHyperLogLog(name);
}
 
Example #6
Source File: TracingRedissonClient.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public <V> RHyperLogLog<V> getHyperLogLog(String name,
    Codec codec) {
  return redissonClient.getHyperLogLog(name, codec);
}