org.apache.rocketmq.filter.util.BitsArray Java Examples
The following examples show how to use
org.apache.rocketmq.filter.util.BitsArray.
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: BloomFilterTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testCheckFalseHit() { BloomFilter bloomFilter = BloomFilter.createByFn(1, 300); BitsArray bits = BitsArray.create(bloomFilter.getM()); int falseHit = 0; for (int i = 0; i < bloomFilter.getN(); i++) { String str = randomString((new Random(System.nanoTime())).nextInt(127) + 10); int[] bitPos = bloomFilter.calcBitPositions(str); if (bloomFilter.checkFalseHit(bitPos, bits)) { falseHit++; } bloomFilter.hashTo(bitPos, bits); } assertThat(falseHit).isLessThanOrEqualTo(bloomFilter.getF() * bloomFilter.getN() / 100); }
Example #2
Source File: BloomFilterTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Test public void testCheckFalseHit() { BloomFilter bloomFilter = BloomFilter.createByFn(1, 300); BitsArray bits = BitsArray.create(bloomFilter.getM()); int falseHit = 0; for (int i = 0; i < bloomFilter.getN(); i++) { String str = randomString((new Random(System.nanoTime())).nextInt(127) + 10); int[] bitPos = bloomFilter.calcBitPositions(str); if (bloomFilter.checkFalseHit(bitPos, bits)) { falseHit++; } bloomFilter.hashTo(bitPos, bits); } assertThat(falseHit).isLessThanOrEqualTo(bloomFilter.getF() * bloomFilter.getN() / 100); }
Example #3
Source File: BloomFilterTest.java From DDMQ with Apache License 2.0 | 6 votes |
@Test public void testCheckFalseHit() { BloomFilter bloomFilter = BloomFilter.createByFn(1, 300); BitsArray bits = BitsArray.create(bloomFilter.getM()); int falseHit = 0; for (int i = 0; i < bloomFilter.getN(); i++) { String str = randomString((new Random(System.nanoTime())).nextInt(127) + 10); int[] bitPos = bloomFilter.calcBitPositions(str); if (bloomFilter.checkFalseHit(bitPos, bits)) { falseHit++; } bloomFilter.hashTo(bitPos, bits); } assertThat(falseHit).isLessThanOrEqualTo(bloomFilter.getF() * bloomFilter.getN() / 100); }
Example #4
Source File: BloomFilterTest.java From rocketmq with Apache License 2.0 | 6 votes |
@Test public void testCheckFalseHit() { BloomFilter bloomFilter = BloomFilter.createByFn(1, 300); BitsArray bits = BitsArray.create(bloomFilter.getM()); int falseHit = 0; for (int i = 0; i < bloomFilter.getN(); i++) { String str = randomString((new Random(System.nanoTime())).nextInt(127) + 10); int[] bitPos = bloomFilter.calcBitPositions(str); if (bloomFilter.checkFalseHit(bitPos, bits)) { falseHit++; } bloomFilter.hashTo(bitPos, bits); } assertThat(falseHit).isLessThanOrEqualTo(bloomFilter.getF() * bloomFilter.getN() / 100); }
Example #5
Source File: BloomFilterTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@Test public void testCheckFalseHit() { BloomFilter bloomFilter = BloomFilter.createByFn(1, 300); BitsArray bits = BitsArray.create(bloomFilter.getM()); int falseHit = 0; for (int i = 0; i < bloomFilter.getN(); i++) { String str = randomString((new Random(System.nanoTime())).nextInt(127) + 10); int[] bitPos = bloomFilter.calcBitPositions(str); if (bloomFilter.checkFalseHit(bitPos, bits)) { falseHit++; } bloomFilter.hashTo(bitPos, bits); } assertThat(falseHit).isLessThanOrEqualTo(bloomFilter.getF() * bloomFilter.getN() / 100); }
Example #6
Source File: BloomFilterTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testCheckFalseHit() { BloomFilter bloomFilter = BloomFilter.createByFn(1, 300); BitsArray bits = BitsArray.create(bloomFilter.getM()); int falseHit = 0; for (int i = 0; i < bloomFilter.getN(); i++) { String str = randomString((new Random(System.nanoTime())).nextInt(127) + 10); int[] bitPos = bloomFilter.calcBitPositions(str); if (bloomFilter.checkFalseHit(bitPos, bits)) { falseHit++; } bloomFilter.hashTo(bitPos, bits); } assertThat(falseHit).isLessThanOrEqualTo(bloomFilter.getF() * bloomFilter.getN() / 100); }
Example #7
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testOr() { BitsArray b1 = BitsArray.create(new byte[] {(byte) 0xff, 0x00}); BitsArray b2 = BitsArray.create(new byte[] {0x00, (byte) 0xff}); b1.or(b2); for (int i = 0; i < b1.bitLength(); i++) { assertThat(b1.getBit(i)).isTrue(); } }
Example #8
Source File: BitsArrayTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
BitsArray gen(int bitCount) { BitsArray bitsArray = BitsArray.create(bitCount); for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { Thread.sleep(2); } catch (InterruptedException e) { } } return bitsArray; }
Example #9
Source File: BitsArrayTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testOr() { BitsArray b1 = BitsArray.create(new byte[] {(byte) 0xff, 0x00}); BitsArray b2 = BitsArray.create(new byte[] {0x00, (byte) 0xff}); b1.or(b2); for (int i = 0; i < b1.bitLength(); i++) { assertThat(b1.getBit(i)).isTrue(); } }
Example #10
Source File: BitsArrayTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testNot() { BitsArray bitsArray = gen(bitLength); BitsArray backUp = bitsArray.clone(); bitsArray.not(2); bitsArray.xor(backUp); assertThat(bitsArray.getBit(2)).isTrue(); }
Example #11
Source File: BitsArrayTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testAndOr() { BitsArray bitsArray = gen(bitLength); boolean val = bitsArray.getBit(2); if (val) { bitsArray.and(2, false); assertThat(!bitsArray.getBit(2)).isTrue(); } else { bitsArray.or(2, true); assertThat(bitsArray.getBit(2)).isTrue(); } }
Example #12
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
BitsArray gen(int bitCount) { BitsArray bitsArray = BitsArray.create(bitCount); for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { Thread.sleep(2); } catch (InterruptedException e) { } } return bitsArray; }
Example #13
Source File: BitsArrayTest.java From rocketmq with Apache License 2.0 | 5 votes |
BitsArray gen(int bitCount) { BitsArray bitsArray = BitsArray.create(bitCount); for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { Thread.sleep(2); } catch (InterruptedException e) { } } return bitsArray; }
Example #14
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testAndOr() { BitsArray bitsArray = gen(bitLength); boolean val = bitsArray.getBit(2); if (val) { bitsArray.and(2, false); assertThat(!bitsArray.getBit(2)).isTrue(); } else { bitsArray.or(2, true); assertThat(bitsArray.getBit(2)).isTrue(); } }
Example #15
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testNot() { BitsArray bitsArray = gen(bitLength); BitsArray backUp = bitsArray.clone(); bitsArray.not(2); bitsArray.xor(backUp); assertThat(bitsArray.getBit(2)).isTrue(); }
Example #16
Source File: BitsArrayTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testNot() { BitsArray bitsArray = gen(bitLength); BitsArray backUp = bitsArray.clone(); bitsArray.not(2); bitsArray.xor(backUp); assertThat(bitsArray.getBit(2)).isTrue(); }
Example #17
Source File: BitsArrayTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testOr() { BitsArray b1 = BitsArray.create(new byte[]{(byte) 0xff, 0x00}); BitsArray b2 = BitsArray.create(new byte[]{0x00, (byte) 0xff}); b1.or(b2); for (int i = 0; i < b1.bitLength(); i++) { assertThat(b1.getBit(i)).isTrue(); } }
Example #18
Source File: BitsArrayTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testAndOr() { BitsArray bitsArray = gen(bitLength); boolean val = bitsArray.getBit(2); if (val) { bitsArray.and(2, false); assertThat(!bitsArray.getBit(2)).isTrue(); } else { bitsArray.or(2, true); assertThat(bitsArray.getBit(2)).isTrue(); } }
Example #19
Source File: BitsArrayTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testAndOr() { BitsArray bitsArray = gen(bitLength); boolean val = bitsArray.getBit(2); if (val) { bitsArray.and(2, false); assertThat(!bitsArray.getBit(2)).isTrue(); } else { bitsArray.or(2, true); assertThat(bitsArray.getBit(2)).isTrue(); } }
Example #20
Source File: BitsArrayTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
BitsArray gen(int bitCount) { BitsArray bitsArray = BitsArray.create(bitCount); for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { Thread.sleep(2); } catch (InterruptedException e) { } } return bitsArray; }
Example #21
Source File: BitsArrayTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testNot() { BitsArray bitsArray = gen(bitLength); BitsArray backUp = bitsArray.clone(); bitsArray.not(2); bitsArray.xor(backUp); assertThat(bitsArray.getBit(2)).isTrue(); }
Example #22
Source File: BitsArrayTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testOr() { BitsArray b1 = BitsArray.create(new byte[] {(byte) 0xff, 0x00}); BitsArray b2 = BitsArray.create(new byte[] {0x00, (byte) 0xff}); b1.or(b2); for (int i = 0; i < b1.bitLength(); i++) { assertThat(b1.getBit(i)).isTrue(); } }
Example #23
Source File: BitsArrayTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
BitsArray gen(int bitCount) { BitsArray bitsArray = BitsArray.create(bitCount); for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { Thread.sleep(2); } catch (InterruptedException e) { } } return bitsArray; }
Example #24
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testOr() { BitsArray b1 = BitsArray.create(new byte[] {(byte) 0xff, 0x00}); BitsArray b2 = BitsArray.create(new byte[] {0x00, (byte) 0xff}); b1.or(b2); for (int i = 0; i < b1.bitLength(); i++) { assertThat(b1.getBit(i)).isTrue(); } }
Example #25
Source File: BitsArrayTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testAndOr() { BitsArray bitsArray = gen(bitLength); boolean val = bitsArray.getBit(2); if (val) { bitsArray.and(2, false); assertThat(!bitsArray.getBit(2)).isTrue(); } else { bitsArray.or(2, true); assertThat(bitsArray.getBit(2)).isTrue(); } }
Example #26
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testNot() { BitsArray bitsArray = gen(bitLength); BitsArray backUp = bitsArray.clone(); bitsArray.not(2); bitsArray.xor(backUp); assertThat(bitsArray.getBit(2)).isTrue(); }
Example #27
Source File: BitsArrayTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testNot() { BitsArray bitsArray = gen(bitLength); BitsArray backUp = bitsArray.clone(); bitsArray.not(2); bitsArray.xor(backUp); assertThat(bitsArray.getBit(2)).isTrue(); }
Example #28
Source File: BitsArrayTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testOr() { BitsArray b1 = BitsArray.create(new byte[] {(byte) 0xff, 0x00}); BitsArray b2 = BitsArray.create(new byte[] {0x00, (byte) 0xff}); b1.or(b2); for (int i = 0; i < b1.bitLength(); i++) { assertThat(b1.getBit(i)).isTrue(); } }
Example #29
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
@Test public void testAndOr() { BitsArray bitsArray = gen(bitLength); boolean val = bitsArray.getBit(2); if (val) { bitsArray.and(2, false); assertThat(!bitsArray.getBit(2)).isTrue(); } else { bitsArray.or(2, true); assertThat(bitsArray.getBit(2)).isTrue(); } }
Example #30
Source File: BitsArrayTest.java From DDMQ with Apache License 2.0 | 5 votes |
BitsArray gen(int bitCount) { BitsArray bitsArray = BitsArray.create(bitCount); for (int i = 0; i < bitCount / Byte.SIZE; i++) { bitsArray.setByte(i, (byte) (new Random(System.currentTimeMillis())).nextInt(0xff)); try { Thread.sleep(2); } catch (InterruptedException e) { } } return bitsArray; }