Remove whitespace around parentheses.

This commit is contained in:
aherbert 2020-02-17 13:17:11 +00:00
parent 82273e966e
commit 5f70948570
7 changed files with 99 additions and 99 deletions

View File

@ -102,8 +102,8 @@ public class CountingBloomFilter extends AbstractBloomFilter {
@Override @Override
public int andCardinality(final BloomFilter other) { public int andCardinality(final BloomFilter other) {
if (other instanceof CountingBloomFilter) { if (other instanceof CountingBloomFilter) {
final Set<Integer> result = new HashSet<>( counts.keySet()); final Set<Integer> result = new HashSet<>(counts.keySet());
result.retainAll( ((CountingBloomFilter)other).counts.keySet() ); result.retainAll(((CountingBloomFilter)other).counts.keySet());
return result.size(); return result.size();
} }
return super.andCardinality(other); return super.andCardinality(other);
@ -172,8 +172,8 @@ public class CountingBloomFilter extends AbstractBloomFilter {
@Override @Override
public void merge(final Hasher hasher) { public void merge(final Hasher hasher) {
verifyHasher( hasher ); verifyHasher(hasher);
merge( hasher.getBits(getShape()) ); merge(hasher.getBits(getShape()));
} }
/** /**
@ -186,9 +186,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
if (val == null) { if (val == null) {
counts.put(idx, 1 ); counts.put(idx, 1 );
} else if (val == Integer.MAX_VALUE) { } else if (val == Integer.MAX_VALUE) {
throw new IllegalStateException( "Overflow on index "+idx); throw new IllegalStateException("Overflow on index " + idx);
} else { } else {
counts.put( idx, val+1 ); counts.put(idx, val + 1);
} }
}); });
} }
@ -223,9 +223,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
* @param hasher the hasher to generate bits. * @param hasher the hasher to generate bits.
*/ */
public void remove(final Hasher hasher) { public void remove(final Hasher hasher) {
verifyHasher( hasher ); verifyHasher(hasher);
final Set<Integer> lst = new HashSet<>(); final Set<Integer> lst = new HashSet<>();
hasher.getBits(getShape()).forEachRemaining( (Consumer<Integer>)lst::add ); hasher.getBits(getShape()).forEachRemaining((Consumer<Integer>)lst::add);
remove(lst.stream()); remove(lst.stream());
} }
@ -245,7 +245,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
} }
} }
if (val == null || val == 0) { if (val == null || val == 0) {
throw new IllegalStateException( "Underflow on index "+idx); throw new IllegalStateException("Underflow on index " + idx);
} else if (val - 1 == 0) { } else if (val - 1 == 0) {
counts.remove(idx); counts.remove(idx);
} else { } else {

View File

@ -106,7 +106,7 @@ public interface HashFunctionIdentity {
*/ */
static byte[] prepareSignatureBuffer(final HashFunctionIdentity identity) { static byte[] prepareSignatureBuffer(final HashFunctionIdentity identity) {
return String.format( "%s-%s-%s", return String.format("%s-%s-%s",
identity.getName().toUpperCase(Locale.ROOT), identity.getSignedness(), identity.getName().toUpperCase(Locale.ROOT), identity.getSignedness(),
identity.getProcessType() ).getBytes(StandardCharsets.UTF_8); identity.getProcessType() ).getBytes(StandardCharsets.UTF_8);

View File

@ -35,7 +35,7 @@ public final class HashFunctionIdentityImpl implements HashFunctionIdentity {
* Creates a copy of the HashFunctionIdentity. * Creates a copy of the HashFunctionIdentity.
* @param identity the identity to copy. * @param identity the identity to copy.
*/ */
public HashFunctionIdentityImpl( final HashFunctionIdentity identity) { public HashFunctionIdentityImpl(final HashFunctionIdentity identity) {
this.name = identity.getName(); this.name = identity.getName();
this.provider = identity.getProvider(); this.provider = identity.getProvider();
this.signedness = identity.getSignedness(); this.signedness = identity.getSignedness();
@ -51,7 +51,7 @@ public final class HashFunctionIdentityImpl implements HashFunctionIdentity {
* @param process the processes of the hash function. * @param process the processes of the hash function.
* @param signature the signature for the hash function. * @param signature the signature for the hash function.
*/ */
public HashFunctionIdentityImpl( final String provider, final String name, final Signedness signedness, final ProcessType process, public HashFunctionIdentityImpl(final String provider, final String name, final Signedness signedness, final ProcessType process,
final long signature) { final long signature) {
this.name = name; this.name = name;
this.provider = provider; this.provider = provider;

View File

@ -261,7 +261,7 @@ public class Shape {
return return
other.getNumberOfBits() == getNumberOfBits() && other.getNumberOfBits() == getNumberOfBits() &&
other.getNumberOfHashFunctions() == getNumberOfHashFunctions() && other.getNumberOfHashFunctions() == getNumberOfHashFunctions() &&
HashFunctionIdentity.COMMON_COMPARATOR.compare( getHashFunctionIdentity(), HashFunctionIdentity.COMMON_COMPARATOR.compare(getHashFunctionIdentity(),
other.getHashFunctionIdentity()) == 0; other.getHashFunctionIdentity()) == 0;
} }
return false; return false;

View File

@ -44,26 +44,26 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
*/ */
@Test @Test
public void andCardinalityTest_CountingBloomFilter() { public void andCardinalityTest_CountingBloomFilter() {
final Hasher hasher = new StaticHasher( Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ).iterator(), shape ); final Hasher hasher = new StaticHasher(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).iterator(), shape);
final CountingBloomFilter bf = createFilter(hasher, shape); final CountingBloomFilter bf = createFilter(hasher, shape);
Hasher hasher2 = new StaticHasher( Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ).iterator(), shape ); Hasher hasher2 = new StaticHasher(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).iterator(), shape);
CountingBloomFilter bf2 = createFilter(hasher2, shape); CountingBloomFilter bf2 = createFilter(hasher2, shape);
assertEquals( 10, bf.andCardinality(bf2)); assertEquals(10, bf.andCardinality(bf2));
assertEquals( 10, bf2.andCardinality(bf)); assertEquals(10, bf2.andCardinality(bf));
hasher2 = new StaticHasher( Arrays.asList( 1, 2, 3, 4, 5 ).iterator(), shape ); hasher2 = new StaticHasher(Arrays.asList(1, 2, 3, 4, 5).iterator(), shape);
bf2 = createFilter(hasher2, shape); bf2 = createFilter(hasher2, shape);
assertEquals( 5, bf.andCardinality(bf2)); assertEquals(5, bf.andCardinality(bf2));
assertEquals( 5, bf2.andCardinality(bf)); assertEquals(5, bf2.andCardinality(bf));
hasher2 = new StaticHasher( Arrays.asList( 11, 12, 13, 14, 15 ).iterator(), shape ); hasher2 = new StaticHasher(Arrays.asList(11, 12, 13, 14, 15).iterator(), shape);
bf2 = createFilter(hasher2, shape); bf2 = createFilter(hasher2, shape);
assertEquals( 0, bf.andCardinality(bf2)); assertEquals(0, bf.andCardinality(bf2));
assertEquals( 0, bf2.andCardinality(bf)); assertEquals(0, bf2.andCardinality(bf));
} }
@ -73,8 +73,8 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
*/ */
@Test @Test
public void ConstructorTest_HasherValues_CountsTest() { public void ConstructorTest_HasherValues_CountsTest() {
final List<Integer> lst = Arrays.asList( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ); final List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final CountingBloomFilter bf = createFilter(hasher, shape); final CountingBloomFilter bf = createFilter(hasher, shape);
final long[] lb = bf.getBits(); final long[] lb = bf.getBits();
@ -95,15 +95,15 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
final Map<Integer,Integer> map = new HashMap<>(); final Map<Integer,Integer> map = new HashMap<>();
for (int i =0;i<17;i++) for (int i =0;i<17;i++)
{ {
map.put( i, 1 ); map.put(i, 1);
} }
CountingBloomFilter bf = new CountingBloomFilter( map, shape); CountingBloomFilter bf = new CountingBloomFilter(map, shape);
assertEquals(17, bf.getCounts().count()); assertEquals(17, bf.getCounts().count());
map.put( shape.getNumberOfBits(), 1 ); map.put(shape.getNumberOfBits(), 1);
try { try {
bf = new CountingBloomFilter( map, shape); bf = new CountingBloomFilter(map, shape);
fail("Should have thrown IllegalArgumentExceptionW"); fail("Should have thrown IllegalArgumentExceptionW");
} catch (final IllegalArgumentException exprected) } catch (final IllegalArgumentException exprected)
{ {
@ -111,9 +111,9 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
} }
map.clear(); map.clear();
map.put( -1, 1 ); map.put(-1, 1);
try { try {
bf = new CountingBloomFilter( map, shape); bf = new CountingBloomFilter(map, shape);
fail("Should have thrown IllegalArgumentExceptionW"); fail("Should have thrown IllegalArgumentExceptionW");
} catch (final IllegalArgumentException exprected) } catch (final IllegalArgumentException exprected)
{ {
@ -121,9 +121,9 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
} }
map.clear(); map.clear();
map.put( 1, -1 ); map.put(1, -1);
try { try {
bf = new CountingBloomFilter( map, shape); bf = new CountingBloomFilter(map, shape);
fail("Should have thrown IllegalArgumentExceptionW"); fail("Should have thrown IllegalArgumentExceptionW");
} catch (final IllegalArgumentException exprected) } catch (final IllegalArgumentException exprected)
{ {
@ -134,12 +134,12 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
@Override @Override
protected CountingBloomFilter createEmptyFilter(final Shape shape) { protected CountingBloomFilter createEmptyFilter(final Shape shape) {
return new CountingBloomFilter( shape ); return new CountingBloomFilter(shape);
} }
@Override @Override
protected CountingBloomFilter createFilter(final Hasher hasher, final Shape shape) { protected CountingBloomFilter createFilter(final Hasher hasher, final Shape shape) {
return new CountingBloomFilter( hasher, shape ); return new CountingBloomFilter(hasher, shape);
} }
@ -153,13 +153,13 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0 1, 1, 1, 1, 1, 1, 1, 1, 0
}; };
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final CountingBloomFilter bf = createFilter(hasher, shape); final CountingBloomFilter bf = createFilter(hasher, shape);
final List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 ); final List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27);
final Hasher hasher2 = new StaticHasher( lst2.iterator(), shape ); final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
final BloomFilter bf2 = createFilter(hasher2, shape); final BloomFilter bf2 = createFilter(hasher2, shape);
bf.merge(bf2); bf.merge(bf2);
@ -174,10 +174,10 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
{ {
if (m.get(i) == null) if (m.get(i) == null)
{ {
assertEquals( "Wrong value for "+i, expected[i], 0 ); assertEquals("Wrong value for "+i, expected[i], 0);
} else } else
{ {
assertEquals( "Wrong value for "+i, expected[i], m.get(i).intValue()); assertEquals("Wrong value for "+i, expected[i], m.get(i).intValue());
} }
} }
} }
@ -192,13 +192,13 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0 1, 1, 1, 1, 1, 1, 1, 1, 0
}; };
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final CountingBloomFilter bf = createFilter(hasher, shape); final CountingBloomFilter bf = createFilter(hasher, shape);
final List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 ); final List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27);
final Hasher hasher2 = new StaticHasher( lst2.iterator(), shape ); final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
final BloomFilter bf2 = new BitSetBloomFilter(hasher2, shape); final BloomFilter bf2 = new BitSetBloomFilter(hasher2, shape);
bf.merge(bf2); bf.merge(bf2);
@ -213,10 +213,10 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
{ {
if (m.get(i) == null) if (m.get(i) == null)
{ {
assertEquals( "Wrong value for "+i, expected[i], 0 ); assertEquals("Wrong value for "+i, expected[i], 0);
} else } else
{ {
assertEquals( "Wrong value for "+i, expected[i], m.get(i).intValue()); assertEquals("Wrong value for "+i, expected[i], m.get(i).intValue());
} }
} }
@ -228,15 +228,15 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
@Test @Test
public void mergeTest_Overflow() { public void mergeTest_Overflow() {
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
CountingBloomFilter bf = createFilter(hasher, shape); CountingBloomFilter bf = createFilter(hasher, shape);
final Map<Integer,Integer> map = new HashMap<>(); final Map<Integer,Integer> map = new HashMap<>();
bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue())); bf.getCounts().forEach(e -> map.put(e.getKey(), e.getValue()));
map.put(1, Integer.MAX_VALUE ); map.put(1, Integer.MAX_VALUE);
CountingBloomFilter bf2 = new CountingBloomFilter(map, shape); CountingBloomFilter bf2 = new CountingBloomFilter(map, shape);
@ -268,13 +268,13 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
1, 1, 1, 1, 1, 1, 1, 1, 0 1, 1, 1, 1, 1, 1, 1, 1, 0
}; };
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final CountingBloomFilter bf = createFilter(hasher, shape); final CountingBloomFilter bf = createFilter(hasher, shape);
final List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 ); final List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27);
final Hasher hasher2 = new StaticHasher( lst2.iterator(), shape ); final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
bf.merge(hasher2); bf.merge(hasher2);
@ -288,10 +288,10 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
{ {
if (m.get(i) == null) if (m.get(i) == null)
{ {
assertEquals( "Wrong value for "+i, expected[i], 0 ); assertEquals("Wrong value for "+i, expected[i], 0);
} else } else
{ {
assertEquals( "Wrong value for "+i, expected[i], m.get(i).intValue()); assertEquals("Wrong value for "+i, expected[i], m.get(i).intValue());
} }
} }
} }
@ -309,24 +309,24 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
final Map<Integer,Integer> map = new HashMap<>(); final Map<Integer,Integer> map = new HashMap<>();
for (int i=1;i<values.length;i++) for (int i=1;i<values.length;i++)
{ {
map.put( i, values[i] ); map.put(i, values[i]);
} }
final CountingBloomFilter bf = new CountingBloomFilter( map, shape ); final CountingBloomFilter bf = new CountingBloomFilter(map, shape);
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final BloomFilter bf2 = new CountingBloomFilter( hasher, shape ); final BloomFilter bf2 = new CountingBloomFilter(hasher, shape);
bf.remove( bf2 ); bf.remove(bf2);
assertEquals( 17, bf.cardinality() ); assertEquals(17, bf.cardinality());
final Map<Integer,Integer> map2 = new HashMap<>(); final Map<Integer,Integer> map2 = new HashMap<>();
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue())); bf.getCounts().forEach(e -> map2.put(e.getKey(), e.getValue()));
for (int i = 11; i<values.length; i++ ) for (int i = 11; i<values.length; i++)
{ {
assertNotNull( map2.get(i) ); assertNotNull(map2.get(i));
assertEquals( 1, map2.get(i).intValue()); assertEquals(1, map2.get(i).intValue());
} }
} }
@ -344,24 +344,24 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
final Map<Integer,Integer> map = new HashMap<>(); final Map<Integer,Integer> map = new HashMap<>();
for (int i=1;i<values.length;i++) for (int i=1;i<values.length;i++)
{ {
map.put( i, values[i] ); map.put(i, values[i]);
} }
final CountingBloomFilter bf = new CountingBloomFilter( map, shape ); final CountingBloomFilter bf = new CountingBloomFilter(map, shape);
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
bf.remove( hasher ); bf.remove(hasher);
assertEquals( 17, bf.cardinality() ); assertEquals(17, bf.cardinality());
final Map<Integer,Integer> map2 = new HashMap<>(); final Map<Integer,Integer> map2 = new HashMap<>();
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue())); bf.getCounts().forEach(e -> map2.put(e.getKey(), e.getValue()));
for (int i = 11; i<values.length; i++ ) for (int i = 11; i<values.length; i++)
{ {
assertNotNull( map2.get(i) ); assertNotNull(map2.get(i));
assertEquals( 1, map2.get(i).intValue()); assertEquals(1, map2.get(i).intValue());
} }
} }
@ -379,24 +379,24 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
final Map<Integer,Integer> map = new HashMap<>(); final Map<Integer,Integer> map = new HashMap<>();
for (int i=1;i<values.length;i++) for (int i=1;i<values.length;i++)
{ {
map.put( i, values[i] ); map.put(i, values[i]);
} }
final CountingBloomFilter bf = new CountingBloomFilter( map, shape ); final CountingBloomFilter bf = new CountingBloomFilter(map, shape);
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final BitSetBloomFilter bf2 = new BitSetBloomFilter( hasher, shape ); final BitSetBloomFilter bf2 = new BitSetBloomFilter(hasher, shape);
bf.remove( bf2 ); bf.remove(bf2);
assertEquals( 17, bf.cardinality() ); assertEquals(17, bf.cardinality());
final Map<Integer,Integer> map2 = new HashMap<>(); final Map<Integer,Integer> map2 = new HashMap<>();
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue())); bf.getCounts().forEach(e -> map2.put(e.getKey(), e.getValue()));
for (int i = 11; i<values.length; i++ ) for (int i = 11; i<values.length; i++)
{ {
assertNotNull( map2.get(i) ); assertNotNull(map2.get(i));
assertEquals( 1, map2.get(i).intValue()); assertEquals(1, map2.get(i).intValue());
} }
} }
@ -407,14 +407,14 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
@Test @Test
public void removeTest_Underflow() { public void removeTest_Underflow() {
final List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 ); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17);
final Hasher hasher = new StaticHasher( lst.iterator(), shape ); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
CountingBloomFilter bf = createFilter(hasher, shape); CountingBloomFilter bf = createFilter(hasher, shape);
final Map<Integer,Integer> map = new HashMap<>(); final Map<Integer,Integer> map = new HashMap<>();
bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue())); bf.getCounts().forEach(e -> map.put(e.getKey(), e.getValue()));
map.remove(1); map.remove(1);
CountingBloomFilter bf2 = new CountingBloomFilter(map, shape); CountingBloomFilter bf2 = new CountingBloomFilter(map, shape);

