Use final.
This commit is contained in:
parent
1e57244dc1
commit
1a193e4f21
|
@ -1829,8 +1829,8 @@ public class CollectionUtils {
|
|||
"The sum of start index and count can't be greater than the size of collection.");
|
||||
}
|
||||
|
||||
Collection<E> result = new ArrayList<>(count);
|
||||
Iterator<E> iterator = input.iterator();
|
||||
final Collection<E> result = new ArrayList<>(count);
|
||||
final Iterator<E> iterator = input.iterator();
|
||||
while (count > 0) {
|
||||
if (startIndex > 0) {
|
||||
startIndex = startIndex - 1;
|
||||
|
|
|
@ -135,7 +135,7 @@ public final class UnmodifiableBag<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public final class UnmodifiableSortedBag<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -377,7 +377,7 @@ public abstract class AbstractDualBidiMap<K, V> implements BidiMap<K, V> {
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
if (parent.isEmpty() || Objects.isNull(filter)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
*
|
||||
* @param shape The shape.
|
||||
*/
|
||||
protected AbstractBloomFilter(Shape shape) {
|
||||
protected AbstractBloomFilter(final Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* @param other the other filter to check.
|
||||
* @throws IllegalArgumentException if the shapes are not the same.
|
||||
*/
|
||||
protected void verifyShape(BloomFilter other) {
|
||||
protected void verifyShape(final BloomFilter other) {
|
||||
verifyShape(other.getShape());
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* @param shape the other shape to check.
|
||||
* @throws IllegalArgumentException if the shapes are not the same.
|
||||
*/
|
||||
protected void verifyShape(Shape shape) {
|
||||
protected void verifyShape(final Shape shape) {
|
||||
if (!this.shape.equals(shape)) {
|
||||
throw new IllegalArgumentException(String.format("Shape %s is not the same as %s", shape, this.shape));
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
*
|
||||
* @param hasher the Hasher to check
|
||||
*/
|
||||
protected void verifyHasher(Hasher hasher) {
|
||||
protected void verifyHasher(final Hasher hasher) {
|
||||
if (shape.getHashFunctionIdentity().getSignature() != hasher.getHashFunctionIdentity().getSignature()) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Hasher (%s) is not the hasher for shape (%s)",
|
||||
|
@ -163,12 +163,12 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* @return the cardinality of the result of {@code ( this AND other )}.
|
||||
*/
|
||||
@Override
|
||||
public int andCardinality(BloomFilter other) {
|
||||
public int andCardinality(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
long[] mine = getBits();
|
||||
long[] theirs = other.getBits();
|
||||
int limit = Integer.min(mine.length, theirs.length);
|
||||
long[] result = new long[limit];
|
||||
final long[] mine = getBits();
|
||||
final long[] theirs = other.getBits();
|
||||
final int limit = Integer.min(mine.length, theirs.length);
|
||||
final long[] result = new long[limit];
|
||||
for (int i = 0; i < limit; i++) {
|
||||
result[i] = mine[i] & theirs[i];
|
||||
}
|
||||
|
@ -176,10 +176,10 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int orCardinality(BloomFilter other) {
|
||||
public int orCardinality(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
long[] mine = getBits();
|
||||
long[] theirs = other.getBits();
|
||||
final long[] mine = getBits();
|
||||
final long[] theirs = other.getBits();
|
||||
long[] remainder = null;
|
||||
long[] result = null;
|
||||
if (mine.length > theirs.length) {
|
||||
|
@ -190,7 +190,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
remainder = theirs;
|
||||
|
||||
}
|
||||
int limit = Integer.min(mine.length, theirs.length);
|
||||
final int limit = Integer.min(mine.length, theirs.length);
|
||||
for (int i = 0; i < limit; i++) {
|
||||
result[i] = mine[i] | theirs[i];
|
||||
}
|
||||
|
@ -209,10 +209,10 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* @return the cardinality of the result of {@code( this XOR other )}
|
||||
*/
|
||||
@Override
|
||||
public int xorCardinality(BloomFilter other) {
|
||||
public int xorCardinality(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
long[] mine = getBits();
|
||||
long[] theirs = other.getBits();
|
||||
final long[] mine = getBits();
|
||||
final long[] theirs = other.getBits();
|
||||
long[] remainder = null;
|
||||
long[] result = null;
|
||||
if (mine.length > theirs.length) {
|
||||
|
@ -223,7 +223,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
remainder = theirs;
|
||||
|
||||
}
|
||||
int limit = Integer.min(mine.length, theirs.length);
|
||||
final int limit = Integer.min(mine.length, theirs.length);
|
||||
for (int i = 0; i < limit; i++) {
|
||||
result[i] = mine[i] ^ theirs[i];
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* @return true if this filter matches the other.
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(BloomFilter other) {
|
||||
public boolean contains(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
return other.cardinality() == andCardinality(other);
|
||||
}
|
||||
|
@ -257,16 +257,16 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
|||
* this filter, or if the hasher is not the specified one
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Hasher hasher) {
|
||||
public boolean contains(final Hasher hasher) {
|
||||
verifyHasher( hasher );
|
||||
long[] buff = getBits();
|
||||
final long[] buff = getBits();
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
while (iter.hasNext()) {
|
||||
int idx = iter.nextInt();
|
||||
int buffIdx = idx / Long.SIZE;
|
||||
int pwr = Math.floorMod(idx, Long.SIZE);
|
||||
long buffOffset = 1L << pwr;
|
||||
final int idx = iter.nextInt();
|
||||
final int buffIdx = idx / Long.SIZE;
|
||||
final int pwr = Math.floorMod(idx, Long.SIZE);
|
||||
final long buffOffset = 1L << pwr;
|
||||
if ((buff[buffIdx] & buffOffset) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
* @param hasher the Hasher to use.
|
||||
* @param shape the desired shape of the filter.
|
||||
*/
|
||||
public BitSetBloomFilter(Hasher hasher, Shape shape) {
|
||||
public BitSetBloomFilter(final Hasher hasher, final Shape shape) {
|
||||
this(shape);
|
||||
verifyHasher(hasher);
|
||||
hasher.getBits(shape).forEachRemaining((IntConsumer) bitSet::set);
|
||||
|
@ -54,7 +54,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
*
|
||||
* @param shape the desired shape of the filter.
|
||||
*/
|
||||
public BitSetBloomFilter(Shape shape) {
|
||||
public BitSetBloomFilter(final Shape shape) {
|
||||
super(shape);
|
||||
this.bitSet = new BitSet();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void merge(BloomFilter other) {
|
||||
public void merge(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
if (other instanceof BitSetBloomFilter) {
|
||||
bitSet.or(((BitSetBloomFilter)other).bitSet);
|
||||
|
@ -80,9 +80,9 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Hasher hasher) {
|
||||
public boolean contains(final Hasher hasher) {
|
||||
verifyHasher(hasher);
|
||||
OfInt iter = hasher.getBits(getShape());
|
||||
final OfInt iter = hasher.getBits(getShape());
|
||||
while (iter.hasNext()) {
|
||||
if (!bitSet.get(iter.nextInt())) {
|
||||
return false;
|
||||
|
@ -103,7 +103,7 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
|
||||
|
||||
@Override
|
||||
public void merge(Hasher hasher) {
|
||||
public void merge(final Hasher hasher) {
|
||||
verifyHasher(hasher);
|
||||
hasher.getBits(getShape()).forEachRemaining((IntConsumer) bitSet::set);
|
||||
}
|
||||
|
@ -117,10 +117,10 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
* @see #andCardinality(BloomFilter)
|
||||
*/
|
||||
@Override
|
||||
public int andCardinality(BloomFilter other) {
|
||||
public int andCardinality(final BloomFilter other) {
|
||||
if (other instanceof BitSetBloomFilter) {
|
||||
verifyShape(other);
|
||||
BitSet result = (BitSet) bitSet.clone();
|
||||
final BitSet result = (BitSet) bitSet.clone();
|
||||
result.and(((BitSetBloomFilter)other).bitSet);
|
||||
return result.cardinality();
|
||||
}
|
||||
|
@ -129,10 +129,10 @@ public class BitSetBloomFilter extends AbstractBloomFilter {
|
|||
|
||||
|
||||
@Override
|
||||
public int xorCardinality(BloomFilter other) {
|
||||
public int xorCardinality(final BloomFilter other) {
|
||||
if (other instanceof BitSetBloomFilter) {
|
||||
verifyShape(other);
|
||||
BitSet result = (BitSet) bitSet.clone();
|
||||
final BitSet result = (BitSet) bitSet.clone();
|
||||
result.xor(((BitSetBloomFilter)other).bitSet);
|
||||
return result.cardinality();
|
||||
}
|
||||
|
|
|
@ -58,11 +58,11 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
* @param hasher The hasher to build the filter from.
|
||||
* @param shape The shape of the resulting filter.
|
||||
*/
|
||||
public CountingBloomFilter(Hasher hasher, Shape shape) {
|
||||
public CountingBloomFilter(final Hasher hasher, final Shape shape) {
|
||||
super(shape);
|
||||
verifyHasher(hasher);
|
||||
counts = new TreeMap<>();
|
||||
Set<Integer> idxs = new HashSet<>();
|
||||
final Set<Integer> idxs = new HashSet<>();
|
||||
hasher.getBits(shape).forEachRemaining((IntConsumer) idxs::add);
|
||||
idxs.stream().forEach(idx -> counts.put(idx, 1));
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
*
|
||||
* @param shape The shape of the resulting filter.
|
||||
*/
|
||||
public CountingBloomFilter(Shape shape) {
|
||||
public CountingBloomFilter(final Shape shape) {
|
||||
super(shape);
|
||||
this.counts = new TreeMap<>();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
* @param counts A map of data counts.
|
||||
* @param shape The shape of the resulting filter.
|
||||
*/
|
||||
public CountingBloomFilter(Map<Integer,Integer> counts, Shape shape) {
|
||||
public CountingBloomFilter(final Map<Integer,Integer> counts, final Shape shape) {
|
||||
this(shape);
|
||||
counts.entrySet().stream().forEach( e -> {
|
||||
if (e.getKey() >= shape.getNumberOfBits())
|
||||
|
@ -116,8 +116,8 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("{ ");
|
||||
for (Map.Entry<Integer, Integer> e : counts.entrySet()) {
|
||||
final StringBuilder sb = new StringBuilder("{ ");
|
||||
for (final Map.Entry<Integer, Integer> e : counts.entrySet()) {
|
||||
sb.append(String.format("(%s,%s) ", e.getKey(), e.getValue()));
|
||||
}
|
||||
return sb.append("}").toString();
|
||||
|
@ -135,7 +135,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
* @param other the other filter.
|
||||
*/
|
||||
@Override
|
||||
public void merge(BloomFilter other) {
|
||||
public void merge(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
if (other instanceof CountingBloomFilter)
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void merge(Hasher hasher) {
|
||||
public void merge(final Hasher hasher) {
|
||||
verifyHasher( hasher );
|
||||
merge( hasher.getBits(getShape()) );
|
||||
}
|
||||
|
@ -155,9 +155,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
* Merge an iterator of set bits into this filter.
|
||||
* @param iter the iterator of bits to set.
|
||||
*/
|
||||
private void merge(Iterator<Integer> iter) {
|
||||
private void merge(final Iterator<Integer> iter) {
|
||||
iter.forEachRemaining(idx -> {
|
||||
Integer val = counts.get(idx);
|
||||
final Integer val = counts.get(idx);
|
||||
if (val == null) {
|
||||
counts.put(idx, 1 );
|
||||
} else if (val == Integer.MAX_VALUE) {
|
||||
|
@ -178,7 +178,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
*
|
||||
* @param other the other filter.
|
||||
*/
|
||||
public void remove(BloomFilter other) {
|
||||
public void remove(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
if (other instanceof CountingBloomFilter)
|
||||
{
|
||||
|
@ -198,9 +198,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
*
|
||||
* @param hasher the hasher to generate bits.
|
||||
*/
|
||||
public void remove(Hasher hasher) {
|
||||
public void remove(final Hasher hasher) {
|
||||
verifyHasher( hasher );
|
||||
Set<Integer> lst = new HashSet<>();
|
||||
final Set<Integer> lst = new HashSet<>();
|
||||
hasher.getBits(getShape()).forEachRemaining( (Consumer<Integer>)lst::add );
|
||||
remove(lst.stream());
|
||||
}
|
||||
|
@ -210,9 +210,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
*
|
||||
* @param idxStream The stream of bit counts to decrement.
|
||||
*/
|
||||
private void remove(Stream<Integer> idxStream) {
|
||||
private void remove(final Stream<Integer> idxStream) {
|
||||
idxStream.forEach(idx -> {
|
||||
Integer val = counts.get(idx);
|
||||
final Integer val = counts.get(idx);
|
||||
if (val != null) {
|
||||
if (val - 1 == 0) {
|
||||
counts.remove(idx);
|
||||
|
@ -232,7 +232,7 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
|
||||
@Override
|
||||
public long[] getBits() {
|
||||
BitSet bs = new BitSet();
|
||||
final BitSet bs = new BitSet();
|
||||
counts.keySet().stream().forEach(bs::set);
|
||||
return bs.toLongArray();
|
||||
}
|
||||
|
@ -243,9 +243,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Hasher hasher) {
|
||||
public boolean contains(final Hasher hasher) {
|
||||
verifyHasher(hasher);
|
||||
OfInt iter = hasher.getBits(getShape());
|
||||
final OfInt iter = hasher.getBits(getShape());
|
||||
while (iter.hasNext()) {
|
||||
if (counts.get(iter.nextInt()) == null) {
|
||||
return false;
|
||||
|
@ -260,9 +260,9 @@ public class CountingBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int andCardinality(BloomFilter other) {
|
||||
public int andCardinality(final BloomFilter other) {
|
||||
if (other instanceof CountingBloomFilter) {
|
||||
Set<Integer> result = new HashSet<>( counts.keySet());
|
||||
final Set<Integer> result = new HashSet<>( counts.keySet());
|
||||
result.retainAll( ((CountingBloomFilter)other).counts.keySet() );
|
||||
return result.size();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class HasherBloomFilter extends AbstractBloomFilter {
|
|||
* @param hasher the hasher to use.
|
||||
* @param shape the shape of the Bloom filter.
|
||||
*/
|
||||
public HasherBloomFilter(Hasher hasher, Shape shape) {
|
||||
public HasherBloomFilter(final Hasher hasher, final Shape shape) {
|
||||
super(shape);
|
||||
verifyHasher(hasher);
|
||||
if (hasher instanceof StaticHasher) {
|
||||
|
@ -65,7 +65,7 @@ public class HasherBloomFilter extends AbstractBloomFilter {
|
|||
*
|
||||
* @param shape the shape of the Bloom filter.
|
||||
*/
|
||||
public HasherBloomFilter(Shape shape) {
|
||||
public HasherBloomFilter(final Shape shape) {
|
||||
super(shape);
|
||||
this.hasher = new StaticHasher(EmptyIterator.emptyIterator(), shape);
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ public class HasherBloomFilter extends AbstractBloomFilter {
|
|||
if (hasher.size() == 0) {
|
||||
return new long[0];
|
||||
}
|
||||
int n = (int) Math.ceil(hasher.getShape().getNumberOfBits() * 1.0 / Long.SIZE);
|
||||
long[] result = new long[n];
|
||||
OfInt iter = hasher.getBits(hasher.getShape());
|
||||
final int n = (int) Math.ceil(hasher.getShape().getNumberOfBits() * 1.0 / Long.SIZE);
|
||||
final long[] result = new long[n];
|
||||
final OfInt iter = hasher.getBits(hasher.getShape());
|
||||
iter.forEachRemaining((IntConsumer) idx -> {
|
||||
long buff = result[idx / Long.SIZE];
|
||||
long pwr = Math.floorMod(idx, Long.SIZE);
|
||||
long buffOffset = 1L << pwr;
|
||||
final long pwr = Math.floorMod(idx, Long.SIZE);
|
||||
final long buffOffset = 1L << pwr;
|
||||
buff |= buffOffset;
|
||||
result[idx / Long.SIZE] = buff;
|
||||
});
|
||||
|
@ -105,14 +105,14 @@ public class HasherBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void merge(BloomFilter other) {
|
||||
public void merge(final BloomFilter other) {
|
||||
merge(other.getHasher());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(Hasher hasher) {
|
||||
public void merge(final Hasher hasher) {
|
||||
verifyHasher(hasher);
|
||||
IteratorChain<Integer> iter = new IteratorChain<>(this.hasher.getBits(getShape()),
|
||||
final IteratorChain<Integer> iter = new IteratorChain<>(this.hasher.getBits(getShape()),
|
||||
hasher.getBits(getShape()));
|
||||
this.hasher = new StaticHasher(iter, getShape());
|
||||
}
|
||||
|
@ -123,15 +123,15 @@ public class HasherBloomFilter extends AbstractBloomFilter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Hasher hasher) {
|
||||
public boolean contains(final Hasher hasher) {
|
||||
verifyHasher(hasher);
|
||||
Set<Integer> set = new TreeSet<>();
|
||||
final Set<Integer> set = new TreeSet<>();
|
||||
hasher.getBits(getShape()).forEachRemaining((IntConsumer) idx -> {
|
||||
set.add(idx);
|
||||
});
|
||||
OfInt iter = this.hasher.getBits(getShape());
|
||||
final OfInt iter = this.hasher.getBits(getShape());
|
||||
while (iter.hasNext()) {
|
||||
int idx = iter.nextInt();
|
||||
final int idx = iter.nextInt();
|
||||
set.remove(idx);
|
||||
if (set.isEmpty()) {
|
||||
return true;
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class SetOperations {
|
|||
* @param second the second filter to check.
|
||||
* @throws IllegalArgumentException if the shapes are not the same.
|
||||
*/
|
||||
private static void verifyShape(BloomFilter first, BloomFilter second) {
|
||||
private static void verifyShape(final BloomFilter first, final BloomFilter second) {
|
||||
if (!first.getShape().equals(second.getShape())) {
|
||||
throw new IllegalArgumentException(String.format("Shape %s is not the same as %s",
|
||||
first.getShape(), second.getShape()));
|
||||
|
@ -51,7 +51,7 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return the Hamming distance.
|
||||
*/
|
||||
public static int hammingDistance(BloomFilter first, BloomFilter second) {
|
||||
public static int hammingDistance(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
return first.xorCardinality(second);
|
||||
}
|
||||
|
@ -66,9 +66,9 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return the Jaccard similarity.
|
||||
*/
|
||||
public static double jaccardSimilarity(BloomFilter first, BloomFilter second) {
|
||||
public static double jaccardSimilarity(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
int orCard = first.orCardinality(second);
|
||||
final int orCard = first.orCardinality(second);
|
||||
// if the orCard is zero then the hamming distance will also be zero.
|
||||
return orCard==0?0:hammingDistance(first,second) / (double) orCard;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return the Jaccard distance.
|
||||
*/
|
||||
public static double jaccardDistance(BloomFilter first, BloomFilter second) {
|
||||
public static double jaccardDistance(final BloomFilter first, final BloomFilter second) {
|
||||
return 1.0 - jaccardSimilarity(first,second);
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,9 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return the Cosine similarity.
|
||||
*/
|
||||
public static double cosineSimilarity(BloomFilter first, BloomFilter second) {
|
||||
public static double cosineSimilarity(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
int numerator = first.andCardinality(second);
|
||||
final int numerator = first.andCardinality(second);
|
||||
|
||||
return numerator==0?0:numerator / (Math.sqrt(first.cardinality()) * Math.sqrt(second.cardinality()));
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return the jaccard distance.
|
||||
*/
|
||||
public static double cosineDistance(BloomFilter first, BloomFilter second) {
|
||||
public static double cosineDistance(final BloomFilter first, final BloomFilter second) {
|
||||
return 1.0 - cosineSimilarity(first,second);
|
||||
}
|
||||
|
||||
|
@ -124,9 +124,9 @@ public final class SetOperations {
|
|||
* @param filter the Bloom filter to estimate size for.
|
||||
* @return an estimate of the number of items that were placed in the Bloom filter.
|
||||
*/
|
||||
public static long estimateSize(BloomFilter filter) {
|
||||
Shape shape = filter.getShape();
|
||||
double estimate = -(shape.getNumberOfBits() *
|
||||
public static long estimateSize(final BloomFilter filter) {
|
||||
final Shape shape = filter.getShape();
|
||||
final double estimate = -(shape.getNumberOfBits() *
|
||||
Math.log(1.0 - filter.cardinality() * 1.0 / shape.getNumberOfBits())) /
|
||||
shape.getNumberOfHashFunctions();
|
||||
return Math.round(estimate);
|
||||
|
@ -140,10 +140,10 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return an estimate of the size of the union between the two filters.
|
||||
*/
|
||||
public static long estimateUnionSize(BloomFilter first, BloomFilter second) {
|
||||
public static long estimateUnionSize(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
Shape shape = first.getShape();
|
||||
double estimate = -(shape.getNumberOfBits() *
|
||||
final Shape shape = first.getShape();
|
||||
final double estimate = -(shape.getNumberOfBits() *
|
||||
Math.log(1.0 - first.orCardinality(second) * 1.0 / shape.getNumberOfBits())) /
|
||||
shape.getNumberOfHashFunctions();
|
||||
return Math.round(estimate);
|
||||
|
@ -157,7 +157,7 @@ public final class SetOperations {
|
|||
* @param second the second Bloom filter.
|
||||
* @return an estimate of the size of the intersection between the two filters.
|
||||
*/
|
||||
public static long estimateIntersectionSize(BloomFilter first, BloomFilter second) {
|
||||
public static long estimateIntersectionSize(final BloomFilter first, final BloomFilter second) {
|
||||
verifyShape(first,second);
|
||||
// do subtraction early to avoid Long overflow.
|
||||
return estimateSize(first) - estimateUnionSize(first,second) + estimateSize(second);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class DynamicHasher implements Hasher {
|
|||
* @param function the function to use.
|
||||
* @param buffers the byte buffers that will be hashed.
|
||||
*/
|
||||
public DynamicHasher(HashFunction function, List<byte[]> buffers) {
|
||||
public DynamicHasher(final HashFunction function, final List<byte[]> buffers) {
|
||||
this.buffers = new ArrayList<>(buffers);
|
||||
this.function = function;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class DynamicHasher implements Hasher {
|
|||
* {@code getName()}
|
||||
*/
|
||||
@Override
|
||||
public PrimitiveIterator.OfInt getBits(Shape shape) {
|
||||
public PrimitiveIterator.OfInt getBits(final Shape shape) {
|
||||
if (HashFunctionIdentity.COMMON_COMPARATOR.compare(getHashFunctionIdentity(),
|
||||
shape.getHashFunctionIdentity()) != 0) {
|
||||
throw new IllegalArgumentException(
|
||||
|
@ -95,7 +95,7 @@ public class DynamicHasher implements Hasher {
|
|||
*
|
||||
* @param shape
|
||||
*/
|
||||
private Iterator(Shape shape) {
|
||||
private Iterator(final Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class DynamicHasher implements Hasher {
|
|||
*
|
||||
* @param function the function implementation.
|
||||
*/
|
||||
public Builder(HashFunction function) {
|
||||
public Builder(final HashFunction function) {
|
||||
this.function = function;
|
||||
this.buffers = new ArrayList<>();
|
||||
|
||||
|
@ -158,18 +158,18 @@ public class DynamicHasher implements Hasher {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final Builder with(byte property) {
|
||||
public final Builder with(final byte property) {
|
||||
return with(new byte[] {property});
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Builder with(byte[] property) {
|
||||
public final Builder with(final byte[] property) {
|
||||
buffers.add(property);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Builder with(String property) {
|
||||
public final Builder with(final String property) {
|
||||
return with(property.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public interface HashFunctionIdentity {
|
|||
Comparator<HashFunctionIdentity> COMMON_COMPARATOR = new Comparator<HashFunctionIdentity>() {
|
||||
|
||||
@Override
|
||||
public int compare(HashFunctionIdentity identity1, HashFunctionIdentity identity2) {
|
||||
public int compare(final HashFunctionIdentity identity1, final HashFunctionIdentity identity2) {
|
||||
int result = identity1.getName().compareToIgnoreCase(identity2.getName());
|
||||
if (result == 0) {
|
||||
result = identity1.getSignedness().compareTo(identity2.getSignedness());
|
||||
|
@ -54,7 +54,7 @@ public interface HashFunctionIdentity {
|
|||
Comparator<HashFunctionIdentity> DEEP_COMPARATOR = new Comparator<HashFunctionIdentity>() {
|
||||
|
||||
@Override
|
||||
public int compare(HashFunctionIdentity identity1, HashFunctionIdentity identity2) {
|
||||
public int compare(final HashFunctionIdentity identity1, final HashFunctionIdentity identity2) {
|
||||
int result = COMMON_COMPARATOR.compare(identity1, identity2);
|
||||
if (result == 0) {
|
||||
result = identity1.getProvider().compareToIgnoreCase(identity2.getProvider());
|
||||
|
@ -69,7 +69,7 @@ public interface HashFunctionIdentity {
|
|||
* @param identity the identity to format.
|
||||
* @return the String representing the identity.
|
||||
*/
|
||||
static String asCommonString(HashFunctionIdentity identity) {
|
||||
static String asCommonString(final HashFunctionIdentity identity) {
|
||||
return String.format("%s-%s-%s", identity.getName(), identity.getSignedness(), identity.getProcessType());
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public interface HashFunctionIdentity {
|
|||
* @param identity The HashFunctionIdentity to create the buffer for.
|
||||
* @return the signature buffer for the identity
|
||||
*/
|
||||
static byte[] prepareSignatureBuffer(HashFunctionIdentity identity) {
|
||||
static byte[] prepareSignatureBuffer(final HashFunctionIdentity identity) {
|
||||
|
||||
return String.format( "%s-%s-%s",
|
||||
identity.getName().toUpperCase(Locale.ROOT), identity.getSignedness(),
|
||||
|
|
|
@ -35,7 +35,7 @@ public final class HashFunctionIdentityImpl implements HashFunctionIdentity {
|
|||
* Creates a copy of the HashFunctionIdentity.
|
||||
* @param identity the identity to copy.
|
||||
*/
|
||||
public HashFunctionIdentityImpl( HashFunctionIdentity identity) {
|
||||
public HashFunctionIdentityImpl( final HashFunctionIdentity identity) {
|
||||
this.name = identity.getName();
|
||||
this.provider = identity.getProvider();
|
||||
this.signedness = identity.getSignedness();
|
||||
|
@ -51,8 +51,8 @@ public final class HashFunctionIdentityImpl implements HashFunctionIdentity {
|
|||
* @param process the processes of the hash function.
|
||||
* @param signature the signature for the hash function.
|
||||
*/
|
||||
public HashFunctionIdentityImpl( String provider, String name, Signedness signedness, ProcessType process,
|
||||
long signature) {
|
||||
public HashFunctionIdentityImpl( final String provider, final String name, final Signedness signedness, final ProcessType process,
|
||||
final long signature) {
|
||||
this.name = name;
|
||||
this.provider = provider;
|
||||
this.signedness = signedness;
|
||||
|
|
|
@ -89,7 +89,7 @@ public class Shape {
|
|||
* @param probability The desired probability of duplicates. Must be in the range
|
||||
* (0.0,1.0).
|
||||
*/
|
||||
public Shape(HashFunctionIdentity hashFunctionIdentity, final int numberOfItems, final double probability) {
|
||||
public Shape(final HashFunctionIdentity hashFunctionIdentity, final int numberOfItems, final double probability) {
|
||||
if (hashFunctionIdentity == null) {
|
||||
throw new IllegalArgumentException("Hash function identity may not be null");
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class Shape {
|
|||
this.numberOfHashFunctions = numberOfHashFunctions;
|
||||
|
||||
// n = ceil(m / (-k / log(1 - exp(log(p) / k))))
|
||||
double n = Math.ceil(numberOfBits /
|
||||
final double n = Math.ceil(numberOfBits /
|
||||
(-numberOfHashFunctions / Math.log(1 - Math.exp(Math.log(probability) / numberOfHashFunctions))));
|
||||
|
||||
// log of probability is always < 0
|
||||
|
@ -251,12 +251,12 @@ public class Shape {
|
|||
* @param numberOfBits the number of bits in the filter.
|
||||
* @return the optimal number of hash functions.
|
||||
*/
|
||||
private int calculateNumberOfHashFunctions(int numberOfItems, int numberOfBits) {
|
||||
private int calculateNumberOfHashFunctions(final int numberOfItems, final int numberOfBits) {
|
||||
/*
|
||||
* k = round((m / n) * log(2)) We change order so that we use real math rather
|
||||
* than integer math.
|
||||
*/
|
||||
long k = Math.round(LOG_OF_2 * numberOfBits / numberOfItems);
|
||||
final long k = Math.round(LOG_OF_2 * numberOfBits / numberOfItems);
|
||||
if (k < 1) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Filter to small: Calculated number of hash functions (%s) was less than 1", k));
|
||||
|
@ -279,7 +279,7 @@ public class Shape {
|
|||
*/
|
||||
public final double getProbability() {
|
||||
// (1 - exp(-kn/m))^k
|
||||
double p = Math.pow(1.0 - Math.exp(-1.0 * numberOfHashFunctions * numberOfItems / numberOfBits),
|
||||
final double p = Math.pow(1.0 - Math.exp(-1.0 * numberOfHashFunctions * numberOfItems / numberOfBits),
|
||||
numberOfHashFunctions);
|
||||
/*
|
||||
* We do not need to check for p < = since we only allow positive values for
|
||||
|
@ -331,9 +331,9 @@ public class Shape {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(final Object o) {
|
||||
if (o instanceof Shape) {
|
||||
Shape other = (Shape) o;
|
||||
final Shape other = (Shape) o;
|
||||
return
|
||||
other.getNumberOfBits() == getNumberOfBits() &&
|
||||
other.getNumberOfHashFunctions() == getNumberOfHashFunctions() &&
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class StaticHasher implements Hasher {
|
|||
* @param shape the Shape for the resulting values.
|
||||
* @throws IllegalArgumentException if the shape of the hasher and the shape parameter are not the same.
|
||||
*/
|
||||
public StaticHasher(StaticHasher hasher, Shape shape) {
|
||||
public StaticHasher(final StaticHasher hasher, final Shape shape) {
|
||||
if (!hasher.shape.equals(shape)) {
|
||||
throw new IllegalArgumentException(String.format("Hasher shape (%s) is not the same as shape (%s)",
|
||||
hasher.getShape().toString(), shape.toString()));
|
||||
|
@ -60,7 +60,7 @@ public final class StaticHasher implements Hasher {
|
|||
* @param shape the Shape for the resulting values.
|
||||
* @throws IllegalArgumentException if the hasher function and the shape function are not the same.
|
||||
*/
|
||||
public StaticHasher(Hasher hasher, Shape shape) {
|
||||
public StaticHasher(final Hasher hasher, final Shape shape) {
|
||||
this( hasher.getBits(shape), shape);
|
||||
if (
|
||||
HashFunctionIdentity.COMMON_COMPARATOR.compare(
|
||||
|
@ -77,9 +77,9 @@ public final class StaticHasher implements Hasher {
|
|||
* @param shape the Shape that the integers were generated for.
|
||||
* @throws IllegalArgumentException if any Integer is outside the range [0,shape.getNumberOfBits())
|
||||
*/
|
||||
public StaticHasher(Iterator<Integer> iter, Shape shape) {
|
||||
public StaticHasher(final Iterator<Integer> iter, final Shape shape) {
|
||||
this.shape = shape;
|
||||
Set<Integer> workingValues = new TreeSet<>();
|
||||
final Set<Integer> workingValues = new TreeSet<>();
|
||||
iter.forEachRemaining( idx -> {
|
||||
if (idx >= this.shape.getNumberOfBits())
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ public final class StaticHasher implements Hasher {
|
|||
});
|
||||
this.values = new int[workingValues.size()];
|
||||
int i=0;
|
||||
for (Integer value : workingValues)
|
||||
for (final Integer value : workingValues)
|
||||
{
|
||||
values[i++] = value.intValue();
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public final class StaticHasher implements Hasher {
|
|||
* equal {@code getName()}
|
||||
*/
|
||||
@Override
|
||||
public OfInt getBits(Shape shape) {
|
||||
public OfInt getBits(final Shape shape) {
|
||||
if (!this.shape.equals(shape)) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("shape (%s) does not match internal shape (%s)", shape, this.shape));
|
||||
|
|
|
@ -58,14 +58,14 @@ public final class MD5Cyclic implements HashFunction {
|
|||
public MD5Cyclic() {
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance(NAME);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch (final NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException( e.getMessage() );
|
||||
}
|
||||
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long apply(byte[] buffer, int seed) {
|
||||
public long apply(final byte[] buffer, final int seed) {
|
||||
|
||||
if (seed == 0) {
|
||||
byte[] hash;
|
||||
|
@ -75,7 +75,7 @@ public final class MD5Cyclic implements HashFunction {
|
|||
messageDigest.reset();
|
||||
}
|
||||
|
||||
LongBuffer lb = ByteBuffer.wrap(hash).asLongBuffer();
|
||||
final LongBuffer lb = ByteBuffer.wrap(hash).asLongBuffer();
|
||||
result[0] = lb.get(0);
|
||||
result[1] = lb.get(1);
|
||||
} else {
|
||||
|
|
|
@ -54,7 +54,7 @@ public final class Murmur128x86Cyclic implements HashFunction {
|
|||
|
||||
|
||||
@Override
|
||||
public long apply(byte[] buffer, int seed) {
|
||||
public long apply(final byte[] buffer, final int seed) {
|
||||
if (parts == null || seed == 0) {
|
||||
parts = MurmurHash3.hash128x64(buffer, 0, buffer.length, 0);
|
||||
} else {
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class Murmur32x86Iterative implements HashFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long apply(byte[] buffer, int seed) {
|
||||
public long apply(final byte[] buffer, final int seed) {
|
||||
return MurmurHash3.hash32x86(buffer, 0, buffer.length, seed);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,11 +57,11 @@ public final class ObjectsHashIterative implements HashFunction {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long apply(byte[] buffer, int seed) {
|
||||
public long apply(final byte[] buffer, final int seed) {
|
||||
if (seed == 0) {
|
||||
last = 0;
|
||||
}
|
||||
long result = Arrays.deepHashCode( new Object[] {last, buffer});
|
||||
final long result = Arrays.deepHashCode( new Object[] {last, buffer});
|
||||
last += result;
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ public class CompositeCollection<E> implements Collection<E>, Serializable {
|
|||
* @param compositeCollections the Collections to be appended to the composite
|
||||
*/
|
||||
public void addComposited(final Collection<E>... compositeCollections) {
|
||||
for (Collection<E> compositeCollection : compositeCollections) {
|
||||
for (final Collection<E> compositeCollection : compositeCollections) {
|
||||
if (compositeCollection != null) {
|
||||
all.add(compositeCollection);
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ public class FixedSizeList<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw unsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -246,8 +246,8 @@ public class SetUniqueList<E> extends AbstractSerializableListDecorator<E> {
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
boolean result = super.removeIf(filter);
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
final boolean result = super.removeIf(filter);
|
||||
set.removeIf(filter);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public final class UnmodifiableList<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ public abstract class AbstractReferenceMap<K, V> extends AbstractHashedMap<K, V>
|
|||
HashEntry<K, V> previous = null;
|
||||
HashEntry<K, V> entry = data[index];
|
||||
while (entry != null) {
|
||||
ReferenceEntry<K, V> refEntry = (ReferenceEntry<K, V>) entry;
|
||||
final ReferenceEntry<K, V> refEntry = (ReferenceEntry<K, V>) entry;
|
||||
if (refEntry.purge(ref)) {
|
||||
if (previous == null) {
|
||||
data[index] = entry.next;
|
||||
|
|
|
@ -98,7 +98,7 @@ public final class UnmodifiableEntrySet<K, V>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super Map.Entry<K, V>> filter) {
|
||||
public boolean removeIf(final Predicate<? super Map.Entry<K, V>> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ public final class UnmodifiableMultiSet<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ public final class UnmodifiableQueue<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ public class CompositeSet<E> implements Set<E>, Serializable {
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
if (Objects.isNull(filter)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ public final class MapBackedSet<E, V> implements Set<E>, Serializable {
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
return map.keySet().removeIf(filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public final class UnmodifiableNavigableSet<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public final class UnmodifiableSet<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ public final class UnmodifiableSortedSet<E>
|
|||
* @since 4.4
|
||||
*/
|
||||
@Override
|
||||
public boolean removeIf(Predicate<? super E> filter) {
|
||||
public boolean removeIf(final Predicate<? super E> filter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -1474,7 +1474,7 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
|
||||
@Test
|
||||
public void testRemoveRange() {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
Collection<Integer> result = CollectionUtils.removeRange(list, 0, 0);
|
||||
assertEquals(1, list.size());
|
||||
|
@ -1492,42 +1492,42 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testRemoveRangeNull() {
|
||||
Collection<Integer> list = null;
|
||||
Collection result = CollectionUtils.removeRange(list, 0, 0);
|
||||
final Collection<Integer> list = null;
|
||||
final Collection result = CollectionUtils.removeRange(list, 0, 0);
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
public void testRemoveRangeStartIndexNegative() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
Collection result = CollectionUtils.removeRange(list, -1, 1);
|
||||
final Collection result = CollectionUtils.removeRange(list, -1, 1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testRemoveRangeEndIndexNegative() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
Collection result = CollectionUtils.removeRange(list, 0, -1);
|
||||
final Collection result = CollectionUtils.removeRange(list, 0, -1);
|
||||
}
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testRemoveRangeEndLowStart() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
list.add(2);
|
||||
Collection result = CollectionUtils.removeRange(list, 1, 0);
|
||||
final Collection result = CollectionUtils.removeRange(list, 1, 0);
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
public void testRemoveRangeWrongEndIndex() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
Collection result = CollectionUtils.removeRange(list, 0, 2);
|
||||
final Collection result = CollectionUtils.removeRange(list, 0, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveCount() {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
list.add(2);
|
||||
list.add(3);
|
||||
|
@ -1558,27 +1558,27 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testRemoveCountWithNull() {
|
||||
Collection<Integer> list = null;
|
||||
Collection result = CollectionUtils.removeCount(list, 0, 1);
|
||||
final Collection<Integer> list = null;
|
||||
final Collection result = CollectionUtils.removeCount(list, 0, 1);
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
public void testRemoveCountStartNegative() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
Collection result = CollectionUtils.removeCount(list, -1, 1);
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
final Collection result = CollectionUtils.removeCount(list, -1, 1);
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
public void testRemoveCountNegative() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
Collection result = CollectionUtils.removeCount(list, 0, -1);
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
final Collection result = CollectionUtils.removeCount(list, 0, -1);
|
||||
}
|
||||
|
||||
@Test(expected=IndexOutOfBoundsException.class)
|
||||
public void testRemoveCountWrongCount() {
|
||||
Collection<Integer> list = new ArrayList<>();
|
||||
final Collection<Integer> list = new ArrayList<>();
|
||||
list.add(1);
|
||||
Collection result = CollectionUtils.removeCount(list, 0, 2);
|
||||
final Collection result = CollectionUtils.removeCount(list, 0, 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -65,7 +65,7 @@ public class EnumerationUtilsTest {
|
|||
final Vector<String> vector = new Vector<>();
|
||||
vector.addElement("zero");
|
||||
vector.addElement("one");
|
||||
Enumeration<String> en = vector.elements();
|
||||
final Enumeration<String> en = vector.elements();
|
||||
final Iterator<String> iterator = EnumerationUtils.asIterable(en).iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals("zero", iterator.next());
|
||||
|
|
|
@ -477,28 +477,28 @@ public class IteratorUtilsTest {
|
|||
final Vector<String> vector = new Vector<>();
|
||||
vector.addElement("zero");
|
||||
vector.addElement("one");
|
||||
Enumeration<String> en = vector.elements();
|
||||
final Enumeration<String> en = vector.elements();
|
||||
assertTrue("create instance fail", IteratorUtils.asIterator(en) instanceof Iterator);
|
||||
IteratorUtils.asIterator(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsIteratorNull() {
|
||||
Collection coll = new ArrayList();
|
||||
final Collection coll = new ArrayList();
|
||||
coll.add("test");
|
||||
final Vector<String> vector = new Vector<>();
|
||||
vector.addElement("test");
|
||||
vector.addElement("one");
|
||||
Enumeration<String> en = vector.elements();
|
||||
final Enumeration<String> en = vector.elements();
|
||||
assertTrue("create instance fail", IteratorUtils.asIterator(en, coll) instanceof Iterator);
|
||||
try {
|
||||
IteratorUtils.asIterator(null, coll);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
IteratorUtils.asIterator(en, null);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
@ -542,8 +542,8 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testChainedIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator ie = arrayList.iterator();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
assertTrue("create instance fail", IteratorUtils.chainedIterator(ie) instanceof Iterator);
|
||||
final Collection<Iterator<?>> coll = new ArrayList();
|
||||
assertTrue("create instance fail", IteratorUtils.chainedIterator(coll) instanceof Iterator);
|
||||
|
@ -601,18 +601,18 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testCollatedIteratorCollectionNull() {
|
||||
Collection<Iterator<?>> coll = new ArrayList<>();
|
||||
final Collection<Iterator<?>> coll = new ArrayList<>();
|
||||
coll.add(collectionOdd.iterator());
|
||||
// natural ordering
|
||||
Iterator<?> it = IteratorUtils.collatedIterator(null, coll);
|
||||
List<?> result = IteratorUtils.toList(it);
|
||||
final Iterator<?> it = IteratorUtils.collatedIterator(null, coll);
|
||||
final List<?> result = IteratorUtils.toList(it);
|
||||
assertEquals(6, result.size());
|
||||
IteratorUtils.collatedIterator(null, (Collection<Iterator<?>>) null);
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testCollatedIteratorNull() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
// natural ordering
|
||||
Iterator<Integer> it = IteratorUtils.collatedIterator(null, collectionOdd.iterator(), collectionOdd.iterator(),
|
||||
collectionOdd.iterator());
|
||||
|
@ -842,35 +842,35 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testFilteredIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator ie = arrayList.iterator();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
try {
|
||||
IteratorUtils.filteredIterator(ie, null);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
IteratorUtils.filteredIterator(null, null);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredListIterator() {
|
||||
List arrayList = new ArrayList();
|
||||
final List arrayList = new ArrayList();
|
||||
arrayList.add("test");
|
||||
Predicate predicate = INSTANCE;
|
||||
final Predicate predicate = INSTANCE;
|
||||
assertTrue("create instance fail",
|
||||
IteratorUtils.filteredListIterator(arrayList.listIterator(), predicate) instanceof ListIterator);
|
||||
try {
|
||||
IteratorUtils.filteredListIterator(null, predicate);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
IteratorUtils.filteredListIterator(arrayList.listIterator(), null);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
@ -996,13 +996,13 @@ public class IteratorUtilsTest {
|
|||
IteratorUtils.getIterator(nodeList) instanceof NodeListIterator);
|
||||
assertTrue("returns EnumerationIterator when Enumeration passed",
|
||||
IteratorUtils.getIterator(new Vector().elements()) instanceof EnumerationIterator);
|
||||
Node node1 = createMock(Node.class);
|
||||
final Node node1 = createMock(Node.class);
|
||||
assertTrue("returns NodeListIterator when nodeList passed",
|
||||
IteratorUtils.getIterator(node1) instanceof NodeListIterator);
|
||||
Dictionary dic = createMock(Dictionary.class);
|
||||
final Dictionary dic = createMock(Dictionary.class);
|
||||
assertTrue("returns EnumerationIterator when Dictionary passed",
|
||||
IteratorUtils.getIterator(dic) instanceof EnumerationIterator);
|
||||
int[] arr = new int[8];
|
||||
final int[] arr = new int[8];
|
||||
assertTrue("returns ArrayIterator when array passed", IteratorUtils.getIterator(arr) instanceof ArrayIterator);
|
||||
}
|
||||
|
||||
|
@ -1025,20 +1025,20 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testLoopingIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
arrayList.add("test");
|
||||
Collection coll = new ArrayList();
|
||||
final Collection coll = new ArrayList();
|
||||
coll.add("test");
|
||||
Iterator ie = arrayList.iterator();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
assertTrue("create instance fail", IteratorUtils.loopingIterator(coll) instanceof ResettableIterator);
|
||||
IteratorUtils.loopingIterator(null);
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testLoopingListIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
arrayList.add("test");
|
||||
Iterator ie = arrayList.iterator();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
assertTrue("create instance fail", IteratorUtils.loopingListIterator(arrayList) instanceof ResettableIterator);
|
||||
IteratorUtils.loopingListIterator(null);
|
||||
}
|
||||
|
@ -1111,8 +1111,8 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testPeekingIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator ie = arrayList.iterator();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
assertTrue("create instance fail", IteratorUtils.peekingIterator(ie) instanceof Iterator);
|
||||
IteratorUtils.peekingIterator(null);
|
||||
|
||||
|
@ -1120,8 +1120,8 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testPushBackIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator ie = arrayList.iterator();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
assertTrue("create instance fail", IteratorUtils.pushbackIterator(ie) instanceof Iterator);
|
||||
IteratorUtils.pushbackIterator(null);
|
||||
}
|
||||
|
@ -1230,16 +1230,16 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testTransformedIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator ie = arrayList.iterator();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
try {
|
||||
IteratorUtils.transformedIterator(ie, null);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
try {
|
||||
IteratorUtils.transformedIterator(null, null);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (final NullPointerException npe) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
@ -1409,7 +1409,7 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testUnmodifiableMapIterator() {
|
||||
Set<?> set = new LinkedHashSet<>();
|
||||
final Set<?> set = new LinkedHashSet<>();
|
||||
final MapIterator ie = new EntrySetToMapIteratorAdapter(set);
|
||||
assertTrue("create instance fail", IteratorUtils.unmodifiableMapIterator(ie) instanceof MapIterator);
|
||||
IteratorUtils.unmodifiableMapIterator(null);
|
||||
|
@ -1418,8 +1418,8 @@ public class IteratorUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testZippingIterator() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
Iterator ie = arrayList.iterator();
|
||||
final ArrayList arrayList = new ArrayList();
|
||||
final Iterator ie = arrayList.iterator();
|
||||
assertTrue("create instance fail", IteratorUtils.zippingIterator(ie, ie, ie) instanceof ZippingIterator);
|
||||
assertTrue("create instance fail", IteratorUtils.zippingIterator(ie, ie) instanceof ZippingIterator);
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ public class ListUtilsTest {
|
|||
private int index;
|
||||
|
||||
@Override
|
||||
public Integer transform(Integer input) {
|
||||
public Integer transform(final Integer input) {
|
||||
return offsets.get(input) + index++;
|
||||
}
|
||||
|
||||
|
|
|
@ -189,26 +189,26 @@ public class SetUtilsTest {
|
|||
@Test
|
||||
public void testHashSet()
|
||||
{
|
||||
Set<?> set1 = SetUtils.unmodifiableSet();
|
||||
final Set<?> set1 = SetUtils.unmodifiableSet();
|
||||
assertTrue("set is empty", set1.isEmpty());
|
||||
|
||||
Set<Integer> set2 = SetUtils.hashSet(1, 2, 2, 3);
|
||||
final Set<Integer> set2 = SetUtils.hashSet(1, 2, 2, 3);
|
||||
assertEquals("set has 3 elements", 3, set2.size());
|
||||
assertTrue("set contains 1", set2.contains(1));
|
||||
assertTrue("set contains 2", set2.contains(2));
|
||||
assertTrue("set contains 3", set2.contains(3));
|
||||
|
||||
Set<String> set3 = SetUtils.hashSet("1", "2", "2", "3");
|
||||
final Set<String> set3 = SetUtils.hashSet("1", "2", "2", "3");
|
||||
assertEquals("set has 3 elements", 3, set3.size());
|
||||
assertTrue("set contains 1", set3.contains("1"));
|
||||
assertTrue("set contains 2", set3.contains("2"));
|
||||
assertTrue("set contains 3", set3.contains("3"));
|
||||
|
||||
Set<?> set4 = SetUtils.hashSet(null, null);
|
||||
final Set<?> set4 = SetUtils.hashSet(null, null);
|
||||
assertEquals("set has 1 element", 1, set4.size());
|
||||
assertTrue("set contains null", set4.contains(null));
|
||||
|
||||
Set<?> set5 = SetUtils.hashSet((Object[]) null);
|
||||
final Set<?> set5 = SetUtils.hashSet((Object[]) null);
|
||||
assertEquals("set is null", null, set5);
|
||||
}
|
||||
|
||||
|
@ -251,34 +251,34 @@ public class SetUtilsTest {
|
|||
@Test
|
||||
public void testUnmodifiableSet()
|
||||
{
|
||||
Set<?> set1 = SetUtils.unmodifiableSet();
|
||||
final Set<?> set1 = SetUtils.unmodifiableSet();
|
||||
assertTrue("set is empty", set1.isEmpty());
|
||||
|
||||
Set<Integer> set2 = SetUtils.unmodifiableSet(1, 2, 2, 3);
|
||||
final Set<Integer> set2 = SetUtils.unmodifiableSet(1, 2, 2, 3);
|
||||
assertEquals("set has 3 elements", 3, set2.size());
|
||||
assertTrue("set contains 1", set2.contains(1));
|
||||
assertTrue("set contains 2", set2.contains(2));
|
||||
assertTrue("set contains 3", set2.contains(3));
|
||||
|
||||
Set<String> set3 = SetUtils.unmodifiableSet("1", "2", "2", "3");
|
||||
final Set<String> set3 = SetUtils.unmodifiableSet("1", "2", "2", "3");
|
||||
assertEquals("set has 3 elements", 3, set3.size());
|
||||
assertTrue("set contains 1", set3.contains("1"));
|
||||
assertTrue("set contains 2", set3.contains("2"));
|
||||
assertTrue("set contains 3", set3.contains("3"));
|
||||
|
||||
Set<?> set4 = SetUtils.unmodifiableSet(null, null);
|
||||
final Set<?> set4 = SetUtils.unmodifiableSet(null, null);
|
||||
assertEquals("set has 1 element", 1, set4.size());
|
||||
assertTrue("set contains null", set4.contains(null));
|
||||
|
||||
Set<?> set5 = SetUtils.unmodifiableSet((Object[]) null);
|
||||
final Set<?> set5 = SetUtils.unmodifiableSet((Object[]) null);
|
||||
assertEquals("set is null", null, set5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnmodifiableSetWrap()
|
||||
{
|
||||
Set<Integer> set1 = SetUtils.unmodifiableSet(1, 2, 2, 3);
|
||||
Set<Integer> set2 = SetUtils.unmodifiableSet(set1);
|
||||
final Set<Integer> set1 = SetUtils.unmodifiableSet(1, 2, 2, 3);
|
||||
final Set<Integer> set2 = SetUtils.unmodifiableSet(set1);
|
||||
assertSame(set1, set2);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,11 +127,11 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void constructorTest_Hasher() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
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);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
long[] lb = bf.getBits();
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
final long[] lb = bf.getBits();
|
||||
assertEquals(0x1FFFF, lb[0]);
|
||||
assertEquals(1, lb.length);
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ public abstract class AbstractBloomFilterTest {
|
|||
@Test
|
||||
public final void constructorTest_Empty() {
|
||||
|
||||
BloomFilter bf = createEmptyFilter(shape);
|
||||
long[] lb = bf.getBits();
|
||||
final BloomFilter bf = createEmptyFilter(shape);
|
||||
final long[] lb = bf.getBits();
|
||||
assertEquals(0, lb.length);
|
||||
}
|
||||
|
||||
|
@ -153,14 +153,14 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void constructorTest_WrongShape() {
|
||||
Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
final Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), anotherShape);
|
||||
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(), anotherShape);
|
||||
try {
|
||||
createFilter(hasher, shape);
|
||||
fail("Should throw IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -171,10 +171,10 @@ public abstract class AbstractBloomFilterTest {
|
|||
@Test
|
||||
public final void cardinalityTest() {
|
||||
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
assertEquals(17, bf.cardinality());
|
||||
}
|
||||
|
||||
|
@ -183,15 +183,15 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void orCardinalityTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
AbstractBloomFilter bf = createFilter(hasher, shape);
|
||||
final AbstractBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), 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 Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
||||
BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
assertEquals(27, bf.orCardinality(bf2));
|
||||
}
|
||||
|
@ -201,15 +201,15 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void orCardinalityTest_ExtraLongs() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
AbstractBloomFilter bf = createFilter(hasher, shape);
|
||||
final AbstractBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
final List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69);
|
||||
final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
||||
AbstractBloomFilter bf2 = createFilter(hasher2, shape);
|
||||
final AbstractBloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
assertEquals(27, bf.orCardinality(bf2));
|
||||
assertEquals(27, bf2.orCardinality(bf));
|
||||
|
@ -220,15 +220,15 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void andCardinalityTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), 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 Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
||||
BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
assertEquals(7, bf.andCardinality(bf2));
|
||||
}
|
||||
|
@ -238,15 +238,15 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void andCardinalityTest_ExtraLongs() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
final List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69);
|
||||
final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
||||
BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
assertEquals(7, bf.andCardinality(bf2));
|
||||
assertEquals(7, bf2.andCardinality(bf));
|
||||
|
@ -257,14 +257,14 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void xorCardinalityTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
BloomFilter bf2 = createFilter(hasher2, 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 Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
assertEquals(20, bf.xorCardinality(bf2));
|
||||
}
|
||||
|
@ -274,14 +274,14 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void xorCardinalityTest_ExtraLongs() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
final List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69);
|
||||
final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
assertEquals(20, bf.xorCardinality(bf2));
|
||||
assertEquals(20, bf2.xorCardinality(bf));
|
||||
|
@ -292,14 +292,14 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void mergeTest_BloomFilter() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
BloomFilter bf2 = createFilter(hasher2, 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 Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
bf.merge(bf2);
|
||||
assertEquals(27, bf.cardinality());
|
||||
|
@ -310,20 +310,20 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void mergeTest_BloomFilter_WrongShape() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), anotherShape);
|
||||
BloomFilter bf2 = createFilter(hasher2, anotherShape);
|
||||
final Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
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(), anotherShape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, anotherShape);
|
||||
|
||||
try {
|
||||
bf.merge(bf2);
|
||||
fail("Should throw IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -333,13 +333,13 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void mergeTest_Hasher() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), 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 Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
||||
bf.merge(hasher2);
|
||||
assertEquals(27, bf.cardinality());
|
||||
|
@ -350,19 +350,19 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void mergeTest_Hasher_WrongShape() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
List<Integer> lst2 = Arrays.asList(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), anotherShape);
|
||||
final Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
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(), anotherShape);
|
||||
|
||||
try {
|
||||
bf.merge(hasher2);
|
||||
fail("Should throw IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ public abstract class AbstractBloomFilterTest {
|
|||
AbstractBloomFilter filter = createEmptyFilter(shape);
|
||||
assertFalse(filter.isFull());
|
||||
|
||||
List<Integer> values = new ArrayList<>(shape.getNumberOfBits());
|
||||
final List<Integer> values = new ArrayList<>(shape.getNumberOfBits());
|
||||
for (int i = 0; i < shape.getNumberOfBits(); i++) {
|
||||
values.add(i);
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ public abstract class AbstractBloomFilterTest {
|
|||
|
||||
assertTrue(filter.isFull());
|
||||
|
||||
int mid = shape.getNumberOfBits() / 2;
|
||||
final int mid = shape.getNumberOfBits() / 2;
|
||||
values.remove(Integer.valueOf(mid));
|
||||
hasher2 = new StaticHasher(values.iterator(), shape);
|
||||
filter = createFilter(hasher2, shape);
|
||||
|
@ -400,17 +400,17 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void containsTest_BloomFilter_WrongShape() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
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 BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
Hasher hasher2 = new StaticHasher(lst.iterator(), anotherShape);
|
||||
BloomFilter bf2 = createFilter(hasher2, anotherShape);
|
||||
final Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
final Hasher hasher2 = new StaticHasher(lst.iterator(), anotherShape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, anotherShape);
|
||||
try {
|
||||
bf.contains(bf2);
|
||||
fail("Should throw IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -420,13 +420,13 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void containsTest_BloomFilter() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
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 BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(4, 5, 6, 7, 8, 9, 10);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
final List<Integer> lst2 = Arrays.asList(4, 5, 6, 7, 8, 9, 10);
|
||||
final Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
assertTrue(bf.contains(bf2));
|
||||
assertFalse(bf2.contains(bf));
|
||||
}
|
||||
|
@ -436,9 +436,9 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void containsTest_Hasher() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
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 BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(4, 5, 6, 7, 8, 9, 10);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
@ -458,18 +458,18 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void containsTest_Hasher_WrongShape() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
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 BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
final Shape anotherShape = new Shape(testFunctionX, 3, 72, 17);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(4, 5, 6, 7, 8, 9, 10);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), anotherShape);
|
||||
final List<Integer> lst2 = Arrays.asList(4, 5, 6, 7, 8, 9, 10);
|
||||
final Hasher hasher2 = new StaticHasher(lst2.iterator(), anotherShape);
|
||||
try {
|
||||
bf.contains(hasher2);
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -480,9 +480,9 @@ public abstract class AbstractBloomFilterTest {
|
|||
* @param hasher1 the first static hasher.
|
||||
* @param hasher2 the second static hasher.
|
||||
*/
|
||||
private void assertSameBits(StaticHasher hasher1, StaticHasher hasher2) {
|
||||
OfInt iter1 = hasher1.getBits(shape);
|
||||
OfInt iter2 = hasher2.getBits(shape);
|
||||
private void assertSameBits(final StaticHasher hasher1, final StaticHasher hasher2) {
|
||||
final OfInt iter1 = hasher1.getBits(shape);
|
||||
final OfInt iter2 = hasher2.getBits(shape);
|
||||
|
||||
while (iter1.hasNext()) {
|
||||
assertTrue("Not enough data in second hasher", iter2.hasNext());
|
||||
|
@ -496,11 +496,11 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void getHasherTest() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
final List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
final StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
StaticHasher hasher2 = bf.getHasher();
|
||||
final StaticHasher hasher2 = bf.getHasher();
|
||||
|
||||
assertEquals(shape, hasher2.getShape());
|
||||
assertSameBits(hasher, hasher2);
|
||||
|
@ -511,10 +511,10 @@ public abstract class AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public final void getBitsTest_SpanLong() {
|
||||
List<Integer> lst = Arrays.asList(63, 64);
|
||||
StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter bf = createFilter(hasher, shape);
|
||||
long[] lb = bf.getBits();
|
||||
final List<Integer> lst = Arrays.asList(63, 64);
|
||||
final StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter bf = createFilter(hasher, shape);
|
||||
final long[] lb = bf.getBits();
|
||||
assertEquals(2, lb.length);
|
||||
assertEquals(0x8000000000000000L, lb[0]);
|
||||
assertEquals(0x1, lb[1]);
|
||||
|
|
|
@ -33,12 +33,12 @@ import org.junit.Test;
|
|||
public class BitSetBloomFilterTest extends AbstractBloomFilterTest {
|
||||
|
||||
@Override
|
||||
protected BitSetBloomFilter createFilter(Hasher hasher, Shape shape) {
|
||||
protected BitSetBloomFilter createFilter(final Hasher hasher, final Shape shape) {
|
||||
return new BitSetBloomFilter( hasher, shape );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BitSetBloomFilter createEmptyFilter(Shape shape) {
|
||||
protected BitSetBloomFilter createEmptyFilter(final Shape shape) {
|
||||
return new BitSetBloomFilter( shape );
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,9 @@ public class BitSetBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void andCardinalityTest_BitSetBloomFilter() {
|
||||
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 );
|
||||
|
||||
BitSetBloomFilter bf = createFilter(hasher, shape);
|
||||
final BitSetBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
Hasher hasher2 = new StaticHasher( Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ).iterator(), shape );
|
||||
BitSetBloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
@ -76,9 +76,9 @@ public class BitSetBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void xorCardinalityTest_BitSetBloomFilter() {
|
||||
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 );
|
||||
|
||||
BitSetBloomFilter bf = createFilter(hasher, shape);
|
||||
final BitSetBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
Hasher hasher2 = new StaticHasher( Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ).iterator(), shape );
|
||||
BitSetBloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
@ -106,14 +106,14 @@ public class BitSetBloomFilterTest extends AbstractBloomFilterTest {
|
|||
@Test
|
||||
public void mergeTest_BitSetBloomFilter() {
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
BitSetBloomFilter bf = createFilter(hasher, shape);
|
||||
final BitSetBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 );
|
||||
Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
BloomFilter bf2 = new BitSetBloomFilter(hasher2, 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 Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
final BloomFilter bf2 = new BitSetBloomFilter(hasher2, shape);
|
||||
|
||||
bf.merge(bf2);
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
|
||||
|
||||
@Override
|
||||
protected CountingBloomFilter createFilter(Hasher hasher, Shape shape) {
|
||||
protected CountingBloomFilter createFilter(final Hasher hasher, final Shape shape) {
|
||||
return new CountingBloomFilter( hasher, shape );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CountingBloomFilter createEmptyFilter(Shape shape) {
|
||||
protected CountingBloomFilter createEmptyFilter(final Shape shape) {
|
||||
return new CountingBloomFilter( shape );
|
||||
}
|
||||
|
||||
|
@ -53,11 +53,11 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void ConstructorTest_HasherValues_CountsTest() {
|
||||
List<Integer> lst = Arrays.asList( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
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 );
|
||||
|
||||
CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
long[] lb = bf.getBits();
|
||||
final CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
final long[] lb = bf.getBits();
|
||||
assertEquals(0x1FFFF, lb[0]);
|
||||
assertEquals(1, lb.length);
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void ConstructorTest_Map_CountsTest() {
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
for (int i =0;i<17;i++)
|
||||
{
|
||||
map.put( i, 1 );
|
||||
|
@ -85,7 +85,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
try {
|
||||
bf = new CountingBloomFilter( map, shape);
|
||||
fail( "Should have thrown IllegalArgumentExceptionW");
|
||||
} catch (IllegalArgumentException exprected)
|
||||
} catch (final IllegalArgumentException exprected)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
try {
|
||||
bf = new CountingBloomFilter( map, shape);
|
||||
fail( "Should have thrown IllegalArgumentExceptionW");
|
||||
} catch (IllegalArgumentException exprected)
|
||||
} catch (final IllegalArgumentException exprected)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
try {
|
||||
bf = new CountingBloomFilter( map, shape);
|
||||
fail( "Should have thrown IllegalArgumentExceptionW");
|
||||
} catch (IllegalArgumentException exprected)
|
||||
} catch (final IllegalArgumentException exprected)
|
||||
{
|
||||
// expected
|
||||
}
|
||||
|
@ -117,19 +117,19 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void mergeTest_Counts() {
|
||||
int[] expected = {
|
||||
final int[] expected = {
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0
|
||||
};
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
final CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 );
|
||||
Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
BloomFilter bf2 = createFilter(hasher2, 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 Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
final BloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
||||
bf.merge(bf2);
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get());
|
||||
assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get());
|
||||
|
||||
Map<Integer, Integer> m = new HashMap<>();
|
||||
final Map<Integer, Integer> m = new HashMap<>();
|
||||
bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue()));
|
||||
for (int i=0;i<29;i++)
|
||||
{
|
||||
|
@ -157,19 +157,19 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void mergeTest_Counts_BitSetFilter() {
|
||||
int[] expected = {
|
||||
final int[] expected = {
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0
|
||||
};
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
final CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 );
|
||||
Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
BloomFilter bf2 = new BitSetBloomFilter(hasher2, 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 Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
final BloomFilter bf2 = new BitSetBloomFilter(hasher2, shape);
|
||||
|
||||
bf.merge(bf2);
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get());
|
||||
assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get());
|
||||
|
||||
Map<Integer, Integer> m = new HashMap<>();
|
||||
final Map<Integer, Integer> m = new HashMap<>();
|
||||
bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue()));
|
||||
for (int i=0;i<29;i++)
|
||||
{
|
||||
|
@ -197,19 +197,19 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void mergeTest_Shape_Hasher_Count() {
|
||||
int[] expected = {
|
||||
final int[] expected = {
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 0
|
||||
};
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
final CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList( 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ,26 ,27 );
|
||||
Hasher hasher2 = new StaticHasher( lst2.iterator(), 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 Hasher hasher2 = new StaticHasher( lst2.iterator(), shape );
|
||||
|
||||
bf.merge(hasher2);
|
||||
|
||||
|
@ -217,7 +217,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
assertEquals(Integer.valueOf(2), bf.getCounts().map(Map.Entry::getValue).max(Integer::compare).get());
|
||||
assertEquals(Integer.valueOf(1), bf.getCounts().map(Map.Entry::getValue).min(Integer::compare).get());
|
||||
|
||||
Map<Integer, Integer> m = new HashMap<>();
|
||||
final Map<Integer, Integer> m = new HashMap<>();
|
||||
bf.getCounts().forEach(e -> m.put(e.getKey(), e.getValue()));
|
||||
for (int i=0;i<29;i++)
|
||||
{
|
||||
|
@ -237,13 +237,13 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
@Test
|
||||
public void mergeTest_Overflow() {
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue()));
|
||||
map.put(1, Integer.MAX_VALUE );
|
||||
|
||||
|
@ -260,7 +260,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
bf.merge(bf2);
|
||||
fail( "Should have thrown IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException expected)
|
||||
catch (final IllegalStateException expected)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -271,26 +271,26 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void removeTest_Standard() {
|
||||
int[] values = {
|
||||
final int[] values = {
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
for (int i=1;i<values.length;i++)
|
||||
{
|
||||
map.put( i, values[i] );
|
||||
}
|
||||
|
||||
CountingBloomFilter bf = new CountingBloomFilter( map, shape );
|
||||
final CountingBloomFilter bf = new CountingBloomFilter( map, shape );
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
BitSetBloomFilter bf2 = new BitSetBloomFilter( hasher, 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
final BitSetBloomFilter bf2 = new BitSetBloomFilter( hasher, shape );
|
||||
|
||||
bf.remove( bf2 );
|
||||
assertEquals( 17, bf.cardinality() );
|
||||
Map<Integer,Integer> map2 = new HashMap<>();
|
||||
final Map<Integer,Integer> map2 = new HashMap<>();
|
||||
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue()));
|
||||
|
||||
for (int i = 11; i<values.length; i++ )
|
||||
|
@ -306,26 +306,26 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void removeTest_Counting() {
|
||||
int[] values = {
|
||||
final int[] values = {
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
for (int i=1;i<values.length;i++)
|
||||
{
|
||||
map.put( i, values[i] );
|
||||
}
|
||||
|
||||
CountingBloomFilter bf = new CountingBloomFilter( map, shape );
|
||||
final CountingBloomFilter bf = new CountingBloomFilter( map, shape );
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
BloomFilter bf2 = new CountingBloomFilter( hasher, 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
final BloomFilter bf2 = new CountingBloomFilter( hasher, shape );
|
||||
|
||||
bf.remove( bf2 );
|
||||
assertEquals( 17, bf.cardinality() );
|
||||
Map<Integer,Integer> map2 = new HashMap<>();
|
||||
final Map<Integer,Integer> map2 = new HashMap<>();
|
||||
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue()));
|
||||
|
||||
for (int i = 11; i<values.length; i++ )
|
||||
|
@ -342,13 +342,13 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
@Test
|
||||
public void removeTest_Underflow() {
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
CountingBloomFilter bf = createFilter(hasher, shape);
|
||||
|
||||
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
bf.getCounts().forEach( e -> map.put( e.getKey(), e.getValue()));
|
||||
map.remove(1);
|
||||
|
||||
|
@ -365,7 +365,7 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
bf.remove(bf2);
|
||||
fail( "Should have thrown IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException expected)
|
||||
catch (final IllegalStateException expected)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -376,26 +376,26 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void removeTest_Hasher() {
|
||||
int[] values = {
|
||||
final int[] values = {
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 2, 2, 2, 2, 2, 2, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1
|
||||
};
|
||||
Map<Integer,Integer> map = new HashMap<>();
|
||||
final Map<Integer,Integer> map = new HashMap<>();
|
||||
for (int i=1;i<values.length;i++)
|
||||
{
|
||||
map.put( i, values[i] );
|
||||
}
|
||||
|
||||
CountingBloomFilter bf = new CountingBloomFilter( map, shape );
|
||||
final CountingBloomFilter bf = new CountingBloomFilter( map, shape );
|
||||
|
||||
List<Integer> lst = Arrays.asList( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ,16 ,17 );
|
||||
Hasher hasher = new StaticHasher( lst.iterator(), 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 Hasher hasher = new StaticHasher( lst.iterator(), shape );
|
||||
|
||||
|
||||
bf.remove( hasher );
|
||||
assertEquals( 17, bf.cardinality() );
|
||||
Map<Integer,Integer> map2 = new HashMap<>();
|
||||
final Map<Integer,Integer> map2 = new HashMap<>();
|
||||
bf.getCounts().forEach( e -> map2.put( e.getKey(), e.getValue()));
|
||||
|
||||
for (int i = 11; i<values.length; i++ )
|
||||
|
@ -412,9 +412,9 @@ public class CountingBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void andCardinalityTest_CountingBloomFilter() {
|
||||
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 );
|
||||
|
||||
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 );
|
||||
CountingBloomFilter bf2 = createFilter(hasher2, shape);
|
||||
|
|
|
@ -31,12 +31,12 @@ import org.apache.commons.collections4.bloomfilter.hasher.StaticHasher;
|
|||
public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
||||
|
||||
@Override
|
||||
protected AbstractBloomFilter createFilter(Hasher hasher, Shape shape) {
|
||||
protected AbstractBloomFilter createFilter(final Hasher hasher, final Shape shape) {
|
||||
return new BF( hasher, shape );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractBloomFilter createEmptyFilter(Shape shape) {
|
||||
protected AbstractBloomFilter createEmptyFilter(final Shape shape) {
|
||||
return new BF( shape );
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
|||
/**
|
||||
* The bitset that defines this BloomFilter.
|
||||
*/
|
||||
private BitSet bitSet;
|
||||
private final BitSet bitSet;
|
||||
|
||||
/**
|
||||
* Constructs a BitSetBloomFilter from a hasher and a shape.
|
||||
|
@ -57,7 +57,7 @@ public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
|||
* @param hasher the Hasher to use.
|
||||
* @param shape the desired shape of the filter.
|
||||
*/
|
||||
public BF(Hasher hasher, Shape shape) {
|
||||
public BF(final Hasher hasher, final Shape shape) {
|
||||
this(shape);
|
||||
verifyHasher(hasher);
|
||||
hasher.getBits(shape).forEachRemaining((IntConsumer) bitSet::set);
|
||||
|
@ -68,7 +68,7 @@ public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
|||
*
|
||||
* @param shape the desired shape of the filter.
|
||||
*/
|
||||
public BF(Shape shape) {
|
||||
public BF(final Shape shape) {
|
||||
super(shape);
|
||||
this.bitSet = new BitSet();
|
||||
}
|
||||
|
@ -84,13 +84,13 @@ public class DefaultBloomFilterMethodsTest extends AbstractBloomFilterTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void merge(BloomFilter other) {
|
||||
public void merge(final BloomFilter other) {
|
||||
verifyShape(other);
|
||||
bitSet.or(BitSet.valueOf(other.getBits()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(Hasher hasher) {
|
||||
public void merge(final Hasher hasher) {
|
||||
verifyHasher( hasher );
|
||||
hasher.getBits(getShape()).forEachRemaining((IntConsumer) bitSet::set);
|
||||
}
|
||||
|
|
|
@ -34,12 +34,12 @@ public class HasherBloomFilterTest extends AbstractBloomFilterTest {
|
|||
|
||||
|
||||
@Override
|
||||
protected HasherBloomFilter createFilter(Hasher hasher, Shape shape) {
|
||||
protected HasherBloomFilter createFilter(final Hasher hasher, final Shape shape) {
|
||||
return new HasherBloomFilter( hasher, shape );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractBloomFilter createEmptyFilter(Shape shape) {
|
||||
protected AbstractBloomFilter createEmptyFilter(final Shape shape) {
|
||||
return new HasherBloomFilter( shape );
|
||||
}
|
||||
|
||||
|
@ -49,10 +49,10 @@ public class HasherBloomFilterTest extends AbstractBloomFilterTest {
|
|||
*/
|
||||
@Test
|
||||
public void constructorTest_NonStatic() throws NoSuchAlgorithmException {
|
||||
Shape shape = new Shape( new MD5Cyclic(), 3, 72, 17 );
|
||||
DynamicHasher hasher = new DynamicHasher.Builder( new MD5Cyclic() ).with( "Hello").build();
|
||||
HasherBloomFilter filter = createFilter( hasher, shape );
|
||||
long[] lb = filter.getBits();
|
||||
final Shape shape = new Shape( new MD5Cyclic(), 3, 72, 17 );
|
||||
final DynamicHasher hasher = new DynamicHasher.Builder( new MD5Cyclic() ).with( "Hello").build();
|
||||
final HasherBloomFilter filter = createFilter( hasher, shape );
|
||||
final long[] lb = filter.getBits();
|
||||
assertEquals( 2, lb.length );
|
||||
assertEquals( 0x6203101001888c44L, lb[0]);
|
||||
assertEquals( 0x60L, lb[1]);
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class SetOperationsTest {
|
||||
|
||||
private HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
private final HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -60,7 +60,7 @@ public class SetOperationsTest {
|
|||
}
|
||||
};
|
||||
|
||||
private Shape shape = new Shape(testFunction, 3, 72, 17);
|
||||
private final Shape shape = new Shape(testFunction, 3, 72, 17);
|
||||
|
||||
/**
|
||||
* Tests that the size estimate is correctly calculated.
|
||||
|
@ -82,8 +82,8 @@ public class SetOperationsTest {
|
|||
|
||||
lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
|
||||
26, 27, 28, 29, 30, 31, 32, 33);
|
||||
Hasher hasher2 = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(hasher2, shape);
|
||||
final Hasher hasher2 = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(hasher2, shape);
|
||||
|
||||
assertEquals(3, SetOperations.estimateSize(filter2));
|
||||
|
||||
|
@ -96,15 +96,15 @@ public class SetOperationsTest {
|
|||
public final void estimateUnionSizeTest() {
|
||||
// build a filter
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
final Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
|
||||
lst = Arrays.asList(17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40);
|
||||
Hasher hasher2 = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(hasher2, shape);
|
||||
final Hasher hasher2 = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(hasher2, shape);
|
||||
|
||||
long estimate = SetOperations.estimateUnionSize(filter1, filter2);
|
||||
final long estimate = SetOperations.estimateUnionSize(filter1, filter2);
|
||||
assertEquals(3, estimate);
|
||||
|
||||
}
|
||||
|
@ -116,15 +116,15 @@ public class SetOperationsTest {
|
|||
public final void estimateIntersectionSizeTest() {
|
||||
// build a filter
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
final Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
|
||||
lst = Arrays.asList(8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||
31, 32, 33, 34, 35, 36, 37, 38, 39, 40);
|
||||
Hasher hasher2 = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(hasher2, shape);
|
||||
final Hasher hasher2 = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(hasher2, shape);
|
||||
|
||||
long estimate = SetOperations.estimateIntersectionSize(filter1, filter2);
|
||||
final long estimate = SetOperations.estimateIntersectionSize(filter1, filter2);
|
||||
assertEquals(1, estimate);
|
||||
|
||||
}
|
||||
|
@ -134,9 +134,9 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void hammingDistanceTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter1 = new HasherBloomFilter(hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
@ -159,9 +159,9 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void jaccardSimilarityTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter1 = new HasherBloomFilter(hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
@ -184,12 +184,12 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void jaccardSimilarityTest_NoValues() {
|
||||
BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
// build a filter
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter3 = new HasherBloomFilter( hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape );
|
||||
|
||||
assertEquals(0.0, SetOperations.jaccardSimilarity(filter1, filter2), 0.0001);
|
||||
assertEquals(0.0, SetOperations.jaccardSimilarity(filter2, filter1), 0.0001);
|
||||
|
@ -204,9 +204,9 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void jaccardDistanceTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter1 = new HasherBloomFilter(hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
@ -230,12 +230,12 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void jaccardDistanceTest_NoValues() {
|
||||
BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
// build a filter
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter3 = new HasherBloomFilter( hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape );
|
||||
|
||||
assertEquals(1.0, SetOperations.jaccardDistance(filter1, filter2), 0.0001);
|
||||
assertEquals(1.0, SetOperations.jaccardDistance(filter2, filter1), 0.0001);
|
||||
|
@ -250,9 +250,9 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void cosineSimilarityTest() {
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter1 = new HasherBloomFilter(hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(hasher, shape);
|
||||
|
||||
List<Integer> lst2 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher2 = new StaticHasher(lst2.iterator(), shape);
|
||||
|
@ -276,12 +276,12 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void cosineSimilarityTest_NoValues() {
|
||||
BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
// build a filter
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter3 = new HasherBloomFilter( hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape );
|
||||
|
||||
assertEquals(0.0, SetOperations.cosineSimilarity(filter1, filter2), 0.0001);
|
||||
assertEquals(0.0, SetOperations.cosineSimilarity(filter2, filter1), 0.0001);
|
||||
|
@ -332,12 +332,12 @@ public class SetOperationsTest {
|
|||
*/
|
||||
@Test
|
||||
public final void cosineDistanceTest_NoValues() {
|
||||
BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter1 = new HasherBloomFilter(shape);
|
||||
final BloomFilter filter2 = new HasherBloomFilter(shape);
|
||||
// build a filter
|
||||
List<Integer> lst = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17);
|
||||
Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
BloomFilter filter3 = new HasherBloomFilter( hasher, 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 Hasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final BloomFilter filter3 = new HasherBloomFilter( hasher, shape );
|
||||
|
||||
assertEquals(1.0, SetOperations.cosineDistance(filter1, filter2), 0.0001);
|
||||
assertEquals(1.0, SetOperations.cosineDistance(filter2, filter1), 0.0001);
|
||||
|
|
|
@ -35,11 +35,11 @@ import org.junit.Test;
|
|||
*/
|
||||
public class CommonComparatorTest {
|
||||
|
||||
private void assertBefore(HashFunctionIdentity identity1, HashFunctionIdentity identity2) {
|
||||
private void assertBefore(final HashFunctionIdentity identity1, final HashFunctionIdentity identity2) {
|
||||
assertTrue(0 > HashFunctionIdentity.COMMON_COMPARATOR.compare(identity1, identity2));
|
||||
}
|
||||
|
||||
private void assertAfter(HashFunctionIdentity identity1, HashFunctionIdentity identity2) {
|
||||
private void assertAfter(final HashFunctionIdentity identity1, final HashFunctionIdentity identity2) {
|
||||
assertTrue(0 < HashFunctionIdentity.COMMON_COMPARATOR.compare(identity1, identity2));
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class CommonComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void nameOrderTestDifferentNames() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl2", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl2", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -64,9 +64,9 @@ public class CommonComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void nameOrderTestDifferentCapitalization() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "IMPL1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "IMPL1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertEquals(0, HashFunctionIdentity.COMMON_COMPARATOR.compare(impl1, impl2));
|
||||
|
@ -78,9 +78,9 @@ public class CommonComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void signednessOrder() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.UNSIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.UNSIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -94,9 +94,9 @@ public class CommonComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void processTypeOrder() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.ITERATIVE, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -110,9 +110,9 @@ public class CommonComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void producerDoesNotChangeOrder() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite2", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite2", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertEquals(0, HashFunctionIdentity.COMMON_COMPARATOR.compare(impl1, impl2));
|
||||
|
@ -124,9 +124,9 @@ public class CommonComparatorTest {
|
|||
@Test
|
||||
public void testSortOrder() {
|
||||
// in this test the signature is the position in the final collection for the ID
|
||||
TreeSet<HashFunctionIdentity> result = new TreeSet<>(
|
||||
final TreeSet<HashFunctionIdentity> result = new TreeSet<>(
|
||||
HashFunctionIdentity.COMMON_COMPARATOR);
|
||||
List<HashFunctionIdentity> collection = new ArrayList<>();
|
||||
final List<HashFunctionIdentity> collection = new ArrayList<>();
|
||||
|
||||
collection
|
||||
.add(new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED, ProcessType.CYCLIC, 0));
|
||||
|
@ -156,7 +156,7 @@ public class CommonComparatorTest {
|
|||
|
||||
result.addAll(collection);
|
||||
long idx = 0;
|
||||
for (HashFunctionIdentity id : result) {
|
||||
for (final HashFunctionIdentity id : result) {
|
||||
assertEquals("Unexpected order for " + HashFunctionIdentity.asCommonString(id), idx++, id.getSignature());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ import org.junit.Test;
|
|||
*/
|
||||
public class DeepComparatorTest {
|
||||
|
||||
private void assertBefore(HashFunctionIdentity identity1, HashFunctionIdentity identity2) {
|
||||
private void assertBefore(final HashFunctionIdentity identity1, final HashFunctionIdentity identity2) {
|
||||
assertTrue(0 > HashFunctionIdentity.DEEP_COMPARATOR.compare(identity1, identity2));
|
||||
}
|
||||
|
||||
private void assertAfter(HashFunctionIdentity identity1, HashFunctionIdentity identity2) {
|
||||
private void assertAfter(final HashFunctionIdentity identity1, final HashFunctionIdentity identity2) {
|
||||
assertTrue(0 < HashFunctionIdentity.DEEP_COMPARATOR.compare(identity1, identity2));
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class DeepComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void nameOrderTestDifferentNames() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl2", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl2", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -64,9 +64,9 @@ public class DeepComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void nameOrderTestDifferentCapitalization() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "IMPL1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "IMPL1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertEquals(0, HashFunctionIdentity.DEEP_COMPARATOR.compare(impl1, impl2));
|
||||
|
@ -78,9 +78,9 @@ public class DeepComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void signednessOrder() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.UNSIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.UNSIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -94,9 +94,9 @@ public class DeepComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void processTypeOrder() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.ITERATIVE, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -110,9 +110,9 @@ public class DeepComparatorTest {
|
|||
*/
|
||||
@Test
|
||||
public void producerOrder() {
|
||||
HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl1 = new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite2", "impl1", Signedness.SIGNED,
|
||||
final HashFunctionIdentityImpl impl2 = new HashFunctionIdentityImpl("Testing Suite2", "impl1", Signedness.SIGNED,
|
||||
ProcessType.CYCLIC, 300L);
|
||||
|
||||
assertBefore(impl1, impl2);
|
||||
|
@ -127,8 +127,8 @@ public class DeepComparatorTest {
|
|||
@Test
|
||||
public void testSortOrder() {
|
||||
// in this test the signature is the position in the final collection for the ID
|
||||
TreeSet<HashFunctionIdentity> result = new TreeSet<>(HashFunctionIdentity.DEEP_COMPARATOR);
|
||||
List<HashFunctionIdentity> collection = new ArrayList<>();
|
||||
final TreeSet<HashFunctionIdentity> result = new TreeSet<>(HashFunctionIdentity.DEEP_COMPARATOR);
|
||||
final List<HashFunctionIdentity> collection = new ArrayList<>();
|
||||
|
||||
collection
|
||||
.add(new HashFunctionIdentityImpl("Testing Suite", "impl1", Signedness.SIGNED, ProcessType.CYCLIC, 0));
|
||||
|
@ -182,7 +182,7 @@ public class DeepComparatorTest {
|
|||
|
||||
result.addAll(collection);
|
||||
long idx = 0;
|
||||
for (HashFunctionIdentity id : result) {
|
||||
for (final HashFunctionIdentity id : result) {
|
||||
assertEquals("Unexpected order for " + id.getProvider() + ":" + HashFunctionIdentity.asCommonString(id),
|
||||
idx++, id.getSignature());
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.junit.Test;
|
|||
public class DynamicHasherBuilderTest {
|
||||
|
||||
private DynamicHasher.Builder builder;
|
||||
private Shape shape = new Shape( new MD5Cyclic(), 1, Integer.MAX_VALUE, 1 );
|
||||
private final Shape shape = new Shape( new MD5Cyclic(), 1, Integer.MAX_VALUE, 1 );
|
||||
|
||||
/**
|
||||
* Sets up the builder for testing.
|
||||
|
@ -52,11 +52,11 @@ public class DynamicHasherBuilderTest {
|
|||
*/
|
||||
@Test
|
||||
public void buildTest_byte() {
|
||||
DynamicHasher hasher = builder.with((byte) 0x1).build();
|
||||
final DynamicHasher hasher = builder.with((byte) 0x1).build();
|
||||
|
||||
int expected = 1483089307;
|
||||
final int expected = 1483089307;
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals( expected, iter.nextInt() );
|
||||
|
@ -68,10 +68,10 @@ public class DynamicHasherBuilderTest {
|
|||
*/
|
||||
@Test
|
||||
public void buildTest_byteArray() {
|
||||
DynamicHasher hasher = builder.with("Hello".getBytes()).build();
|
||||
int expected = 1519797563;
|
||||
final DynamicHasher hasher = builder.with("Hello".getBytes()).build();
|
||||
final int expected = 1519797563;
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals( expected, iter.nextInt() );
|
||||
|
@ -84,10 +84,10 @@ public class DynamicHasherBuilderTest {
|
|||
*/
|
||||
@Test
|
||||
public void buildTest_String() {
|
||||
DynamicHasher hasher = builder.with("Hello").build();
|
||||
int expected = 1519797563;
|
||||
final DynamicHasher hasher = builder.with("Hello").build();
|
||||
final int expected = 1519797563;
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals( expected, iter.nextInt() );
|
||||
|
@ -99,9 +99,9 @@ public class DynamicHasherBuilderTest {
|
|||
*/
|
||||
@Test
|
||||
public void buildTest_Empty() {
|
||||
DynamicHasher hasher = builder.build();
|
||||
final DynamicHasher hasher = builder.build();
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
|
||||
assertFalse(iter.hasNext());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class DynamicHasherTest {
|
|||
private DynamicHasher.Builder builder;
|
||||
private Shape shape;
|
||||
|
||||
private HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
private final HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -82,11 +82,11 @@ public class DynamicHasherTest {
|
|||
@Test
|
||||
public void testGetBits() {
|
||||
|
||||
int[] expected = {6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 11, 2, 49, 24, 15, 62};
|
||||
final int[] expected = {6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 11, 2, 49, 24, 15, 62};
|
||||
|
||||
Hasher hasher = builder.with("Hello").build();
|
||||
final Hasher hasher = builder.with("Hello").build();
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
assertTrue(iter.hasNext());
|
||||
|
@ -101,12 +101,12 @@ public class DynamicHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testGetBits_MultipleHashes() {
|
||||
int[] expected = {6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7, 69,
|
||||
final int[] expected = {6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7, 69,
|
||||
59, 49, 39, 13, 3, 65, 55, 45, 35, 25};
|
||||
|
||||
Hasher hasher = builder.with("Hello").with("World").build();
|
||||
final Hasher hasher = builder.with("Hello").with("World").build();
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
assertTrue(iter.hasNext());
|
||||
|
@ -122,12 +122,12 @@ public class DynamicHasherTest {
|
|||
@Test
|
||||
public void testGetBits_WongShape() {
|
||||
|
||||
Hasher hasher = builder.with("Hello").build();
|
||||
final Hasher hasher = builder.with("Hello").build();
|
||||
|
||||
try {
|
||||
hasher.getBits(new Shape(testFunction, 3, 72, 17));
|
||||
fail("Should have thown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class HashFunctionIdentityImplTest {
|
|||
*/
|
||||
@Test
|
||||
public void copyConstructorTest() {
|
||||
HashFunctionIdentity identity = new HashFunctionIdentity() {
|
||||
final HashFunctionIdentity identity = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -62,7 +62,7 @@ public class HashFunctionIdentityImplTest {
|
|||
}
|
||||
|
||||
};
|
||||
HashFunctionIdentityImpl impl = new HashFunctionIdentityImpl( identity );
|
||||
final HashFunctionIdentityImpl impl = new HashFunctionIdentityImpl( identity );
|
||||
assertEquals( "NAME", impl.getName());
|
||||
assertEquals( "Provider", impl.getProvider());
|
||||
assertEquals( Signedness.SIGNED, impl.getSignedness());
|
||||
|
@ -80,7 +80,7 @@ public class HashFunctionIdentityImplTest {
|
|||
*/
|
||||
@Test
|
||||
public void valuesConstructorTest() {
|
||||
HashFunctionIdentityImpl impl = new HashFunctionIdentityImpl( "Provider", "NAME",
|
||||
final HashFunctionIdentityImpl impl = new HashFunctionIdentityImpl( "Provider", "NAME",
|
||||
Signedness.UNSIGNED, ProcessType.ITERATIVE, -2l);
|
||||
assertEquals( "NAME", impl.getName());
|
||||
assertEquals( "Provider", impl.getProvider());
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.junit.Test;
|
|||
public class ShapeTest {
|
||||
|
||||
|
||||
private HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
private final HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -74,7 +74,7 @@ public class ShapeTest {
|
|||
*/
|
||||
|
||||
|
||||
private Shape shape = new Shape(testFunction, 5, 0.1);
|
||||
private final Shape shape = new Shape(testFunction, 5, 0.1);
|
||||
|
||||
/**
|
||||
* Tests that the constructor with a null name, number of items, and probability fails.
|
||||
|
@ -86,7 +86,7 @@ public class ShapeTest {
|
|||
new Shape(null, 5, 0.1);
|
||||
fail( "Should throw IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException expected)
|
||||
catch (final IllegalArgumentException expected)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class ShapeTest {
|
|||
new Shape(null, 5, 72);
|
||||
fail( "Should throw IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException expected)
|
||||
catch (final IllegalArgumentException expected)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class ShapeTest {
|
|||
new Shape(null, 5, 72, 17);
|
||||
fail( "Should throw IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException expected)
|
||||
catch (final IllegalArgumentException expected)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class ShapeTest {
|
|||
new Shape(null, 0.1, 72, 17);
|
||||
fail( "Should throw IllegalArgumentException");
|
||||
}
|
||||
catch (IllegalArgumentException expected)
|
||||
catch (final IllegalArgumentException expected)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape( testFunction, Integer.MAX_VALUE, 1.0 / 10);
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape( testFunction, 0, 1.0 / 10);
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -193,14 +193,14 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 10, 0.0);
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
try {
|
||||
new Shape(testFunction, 10, 1.0);
|
||||
fail("Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public class ShapeTest {
|
|||
/*
|
||||
* values from https://hur.st/bloomfilter/?n=5&m=24
|
||||
*/
|
||||
Shape filterConfig = new Shape(testFunction, 5, 24);
|
||||
final Shape filterConfig = new Shape(testFunction, 5, 24);
|
||||
|
||||
assertEquals(24, filterConfig.getNumberOfBits());
|
||||
assertEquals(3, filterConfig.getNumberOfBytes());
|
||||
|
@ -233,7 +233,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 0, 24);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 5, 6);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 16,8);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public class ShapeTest {
|
|||
/*
|
||||
* values from https://hur.st/bloomfilter/?n=5&m=24&k=4
|
||||
*/
|
||||
Shape filterConfig = new Shape(testFunction, 5, 24, 4);
|
||||
final Shape filterConfig = new Shape(testFunction, 5, 24, 4);
|
||||
|
||||
assertEquals(24, filterConfig.getNumberOfBits());
|
||||
assertEquals(3, filterConfig.getNumberOfBytes());
|
||||
|
@ -295,7 +295,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 0, 24, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 5, 6, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 5, 24, 0);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 4000,8,1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ public class ShapeTest {
|
|||
/*
|
||||
* values from https://hur.st/bloomfilter/?n=5&p=.1&m=&k=
|
||||
*/
|
||||
Shape filterConfig = new Shape(testFunction, 0.1, 24, 3);
|
||||
final Shape filterConfig = new Shape(testFunction, 0.1, 24, 3);
|
||||
|
||||
assertEquals(24, filterConfig.getNumberOfBits());
|
||||
assertEquals(3, filterConfig.getNumberOfBytes());
|
||||
|
@ -373,7 +373,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 0.0, 24, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, -1.0, 24, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, -1.5, 24, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 1.0, 24, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 2.0, 24, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 0.5, 6, 1);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ public class ShapeTest {
|
|||
try {
|
||||
new Shape(testFunction, 0.5, 24, 0);
|
||||
fail( "Should have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected)
|
||||
} catch (final IllegalArgumentException expected)
|
||||
{
|
||||
//expected
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ public class ShapeTest {
|
|||
assertNotEquals(new Shape(testFunction, 5, 1.0 / 11), shape);
|
||||
assertNotEquals(new Shape(testFunction, 4, 1.0 / 10), shape);
|
||||
|
||||
HashFunctionIdentity testFunction2 = new HashFunctionIdentity() {
|
||||
final HashFunctionIdentity testFunction2 = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -489,7 +489,7 @@ public class ShapeTest {
|
|||
*/
|
||||
@Test
|
||||
public void hashCodeTest() {
|
||||
int hashCode = Objects.hash(testFunction, 24, 3 );
|
||||
final int hashCode = Objects.hash(testFunction, 24, 3 );
|
||||
assertEquals(hashCode, shape.hashCode());
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class StaticHasherTest {
|
||||
|
||||
private HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
private final HashFunctionIdentity testFunction = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -63,7 +63,7 @@ public class StaticHasherTest {
|
|||
}
|
||||
};
|
||||
|
||||
private HashFunctionIdentity testFunctionX = new HashFunctionIdentity() {
|
||||
private final HashFunctionIdentity testFunctionX = new HashFunctionIdentity() {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -91,18 +91,18 @@ public class StaticHasherTest {
|
|||
}
|
||||
};
|
||||
|
||||
private Shape shape = new Shape(testFunction, 3, 72, 17);
|
||||
private final Shape shape = new Shape(testFunction, 3, 72, 17);
|
||||
|
||||
/**
|
||||
* Tests that getBits returns the proper values.
|
||||
*/
|
||||
@Test
|
||||
public void testGetBits() {
|
||||
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);
|
||||
|
||||
StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
assertEquals(17, hasher.size());
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
for (int i = 0; i < 17; i++) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(i, iter.nextInt());
|
||||
|
@ -116,14 +116,14 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testGetBits_DuplicateValues() {
|
||||
int[] input = {6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7, 69, 59,
|
||||
final int[] input = {6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7, 69, 59,
|
||||
49, 39, 13, 3, 65, 55, 45, 35, 25};
|
||||
int[] expected = {1, 2, 3, 6, 7, 10, 11, 13, 15, 17, 19, 23, 24, 25, 35, 36, 39, 43, 44, 45, 48, 49, 53, 55, 57,
|
||||
final int[] expected = {1, 2, 3, 6, 7, 10, 11, 13, 15, 17, 19, 23, 24, 25, 35, 36, 39, 43, 44, 45, 48, 49, 53, 55, 57,
|
||||
59, 61, 62, 63, 65, 69, 70};
|
||||
|
||||
StaticHasher hasher = new StaticHasher(Arrays.stream(input).iterator(), shape);
|
||||
final StaticHasher hasher = new StaticHasher(Arrays.stream(input).iterator(), shape);
|
||||
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(expected[i], iter.nextInt());
|
||||
|
@ -136,13 +136,13 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testGetBits_WrongShape() {
|
||||
List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
final List<Integer> lst = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
final StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
try {
|
||||
hasher.getBits(new Shape(testFunctionX, 3, 72, 17));
|
||||
fail("Should have thown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,9 @@ public class StaticHasherTest {
|
|||
@Test
|
||||
public void testConstructor_Iterator() {
|
||||
|
||||
int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
final int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
StaticHasher hasher = new StaticHasher(iter, shape);
|
||||
final StaticHasher hasher = new StaticHasher(iter, shape);
|
||||
|
||||
assertEquals(5, hasher.size());
|
||||
assertEquals(shape, hasher.getShape());
|
||||
|
@ -178,12 +178,12 @@ public class StaticHasherTest {
|
|||
@Test
|
||||
public void testConstructor_Iterator_ValueTooBig() {
|
||||
|
||||
int[] values = {shape.getNumberOfBits(), 3, 5, 7, 9, 3, 5, 1};
|
||||
Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
final int[] values = {shape.getNumberOfBits(), 3, 5, 7, 9, 3, 5, 1};
|
||||
final Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
try {
|
||||
new StaticHasher(iter, shape);
|
||||
fail("Should have thown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -195,12 +195,12 @@ public class StaticHasherTest {
|
|||
@Test
|
||||
public void testConstructor_Iterator_ValueTooSmall() {
|
||||
|
||||
int[] values = {-1, 3, 5, 7, 9, 3, 5, 1};
|
||||
Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
final int[] values = {-1, 3, 5, 7, 9, 3, 5, 1};
|
||||
final Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
try {
|
||||
new StaticHasher(iter, shape);
|
||||
fail("Should have thown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -211,9 +211,9 @@ public class StaticHasherTest {
|
|||
* @param hasher1 the first static hasher.
|
||||
* @param hasher2 the second static hasher.
|
||||
*/
|
||||
private void assertSameBits(StaticHasher hasher1, StaticHasher hasher2) {
|
||||
OfInt iter1 = hasher1.getBits(shape);
|
||||
OfInt iter2 = hasher2.getBits(shape);
|
||||
private void assertSameBits(final StaticHasher hasher1, final StaticHasher hasher2) {
|
||||
final OfInt iter1 = hasher1.getBits(shape);
|
||||
final OfInt iter2 = hasher2.getBits(shape);
|
||||
|
||||
while (iter1.hasNext()) {
|
||||
assertTrue("Not enough data in second hasher", iter2.hasNext());
|
||||
|
@ -227,11 +227,11 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstructor_StaticHasher() {
|
||||
int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
StaticHasher hasher = new StaticHasher(iter, shape);
|
||||
final int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
final Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
final StaticHasher hasher = new StaticHasher(iter, shape);
|
||||
|
||||
StaticHasher hasher2 = new StaticHasher(hasher, shape);
|
||||
final StaticHasher hasher2 = new StaticHasher(hasher, shape);
|
||||
assertEquals(shape, hasher2.getShape());
|
||||
assertSameBits(hasher, hasher2);
|
||||
|
||||
|
@ -243,14 +243,14 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstructor_StaticHasher_WrongShape() {
|
||||
int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
StaticHasher hasher = new StaticHasher(iter, new Shape(testFunctionX, 3, 72, 17));
|
||||
final int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
final Iterator<Integer> iter = Arrays.stream(values).iterator();
|
||||
final StaticHasher hasher = new StaticHasher(iter, new Shape(testFunctionX, 3, 72, 17));
|
||||
|
||||
try {
|
||||
new StaticHasher(hasher, shape);
|
||||
fail("Should have thown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -261,9 +261,9 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstructor_Hasher() {
|
||||
int[] expected = {1, 3, 5, 7, 9};
|
||||
final int[] expected = {1, 3, 5, 7, 9};
|
||||
|
||||
Hasher testHasher = new Hasher() {
|
||||
final Hasher testHasher = new Hasher() {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() { return false; }
|
||||
|
@ -274,14 +274,14 @@ public class StaticHasherTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OfInt getBits(Shape shape) {
|
||||
int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
public OfInt getBits(final Shape shape) {
|
||||
final int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
return Arrays.stream(values).iterator();
|
||||
}
|
||||
};
|
||||
|
||||
StaticHasher hasher = new StaticHasher(testHasher, shape);
|
||||
OfInt iter = hasher.getBits(shape);
|
||||
final StaticHasher hasher = new StaticHasher(testHasher, shape);
|
||||
final OfInt iter = hasher.getBits(shape);
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
assertTrue(iter.hasNext());
|
||||
assertEquals(expected[i], iter.nextInt());
|
||||
|
@ -295,7 +295,7 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testConstructor_Hasher_WrongShape() {
|
||||
Hasher testHasher = new Hasher() {
|
||||
final Hasher testHasher = new Hasher() {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() { return false; }
|
||||
|
@ -306,8 +306,8 @@ public class StaticHasherTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OfInt getBits(Shape shape) {
|
||||
int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
public OfInt getBits(final Shape shape) {
|
||||
final int[] values = {1, 3, 5, 7, 9, 3, 5, 1};
|
||||
return Arrays.stream(values).iterator();
|
||||
}
|
||||
};
|
||||
|
@ -315,7 +315,7 @@ public class StaticHasherTest {
|
|||
try {
|
||||
new StaticHasher(testHasher, shape);
|
||||
fail("Should have thown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
} catch (final IllegalArgumentException expected) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public class StaticHasherTest {
|
|||
*/
|
||||
@Test
|
||||
public void testIsEmpty() {
|
||||
List<Integer> lst = new ArrayList<>();
|
||||
final List<Integer> lst = new ArrayList<>();
|
||||
StaticHasher hasher = new StaticHasher(lst.iterator(), shape);
|
||||
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ public class MD5CyclicTest {
|
|||
*/
|
||||
@Test
|
||||
public void applyTest() {
|
||||
MD5Cyclic md5 = new MD5Cyclic();
|
||||
long l1 = 0x8b1a9953c4611296L;
|
||||
long l2 = 0xa827abf8c47804d7L;
|
||||
byte[] buffer = "Hello".getBytes();
|
||||
final MD5Cyclic md5 = new MD5Cyclic();
|
||||
final long l1 = 0x8b1a9953c4611296L;
|
||||
final long l2 = 0xa827abf8c47804d7L;
|
||||
final byte[] buffer = "Hello".getBytes();
|
||||
|
||||
long l = md5.apply(buffer, 0);
|
||||
assertEquals(l1, l);
|
||||
|
@ -54,10 +54,10 @@ public class MD5CyclicTest {
|
|||
*/
|
||||
@Test
|
||||
public void signatureTest() {
|
||||
MD5Cyclic md5 = new MD5Cyclic();
|
||||
String arg = String.format("%s-%s-%s", md5.getName().toUpperCase(Locale.ROOT), md5.getSignedness(),
|
||||
final MD5Cyclic md5 = new MD5Cyclic();
|
||||
final String arg = String.format("%s-%s-%s", md5.getName().toUpperCase(Locale.ROOT), md5.getSignedness(),
|
||||
md5.getProcessType());
|
||||
long expected = md5.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
final long expected = md5.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
assertEquals(expected, md5.getSignature());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@ public class Murmur128x86CyclicTest {
|
|||
*/
|
||||
@Test
|
||||
public void applyTest() {
|
||||
Murmur128x86Cyclic murmur = new Murmur128x86Cyclic();
|
||||
final Murmur128x86Cyclic murmur = new Murmur128x86Cyclic();
|
||||
|
||||
long l1 = 0xe7eb60dabb386407L;
|
||||
long l2 = 0xc3ca49f691f73056L;
|
||||
byte[] buffer = "Now is the time for all good men to come to the aid of their country"
|
||||
final long l1 = 0xe7eb60dabb386407L;
|
||||
final long l2 = 0xc3ca49f691f73056L;
|
||||
final byte[] buffer = "Now is the time for all good men to come to the aid of their country"
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
long l = murmur.apply(buffer, 0);
|
||||
|
@ -56,10 +56,10 @@ public class Murmur128x86CyclicTest {
|
|||
*/
|
||||
@Test
|
||||
public void signatureTest() {
|
||||
Murmur128x86Cyclic murmur = new Murmur128x86Cyclic();
|
||||
String arg = String.format("%s-%s-%s", murmur.getName().toUpperCase(Locale.ROOT), murmur.getSignedness(),
|
||||
final Murmur128x86Cyclic murmur = new Murmur128x86Cyclic();
|
||||
final String arg = String.format("%s-%s-%s", murmur.getName().toUpperCase(Locale.ROOT), murmur.getSignedness(),
|
||||
murmur.getProcessType());
|
||||
long expected = murmur.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
final long expected = murmur.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
assertEquals(expected, murmur.getSignature());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ public class Murmur32x86IterativeTest {
|
|||
*/
|
||||
@Test
|
||||
public void applyTest() {
|
||||
Murmur32x86Iterative murmur = new Murmur32x86Iterative();
|
||||
final Murmur32x86Iterative murmur = new Murmur32x86Iterative();
|
||||
|
||||
byte[] buffer = "Now is the time for all good men to come to the aid of their country"
|
||||
final byte[] buffer = "Now is the time for all good men to come to the aid of their country"
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
long l = murmur.apply(buffer, 0);
|
||||
|
@ -54,10 +54,10 @@ public class Murmur32x86IterativeTest {
|
|||
*/
|
||||
@Test
|
||||
public void signatureTest() {
|
||||
Murmur32x86Iterative murmur = new Murmur32x86Iterative();
|
||||
String arg = String.format("%s-%s-%s", murmur.getName().toUpperCase(Locale.ROOT), murmur.getSignedness(),
|
||||
final Murmur32x86Iterative murmur = new Murmur32x86Iterative();
|
||||
final String arg = String.format("%s-%s-%s", murmur.getName().toUpperCase(Locale.ROOT), murmur.getSignedness(),
|
||||
murmur.getProcessType());
|
||||
long expected = murmur.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
final long expected = murmur.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
assertEquals(expected, murmur.getSignature());
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ public class ObjectsHashIterativeTest {
|
|||
*/
|
||||
@Test
|
||||
public void applyTest() {
|
||||
ObjectsHashIterative obj = new ObjectsHashIterative();
|
||||
final ObjectsHashIterative obj = new ObjectsHashIterative();
|
||||
|
||||
byte[] buffer = "Now is the time for all good men to come to the aid of their country"
|
||||
final byte[] buffer = "Now is the time for all good men to come to the aid of their country"
|
||||
.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
long l = obj.apply(buffer, 0);
|
||||
|
@ -57,11 +57,11 @@ public class ObjectsHashIterativeTest {
|
|||
*/
|
||||
@Test
|
||||
public void signatureTest() {
|
||||
ObjectsHashIterative obj = new ObjectsHashIterative();
|
||||
String arg = String.format("%s-%s-%s", obj.getName().toUpperCase(Locale.ROOT), obj.getSignedness(),
|
||||
final ObjectsHashIterative obj = new ObjectsHashIterative();
|
||||
final String arg = String.format("%s-%s-%s", obj.getName().toUpperCase(Locale.ROOT), obj.getSignedness(),
|
||||
obj.getProcessType());
|
||||
long expected = obj.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
long expected2 = obj.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
final long expected = obj.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
final long expected2 = obj.apply(arg.getBytes(StandardCharsets.UTF_8), 0);
|
||||
assertEquals(expected, expected2);
|
||||
assertEquals(expected, obj.getSignature());
|
||||
}
|
||||
|
|
|
@ -253,22 +253,22 @@ public class CompositeCollectionTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
public void testAddNullList() {
|
||||
ArrayList<String> nullList = null;
|
||||
CompositeCollection<String> cc = new CompositeCollection<>();
|
||||
final ArrayList<String> nullList = null;
|
||||
final CompositeCollection<String> cc = new CompositeCollection<>();
|
||||
cc.addComposited(nullList);
|
||||
Assert.assertEquals(0, cc.size());
|
||||
}
|
||||
|
||||
public void testAddNullLists2Args() {
|
||||
ArrayList<String> nullList = null;
|
||||
CompositeCollection<String> cc = new CompositeCollection<>();
|
||||
final ArrayList<String> nullList = null;
|
||||
final CompositeCollection<String> cc = new CompositeCollection<>();
|
||||
cc.addComposited(nullList, nullList);
|
||||
Assert.assertEquals(0, cc.size());
|
||||
}
|
||||
|
||||
public void testAddNullListsVarArgs() {
|
||||
ArrayList<String> nullList = null;
|
||||
CompositeCollection<String> cc = new CompositeCollection<>();
|
||||
final ArrayList<String> nullList = null;
|
||||
final CompositeCollection<String> cc = new CompositeCollection<>();
|
||||
cc.addComposited(nullList, nullList, nullList);
|
||||
Assert.assertEquals(0, cc.size());
|
||||
}
|
||||
|
|
|
@ -70,14 +70,14 @@ public class FixedSizeListTest<E> extends AbstractListTest<E> {
|
|||
|
||||
public void testListAllowsMutationOfUnderlyingCollection() {
|
||||
|
||||
List<String> decoratedList = new ArrayList<>();
|
||||
final List<String> decoratedList = new ArrayList<>();
|
||||
decoratedList.add("item 1");
|
||||
decoratedList.add("item 2");
|
||||
//
|
||||
FixedSizeList<String> fixedSizeList = FixedSizeList.fixedSizeList(decoratedList);
|
||||
int sizeBefore = fixedSizeList.size();
|
||||
final FixedSizeList<String> fixedSizeList = FixedSizeList.fixedSizeList(decoratedList);
|
||||
final int sizeBefore = fixedSizeList.size();
|
||||
//
|
||||
boolean changed = decoratedList.add("New Value");
|
||||
final boolean changed = decoratedList.add("New Value");
|
||||
Assert.assertTrue(changed);
|
||||
//
|
||||
Assert.assertEquals("Modifying an the underlying list is allowed",
|
||||
|
@ -85,7 +85,7 @@ public class FixedSizeListTest<E> extends AbstractListTest<E> {
|
|||
}
|
||||
|
||||
private FixedSizeList<String> initFixedSizeList() {
|
||||
List<String> decoratedList = new ArrayList<>();
|
||||
final List<String> decoratedList = new ArrayList<>();
|
||||
decoratedList.add("item 1");
|
||||
decoratedList.add("item 2");
|
||||
//
|
||||
|
@ -93,53 +93,53 @@ public class FixedSizeListTest<E> extends AbstractListTest<E> {
|
|||
}
|
||||
|
||||
public void testAdd() {
|
||||
FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
final FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
|
||||
try {
|
||||
fixedSizeList.add(2,"New Value");
|
||||
fail();
|
||||
} catch (UnsupportedOperationException ex) {}
|
||||
} catch (final UnsupportedOperationException ex) {}
|
||||
}
|
||||
|
||||
|
||||
public void testAddAll() {
|
||||
FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
final FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
|
||||
List<String> addList = new ArrayList<>();
|
||||
final List<String> addList = new ArrayList<>();
|
||||
addList.add("item 3");
|
||||
addList.add("item 4");
|
||||
|
||||
try {
|
||||
fixedSizeList.addAll(2, addList);
|
||||
fail();
|
||||
} catch (UnsupportedOperationException ex) {}
|
||||
} catch (final UnsupportedOperationException ex) {}
|
||||
}
|
||||
|
||||
public void testRemove() {
|
||||
FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
final FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
|
||||
try {
|
||||
fixedSizeList.remove(1);
|
||||
fail();
|
||||
} catch (UnsupportedOperationException ex) {}
|
||||
} catch (final UnsupportedOperationException ex) {}
|
||||
}
|
||||
|
||||
public void testSubList() {
|
||||
FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
final FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
|
||||
List<String> subFixedSizeList = fixedSizeList.subList(1, 1);
|
||||
final List<String> subFixedSizeList = fixedSizeList.subList(1, 1);
|
||||
Assert.assertNotNull(subFixedSizeList);
|
||||
Assert.assertEquals(0, subFixedSizeList.size());
|
||||
}
|
||||
|
||||
public void testIsFull() {
|
||||
FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
final FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
|
||||
Assert.assertTrue(fixedSizeList.isFull());
|
||||
}
|
||||
|
||||
public void testMaxSize() {
|
||||
FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
final FixedSizeList<String> fixedSizeList = initFixedSizeList();
|
||||
|
||||
Assert.assertEquals(2, fixedSizeList.maxSize());
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
|
||||
public class LazyListTest extends AbstractObjectTest {
|
||||
|
||||
public LazyListTest(String testName) {
|
||||
public LazyListTest(final String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class LazyListTest extends AbstractObjectTest {
|
|||
public void testGetWithNull() {
|
||||
final List<Integer> hours = Arrays.asList(7, 5, 8, 2);
|
||||
final Transformer<Integer, LocalDateTime> transformer = input -> LocalDateTime.now().withHour(hours.get(input));
|
||||
List<LocalDateTime> list = new LazyList<>(new ArrayList<>(), transformer);
|
||||
final List<LocalDateTime> list = new LazyList<>(new ArrayList<>(), transformer);
|
||||
LocalDateTime fourthElement = list.get(3);
|
||||
assertFalse(list.isEmpty());
|
||||
assertNotNull(fourthElement);
|
||||
|
@ -113,8 +113,8 @@ public class LazyListTest extends AbstractObjectTest {
|
|||
|
||||
public void testSubListWitheFactory() {
|
||||
final Factory<LocalDateTime> dateFactory = LocalDateTime::now;
|
||||
List<LocalDateTime> list = new LazyList<>(new ArrayList<>(), dateFactory);
|
||||
LocalDateTime fourthElement = list.get(3);
|
||||
final List<LocalDateTime> list = new LazyList<>(new ArrayList<>(), dateFactory);
|
||||
final LocalDateTime fourthElement = list.get(3);
|
||||
assertFalse(list.isEmpty());
|
||||
assertNotNull(fourthElement);
|
||||
testSubList(list);
|
||||
|
@ -123,14 +123,14 @@ public class LazyListTest extends AbstractObjectTest {
|
|||
public void testSubListWithTransformer() {
|
||||
final List<Integer> hours = Arrays.asList(7, 5, 8, 2);
|
||||
final Transformer<Integer, LocalDateTime> transformer = input -> LocalDateTime.now().withHour(hours.get(input));
|
||||
List<LocalDateTime> list = new LazyList<>(new ArrayList<>(), transformer);
|
||||
LocalDateTime fourthElement = list.get(3);
|
||||
final List<LocalDateTime> list = new LazyList<>(new ArrayList<>(), transformer);
|
||||
final LocalDateTime fourthElement = list.get(3);
|
||||
assertFalse(list.isEmpty());
|
||||
assertNotNull(fourthElement);
|
||||
testSubList(list);
|
||||
}
|
||||
|
||||
private void testSubList(List<LocalDateTime> list) {
|
||||
private void testSubList(final List<LocalDateTime> list) {
|
||||
List<LocalDateTime> subList = list.subList(1, 3);
|
||||
assertFalse(subList.isEmpty());
|
||||
assertNotNull(subList);
|
||||
|
|
|
@ -135,35 +135,35 @@ public class DefaultedMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
try {
|
||||
DefaultedMap.defaultedMap(null, (V) "DEFAULT_VALUE");
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
} catch (final NullPointerException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
try {
|
||||
DefaultedMap.defaultedMap((Map<K, V>) null, nullFactory);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
} catch (final NullPointerException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
try {
|
||||
DefaultedMap.defaultedMap(base, (Factory<V>) null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
} catch (final NullPointerException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
try {
|
||||
DefaultedMap.defaultedMap((Map<K, V>) null, nullTransformer);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
} catch (final NullPointerException e) {
|
||||
// Expected
|
||||
}
|
||||
|
||||
try {
|
||||
DefaultedMap.defaultedMap(base, (Transformer<K, V>) null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (NullPointerException e) {
|
||||
} catch (final NullPointerException e) {
|
||||
// Expected
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,11 +347,11 @@ public class Flat3MapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
map.put((K) "A", (V) "one");
|
||||
map.put((K) "B", (V) "two");
|
||||
map.put((K) "C", (V) "three");
|
||||
Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
|
||||
final Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
|
||||
|
||||
Map.Entry<K, V> mapEntry1 = it.next();
|
||||
Map.Entry<K, V> mapEntry2 = it.next();
|
||||
Map.Entry<K, V> mapEntry3 = it.next();
|
||||
final Map.Entry<K, V> mapEntry1 = it.next();
|
||||
final Map.Entry<K, V> mapEntry2 = it.next();
|
||||
final Map.Entry<K, V> mapEntry3 = it.next();
|
||||
it.remove();
|
||||
assertEquals(2, map.size());
|
||||
assertEquals("one", map.get("A"));
|
||||
|
|
|
@ -41,7 +41,7 @@ public class LazySortedMapTest<K, V> extends AbstractSortedMapTest<K, V> {
|
|||
|
||||
private class ReverseStringComparator implements Comparator<String> {
|
||||
@Override
|
||||
public int compare(String arg0, String arg1) {
|
||||
public int compare(final String arg0, final String arg1) {
|
||||
return arg1.compareTo(arg0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PredicatedSortedMapTest<K, V> extends AbstractSortedMapTest<K, V> {
|
|||
|
||||
private class ReverseStringComparator implements Comparator<K> {
|
||||
@Override
|
||||
public int compare(K arg0, K arg1) {
|
||||
public int compare(final K arg0, final K arg1) {
|
||||
return ((String) arg1).compareTo((String)arg0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,14 +261,14 @@ public class ReferenceMapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
}
|
||||
|
||||
public void testCustomPurge() {
|
||||
List<Integer> expiredValues = new ArrayList<>();
|
||||
final List<Integer> expiredValues = new ArrayList<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
final Consumer<Integer> consumer = (Consumer<Integer> & Serializable) v -> expiredValues.add(v);
|
||||
final Map<Integer, Integer> map = new ReferenceMap<Integer, Integer>(ReferenceStrength.WEAK, ReferenceStrength.HARD, false) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected ReferenceEntry<Integer, Integer> createEntry(HashEntry<Integer, Integer> next, int hashCode, Integer key, Integer value) {
|
||||
protected ReferenceEntry<Integer, Integer> createEntry(final HashEntry<Integer, Integer> next, final int hashCode, final Integer key, final Integer value) {
|
||||
return new AccessibleEntry<>(this, next, hashCode, key, value, consumer);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -152,8 +152,8 @@ public class ArrayListValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest
|
|||
public void testArrayListValuedHashMap() {
|
||||
ListValuedMap<K, V> listMap = null;
|
||||
ListValuedMap<K, V> listMap1 = null;
|
||||
Map<K, V> map = new HashMap<>();
|
||||
Map<K, V> map1 = new HashMap<>();
|
||||
final Map<K, V> map = new HashMap<>();
|
||||
final Map<K, V> map1 = new HashMap<>();
|
||||
map.put((K) "A", (V) "W");
|
||||
map.put((K) "B", (V) "X");
|
||||
map.put((K) "C", (V) "F");
|
||||
|
@ -184,7 +184,7 @@ public class ArrayListValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest
|
|||
|
||||
public void testWrappedListAdd() {
|
||||
final ListValuedMap<K, V> listMap = makeObject();
|
||||
List<V> listA = listMap.get((K) "A");
|
||||
final List<V> listA = listMap.get((K) "A");
|
||||
listA.add(0, (V) "W");
|
||||
listA.add(1, (V) "X");
|
||||
listA.add(2, (V) "F");
|
||||
|
@ -195,12 +195,12 @@ public class ArrayListValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest
|
|||
|
||||
public void testWrappedListAddAll() {
|
||||
final ListValuedMap<K, V> listMap = makeObject();
|
||||
List<V> listA = listMap.get((K) "A");
|
||||
List<V> list = Arrays.asList((V) "W", (V) "X", (V) "F");
|
||||
final List<V> listA = listMap.get((K) "A");
|
||||
final List<V> list = Arrays.asList((V) "W", (V) "X", (V) "F");
|
||||
listA.addAll(0, list);
|
||||
assertEquals("{A=[W, X, F]}", listMap.toString());
|
||||
|
||||
List<V> list1 = Arrays.asList((V) "Q", (V) "Q", (V) "L");
|
||||
final List<V> list1 = Arrays.asList((V) "Q", (V) "Q", (V) "L");
|
||||
listA.addAll(3, list1);
|
||||
assertEquals("{A=[W, X, F, Q, Q, L]}", listMap.toString());
|
||||
assertEquals("W", listMap.get((K) "A").get(0));
|
||||
|
@ -216,20 +216,20 @@ public class ArrayListValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest
|
|||
assertEquals(4, listMap.get((K) "A").lastIndexOf("Q"));
|
||||
assertEquals(-1, listMap.get((K) "A").lastIndexOf("A"));
|
||||
|
||||
List<V> list2 = new ArrayList<>();
|
||||
final List<V> list2 = new ArrayList<>();
|
||||
listMap.get((K) "B").addAll(0, list2);
|
||||
assertEquals("{A=[W, X, F, Q, Q, L]}", listMap.toString());
|
||||
List<V> list3 = listMap.get((K) "A").subList(1, 4);
|
||||
final List<V> list3 = listMap.get((K) "A").subList(1, 4);
|
||||
assertEquals(3, list3.size());
|
||||
assertEquals("Q", list3.get(2));
|
||||
}
|
||||
|
||||
public void testValuesListIteratorMethods(){
|
||||
final ListValuedMap<K, V> listMap = makeObject();
|
||||
List<V> listA = listMap.get((K) "A");
|
||||
List<V> list = Arrays.asList((V) "W", (V) "X", (V) "F", (V) "Q", (V) "Q", (V)"F");
|
||||
final List<V> listA = listMap.get((K) "A");
|
||||
final List<V> list = Arrays.asList((V) "W", (V) "X", (V) "F", (V) "Q", (V) "Q", (V)"F");
|
||||
listA.addAll(0, list);
|
||||
ListIterator<V> it = listMap.get((K) "A").listIterator(1);
|
||||
final ListIterator<V> it = listMap.get((K) "A").listIterator(1);
|
||||
assertTrue(it.hasNext());
|
||||
assertEquals("X", it.next());
|
||||
assertEquals("F", it.next());
|
||||
|
|
|
@ -146,7 +146,7 @@ public class HashSetValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest<K
|
|||
public void testHashSetValueHashMap_1() {
|
||||
final MultiValuedMap<K, V> map = new ArrayListValuedHashMap<>();
|
||||
SetValuedMap<K, V> map1 = null;
|
||||
SetValuedMap<K, V> map2 = makeObject();
|
||||
final SetValuedMap<K, V> map2 = makeObject();
|
||||
SetValuedMap<K, V> map3 = null;
|
||||
|
||||
map.put((K) "A", (V) "W");
|
||||
|
|
|
@ -107,8 +107,8 @@ public class UnmodifiableQueueTest<E> extends AbstractQueueTest<E> {
|
|||
}
|
||||
|
||||
public void testOffer() {
|
||||
Queue<E> queue = makeFullCollection();
|
||||
E e = null;
|
||||
final Queue<E> queue = makeFullCollection();
|
||||
final E e = null;
|
||||
try {
|
||||
queue.offer(e);
|
||||
fail();
|
||||
|
@ -116,7 +116,7 @@ public class UnmodifiableQueueTest<E> extends AbstractQueueTest<E> {
|
|||
}
|
||||
|
||||
public void testPoll() {
|
||||
Queue<E> queue = makeFullCollection();
|
||||
final Queue<E> queue = makeFullCollection();
|
||||
try {
|
||||
queue.poll();
|
||||
fail();
|
||||
|
|
Loading…
Reference in New Issue