Skip to content

Commit 8ae234b

Browse files
authored
Merge pull request #525 from apache/add_packageInfo_remove_cast
minor cleanups.
2 parents 13a6e48 + c269ffc commit 8ae234b

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

src/main/java/org/apache/datasketches/filters/bloomfilter/BitArray.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
/**
2929
* This class holds an array of bits suitable for use in a Bloom Filter
30-
*
30+
*
3131
* <p>Rounds the number of bits up to the smallest multiple of 64 (one long)
3232
* that is not smaller than the specified number.
3333
*/
3434
final class BitArray {
3535
// MAX_BITS using longs, based on array indices being capped at Integer.MAX_VALUE
36-
private static final long MAX_BITS = Integer.MAX_VALUE * (long) Long.SIZE;
36+
private static final long MAX_BITS = Integer.MAX_VALUE * (long) Long.SIZE;
3737

3838
private long numBitsSet_; // if -1, need to recompute value
3939
private boolean isDirty_;
@@ -68,10 +68,10 @@ static BitArray heapify(final Buffer buffer, final boolean isEmpty) {
6868
if (numLongs < 0) {
6969
throw new SketchesArgumentException("Possible corruption: Must have strictly positive array size. Found: " + numLongs);
7070
}
71-
71+
7272
if (isEmpty) {
7373
return new BitArray((long) numLongs * Long.SIZE);
74-
}
74+
}
7575

7676
buffer.getInt(); // unused
7777

@@ -120,7 +120,7 @@ long getNumBitsSet() {
120120
numBitsSet_ = 0;
121121
for (final long val : data_) {
122122
numBitsSet_ += Long.bitCount(val);
123-
}
123+
}
124124
}
125125
return numBitsSet_;
126126
}
@@ -184,7 +184,7 @@ long getSerializedSizeBytes() {
184184
void writeToBuffer(final WritableBuffer wbuf) {
185185
wbuf.putInt(data_.length);
186186
wbuf.putInt(0); // unused
187-
187+
188188
if (!isEmpty()) {
189189
wbuf.putLong(isDirty_ ? -1 : numBitsSet_);
190190
wbuf.putLongArray(data_, 0, data_.length);
@@ -204,7 +204,7 @@ public String toString() {
204204
}
205205

206206
// prints a long as a series of 0s and 1s as little endian
207-
private String printLong(final long val) {
207+
private static String printLong(final long val) {
208208
final StringBuilder sb = new StringBuilder();
209209
for (int j = 0; j < Long.SIZE; ++j) {
210210
sb.append((val & (1L << j)) != 0 ? "1" : "0");

src/main/java/org/apache/datasketches/filters/bloomfilter/BloomFilterBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* <p>This class provides methods to help estimate the correct paramters to use when
2828
* creating a Bloom filter, and methods to create the filter using those values.</p>
29-
*
29+
*
3030
* <p>The underlying math is described in the
3131
* <a href='https://en.wikipedia.org/wiki/Bloom_filter#Optimal_number_of_hash_functions'>
3232
* Wikipedia article on Bloom filters</a>.</p>
@@ -75,7 +75,7 @@ public static long suggestNumFilterBits(final long maxDistinctItems, final doubl
7575
if (targetFalsePositiveProb <= 0.0 || targetFalsePositiveProb > 1.0) {
7676
throw new SketchesArgumentException("targetFalsePositiveProb must be a valid probability and strictly greater than 0");
7777
}
78-
return (long) Math.round(-maxDistinctItems * Math.log(targetFalsePositiveProb) / (Math.log(2) * Math.log(2)));
78+
return Math.round(-maxDistinctItems * Math.log(targetFalsePositiveProb) / (Math.log(2) * Math.log(2)));
7979
}
8080

8181
/**
@@ -93,7 +93,7 @@ public static BloomFilter createByAccuracy(final long maxDistinctItems, final do
9393
* using the provided base seed for the hash function.
9494
* @param maxDistinctItems The maximum expected number of distinct items to add to the filter
9595
* @param targetFalsePositiveProb A desired false positive probability per item
96-
* @param seed A base hash seed
96+
* @param seed A base hash seed
9797
* @return A new BloomFilter configured for the given input parameters
9898
*/
9999
public static BloomFilter createByAccuracy(final long maxDistinctItems, final double targetFalsePositiveProb, final long seed) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.datasketches.filters.bloomfilter;

0 commit comments

Comments
 (0)