View File

@ -109,7 +109,7 @@ public class SetOperationsTest {
// build a filter // build a filter
final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
final Hasher hasher = new StaticHasher(lst.iterator(), shape); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape ); final BloomFilter filter3 = new HasherBloomFilter(hasher, shape);
assertEquals(1.0, SetOperations.cosineDistance(filter1, filter2), 0.0001); assertEquals(1.0, SetOperations.cosineDistance(filter1, filter2), 0.0001);
assertEquals(1.0, SetOperations.cosineDistance(filter2, filter1), 0.0001); assertEquals(1.0, SetOperations.cosineDistance(filter2, filter1), 0.0001);
@ -154,7 +154,7 @@ public class SetOperationsTest {
// build a filter // build a filter
final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
final Hasher hasher = new StaticHasher(lst.iterator(), shape); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape ); final BloomFilter filter3 = new HasherBloomFilter(hasher, shape);
assertEquals(0.0, SetOperations.cosineSimilarity(filter1, filter2), 0.0001); assertEquals(0.0, SetOperations.cosineSimilarity(filter1, filter2), 0.0001);
assertEquals(0.0, SetOperations.cosineSimilarity(filter2, filter1), 0.0001); assertEquals(0.0, SetOperations.cosineSimilarity(filter2, filter1), 0.0001);
@ -293,7 +293,7 @@ public class SetOperationsTest {
// build a filter // build a filter
final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
final Hasher hasher = new StaticHasher(lst.iterator(), shape); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape ); final BloomFilter filter3 = new HasherBloomFilter(hasher, shape);
assertEquals(1.0, SetOperations.jaccardDistance(filter1, filter2), 0.0001); assertEquals(1.0, SetOperations.jaccardDistance(filter1, filter2), 0.0001);
assertEquals(1.0, SetOperations.jaccardDistance(filter2, filter1), 0.0001); assertEquals(1.0, SetOperations.jaccardDistance(filter2, filter1), 0.0001);
@ -337,7 +337,7 @@ public class SetOperationsTest {
// build a filter // build a filter
final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17); final List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
final Hasher hasher = new StaticHasher(lst.iterator(), shape); final Hasher hasher = new StaticHasher(lst.iterator(), shape);
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape ); final BloomFilter filter3 = new HasherBloomFilter(hasher, shape);
assertEquals(0.0, SetOperations.jaccardSimilarity(filter1, filter2), 0.0001); assertEquals(0.0, SetOperations.jaccardSimilarity(filter1, filter2), 0.0001);
assertEquals(0.0, SetOperations.jaccardSimilarity(filter2, filter1), 0.0001); assertEquals(0.0, SetOperations.jaccardSimilarity(filter2, filter1), 0.0001);

View File

@ -329,10 +329,10 @@ public class StaticHasherTest {
StaticHasher hasher = new StaticHasher(lst.iterator(), shape); StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
assertTrue( hasher.isEmpty() ); assertTrue(hasher.isEmpty());
lst.add( Integer.valueOf( 1 )); lst.add( Integer.valueOf(1));
hasher = new StaticHasher(lst.iterator(), shape); hasher = new StaticHasher(lst.iterator(), shape);
assertFalse( hasher.isEmpty() ); assertFalse(hasher.isEmpty());
} }
} }