Skip to content

Commit

Permalink
Bump to guava 19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bdupras committed Feb 15, 2016
1 parent 9d53013 commit 4ae2e13
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 58 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Guava-Probably: Probabilistic data structures for Guava

The Guava-Probably project provides several probabilistic data structures for Guava.

Requires JDK 1.6 or higher and Google Guava 16.0.1 or higher (as of 1.0).
Requires JDK 1.6 or higher and Google Guava 19.0 or higher (as of 1.0).


Latest release
Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Guava-Probably: TODO List
=======================================================

=1.0
* bump to most recent version of Guava and true-up Bloom filter API for longs?

==CI
* commit/push to release SNAPSHOT, major, minor, patch :: maven central && javadocs
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>16.0.1</version>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<version>16.0.1</version>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-tests</artifactId>
<version>16.0.1</version>
<version>19.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/duprasville/guava/probably/BloomFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private BloomFilter(com.google.common.hash.BloomFilter<E> delegate, Funnel<E> fu
* double)</a>
*/
@CheckReturnValue
public static <T> BloomFilter<T> create(Funnel<T> funnel, int capacity, double fpp) {
public static <T> BloomFilter<T> create(Funnel<T> funnel, long capacity, double fpp) {
return new BloomFilter<T>(
com.google.common.hash.BloomFilter.create(funnel, capacity, fpp),
funnel, capacity, fpp, 0L);
Expand Down Expand Up @@ -123,7 +123,7 @@ public static <T> BloomFilter<T> create(Funnel<T> funnel, int capacity, double f
* int)">com.google.common.hash.BloomFilter#create(com.google.common.hash.Funnel, int)</a> </a>
*/
@CheckReturnValue
public static <T> BloomFilter<T> create(Funnel<T> funnel, int capacity) {
public static <T> BloomFilter<T> create(Funnel<T> funnel, long capacity) {
return new BloomFilter<T>(
com.google.common.hash.BloomFilter.create(funnel, capacity, 0.03D),
funnel, capacity, 0.03D, 0L);
Expand Down
40 changes: 0 additions & 40 deletions src/main/java/com/duprasville/guava/probably/CuckooFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,27 +484,6 @@ public int hashCode() {
return Objects.hashCode(funnel, cuckooStrategy, table);
}

/**
* Creates a filter with the expected number of insertions and expected false positive
* probability. <p/> <p>Note that overflowing a {@link CuckooFilter} with significantly more
* objects than specified, will result in its saturation causing {@link #add(Object)} to reject
* new additions. <p/> <p>The constructed {@link CuckooFilter} will be serializable if the
* provided {@code Funnel<T>} is. <p/> <p>It is recommended that the funnel be implemented as a
* Java enum. This has the benefit of ensuring proper serialization and deserialization, which is
* important since {@link #equals} also relies on object identity of funnels.
*
* @param funnel the funnel of T's that the constructed {@link CuckooFilter} will use
* @param capacity the number of expected insertions to the constructed {@link CuckooFilter}; must
* be positive
* @param fpp the desired false positive probability (must be positive and less than 1.0)
* @return a {@link CuckooFilter}
*/
@CheckReturnValue
public static <T> CuckooFilter<T> create(
Funnel<? super T> funnel, int capacity, double fpp) {
return create(funnel, (long) capacity, fpp);
}

/**
* Creates a filter with the expected number of insertions and expected false positive
* probability. <p/> <p>Note that overflowing a {@link CuckooFilter} with significantly more
Expand Down Expand Up @@ -550,25 +529,6 @@ static <T> CuckooFilter<T> create(Funnel<? super T> funnel, long capacity, doubl
}
}

/**
* Creates a filter with the expected number of insertions and a default expected false positive
* probability of 3.2%. <p/> <p>Note that overflowing a {@code CuckooFilter} with significantly
* more objects than specified, will result in its saturation causing {@link #add(Object)} to
* reject new additions. <p/> <p>The constructed {@link CuckooFilter} will be serializable if the
* provided {@code Funnel<T>} is. <p/> <p>It is recommended that the funnel be implemented as a
* Java enum. This has the benefit of ensuring proper serialization and deserialization, which is
* important since {@link #equals} also relies on object identity of funnels.
*
* @param funnel the funnel of T's that the constructed {@link CuckooFilter} will use
* @param capacity the number of expected insertions to the constructed {@link CuckooFilter}; must
* be positive
* @return a {@link CuckooFilter}
*/
@CheckReturnValue
public static <T> CuckooFilter<T> create(Funnel<? super T> funnel, int capacity) {
return create(funnel, (long) capacity);
}

/**
* Creates a filter with the expected number of insertions and a default expected false positive
* probability of 3.2%. <p/> <p>Note that overflowing a {@code CuckooFilter} with significantly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,18 @@ private void basicTests(
int falseInsertions = 0;

for (int i = 0; i < capacity - 1; i++) { //minus 1 since we've already inserted one above
double expectedFppBefore = filter.currentFpp();
double currentFppBefore = filter.currentFpp();

if (filter.add(Integer.toString(i))) {
assertTrue("expectedFpp should not decrease after put returns true",
filter.currentFpp() >= expectedFppBefore);
assertTrue("currentFpp should not decrease after put returns true",
filter.currentFpp() >= currentFppBefore);

assertTrue("contains should return true when queried with an inserted item",
filter.contains(Integer.toString(i)));
} else {
falseInsertions++;
assertEquals("expectedFpp should not change after put returns false",
expectedFppBefore, filter.currentFpp());
assertEquals("currentFpp should not change after put returns false",
currentFppBefore, filter.currentFpp());
}
}

Expand All @@ -212,18 +212,15 @@ private void basicTests(
while (filter.add(Integer.toString(random.nextInt())) && (--falseInsertions > 0)) ;

assertWithMessage(
"expectedFpp should be, approximately, at most the requested fpp after inserting the " +
"currentFpp should be, approximately, at most the requested fpp after inserting the " +
"requested number of items")
.that(filter.currentFpp())
.isAtMost(fpp * 1.2);
.isAtMost(fpp * 1.3);

assertWithMessage(
"expectedFpp should be, approximately, at least the half the requested fpp after " +
"currentFpp should be, approximately, at least the half the requested fpp after " +
"inserting the requested number of items: " + capacity + ", " + fpp)
.that(filter.currentFpp())
.isAtLeast(fpp * 0.65);
}



}

0 comments on commit 4ae2e13

Please sign in to comment.