org.redisson.api.RBloomFilter Java Examples
The following examples show how to use
org.redisson.api.RBloomFilter.
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: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void test() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.tryInit(550000000L, 0.03); assertThat(filter.contains("123")).isFalse(); assertThat(filter.add("123")).isTrue(); assertThat(filter.contains("123")).isTrue(); assertThat(filter.add("123")).isFalse(); assertThat(filter.count()).isEqualTo(1); assertThat(filter.contains("hflgs;jl;ao1-32471320o31803-24")).isFalse(); assertThat(filter.add("hflgs;jl;ao1-32471320o31803-24")).isTrue(); assertThat(filter.contains("hflgs;jl;ao1-32471320o31803-24")).isTrue(); assertThat(filter.count()).isEqualTo(2); }
Example #2
Source File: DefaultRedisQueue.java From SeimiCrawler with Apache License 2.0 | 5 votes |
@Override public boolean isProcessed(Request req) { boolean res = false; try { String sign = GenericUtils.signRequest(req); RBloomFilter<String> bloomFilter = getFilter(req.getCrawlerName()); res = bloomFilter.contains(sign); } catch (Exception e) { logger.warn(e.getMessage()); } return res; }
Example #3
Source File: DefaultRedisQueue.java From SeimiCrawler with Apache License 2.0 | 5 votes |
@Override public void addProcessed(Request req) { try { String sign = DigestUtils.md5Hex(req.getUrl()); RBloomFilter<String> bloomFilter = getFilter(req.getCrawlerName()); bloomFilter.add(sign); } catch (Exception e) { logger.warn(e.getMessage()); } }
Example #4
Source File: DefaultRedisQueue.java From SeimiCrawler with Apache License 2.0 | 5 votes |
@Override public long totalCrawled(String crawlerName) { long count = 0; try { RBloomFilter<String> bloomFilter = getFilter(crawlerName); count = bloomFilter.count(); } catch (Exception e) { logger.warn(e.getMessage()); } return count; }
Example #5
Source File: DefaultRedisQueue.java From SeimiCrawler with Apache License 2.0 | 5 votes |
/** * 清除抓取记录 * */ @Override public void clearRecord(String crawlerName) { try { RBloomFilter<String> bloomFilter = getFilter(crawlerName); bloomFilter.delete(); } catch (Exception e) { logger.warn(e.getMessage()); } }
Example #6
Source File: DefaultRedisQueue.java From SeimiCrawler with Apache License 2.0 | 5 votes |
private RBloomFilter<String> getFilter(String crawlerName){ RBloomFilter<String> bloomFilter = bloomFilterCache.get(crawlerName); if (bloomFilter == null){ bloomFilter = redisson.getBloomFilter(setNamePrefix + crawlerName, new StringCodec()); bloomFilter.tryInit(expectedInsertions, falseProbability); bloomFilterCache.put(crawlerName,bloomFilter); } return bloomFilter; }
Example #7
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testConfig() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.tryInit(100, 0.03); assertThat(filter.getExpectedInsertions()).isEqualTo(100); assertThat(filter.getFalseProbability()).isEqualTo(0.03); assertThat(filter.getHashIterations()).isEqualTo(5); assertThat(filter.getSize()).isEqualTo(729); }
Example #8
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testInit() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); assertThat(filter.tryInit(55000000L, 0.03)).isTrue(); assertThat(filter.tryInit(55000001L, 0.03)).isFalse(); filter.delete(); assertThat(redisson.getKeys().count()).isZero(); assertThat(filter.tryInit(55000001L, 0.03)).isTrue(); }
Example #9
Source File: TracingRedissonClient.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public <V> RBloomFilter<V> getBloomFilter(String name) { return redissonClient.getBloomFilter(name); }
Example #10
Source File: TracingRedissonClient.java From java-redis-client with Apache License 2.0 | 4 votes |
@Override public <V> RBloomFilter<V> getBloomFilter(String name, Codec codec) { return redissonClient.getBloomFilter(name, codec); }
Example #11
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testFalseProbability1() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.tryInit(1, -1); }
Example #12
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testFalseProbability2() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.tryInit(1, 2); }
Example #13
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 4 votes |
@Test(expected = IllegalArgumentException.class) public void testSizeZero() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.tryInit(1, 1); }
Example #14
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 4 votes |
@Test(expected = IllegalStateException.class) public void testNotInitializedOnExpectedInsertions() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.getExpectedInsertions(); }
Example #15
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 4 votes |
@Test(expected = IllegalStateException.class) public void testNotInitializedOnContains() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.contains("32"); }
Example #16
Source File: RedissonBloomFilterTest.java From redisson with Apache License 2.0 | 4 votes |
@Test(expected = IllegalStateException.class) public void testNotInitializedOnAdd() { RBloomFilter<String> filter = redisson.getBloomFilter("filter"); filter.add("123"); }