Formatting.
This commit is contained in:
parent
7d06bd77e9
commit
a1ce1c2121
|
@ -116,7 +116,7 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(final Hasher hasher) {
|
public boolean contains(final Hasher hasher) {
|
||||||
verifyHasher( hasher );
|
verifyHasher(hasher);
|
||||||
final long[] buff = getBits();
|
final long[] buff = getBits();
|
||||||
|
|
||||||
final OfInt iter = hasher.getBits(shape);
|
final OfInt iter = hasher.getBits(shape);
|
||||||
|
@ -208,9 +208,8 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
result[i] = mine[i] | theirs[i];
|
result[i] = mine[i] | theirs[i];
|
||||||
}
|
}
|
||||||
if (limit<result.length)
|
if (limit < result.length) {
|
||||||
{
|
System.arraycopy(remainder, limit, result, limit, result.length - limit);
|
||||||
System.arraycopy(remainder, limit, result, limit, result.length-limit);
|
|
||||||
}
|
}
|
||||||
return BitSet.valueOf(result).cardinality();
|
return BitSet.valueOf(result).cardinality();
|
||||||
}
|
}
|
||||||
|
@ -277,9 +276,8 @@ public abstract class AbstractBloomFilter implements BloomFilter {
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
result[i] = mine[i] ^ theirs[i];
|
result[i] = mine[i] ^ theirs[i];
|
||||||
}
|
}
|
||||||
if (limit<result.length)
|
if (limit < result.length) {
|
||||||
{
|
System.arraycopy(remainder, limit, result, limit, result.length - limit);
|
||||||
System.arraycopy(remainder, limit, result, limit, result.length-limit);
|
|
||||||
}
|
}
|
||||||
return BitSet.valueOf(result).cardinality();
|
return BitSet.valueOf(result).cardinality();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,11 @@ public final class StaticHasher implements Hasher {
|
||||||
* @throws IllegalArgumentException if the hasher function and the shape function are not the same.
|
* @throws IllegalArgumentException if the hasher function and the shape function are not the same.
|
||||||
*/
|
*/
|
||||||
public StaticHasher(final Hasher hasher, final Shape shape) {
|
public StaticHasher(final Hasher hasher, final Shape shape) {
|
||||||
this( hasher.getBits(shape), shape);
|
this(hasher.getBits(shape), shape);
|
||||||
if (
|
if (HashFunctionIdentity.COMMON_COMPARATOR.compare(hasher.getHashFunctionIdentity(),
|
||||||
HashFunctionIdentity.COMMON_COMPARATOR.compare(
|
shape.getHashFunctionIdentity()) != 0) {
|
||||||
hasher.getHashFunctionIdentity(), shape.getHashFunctionIdentity()) != 0) {
|
|
||||||
throw new IllegalArgumentException(String.format("Hasher (%s) is not the same as for shape (%s)",
|
throw new IllegalArgumentException(String.format("Hasher (%s) is not the same as for shape (%s)",
|
||||||
HashFunctionIdentity.asCommonString( hasher.getHashFunctionIdentity()),
|
HashFunctionIdentity.asCommonString(hasher.getHashFunctionIdentity()), shape.toString()));
|
||||||
shape.toString()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,20 +63,18 @@ public final class StaticHasher implements Hasher {
|
||||||
public StaticHasher(final Iterator<Integer> iter, final Shape shape) {
|
public StaticHasher(final Iterator<Integer> iter, final Shape shape) {
|
||||||
this.shape = shape;
|
this.shape = shape;
|
||||||
final Set<Integer> workingValues = new TreeSet<>();
|
final Set<Integer> workingValues = new TreeSet<>();
|
||||||
iter.forEachRemaining( idx -> {
|
iter.forEachRemaining(idx -> {
|
||||||
if (idx >= this.shape.getNumberOfBits())
|
if (idx >= this.shape.getNumberOfBits()) {
|
||||||
{
|
throw new IllegalArgumentException(String.format("Bit index (%s) is too big for %s", idx, shape));
|
||||||
throw new IllegalArgumentException( String.format( "Bit index (%s) is too big for %s", idx, shape ));
|
|
||||||
}
|
}
|
||||||
if (idx < 0 ) {
|
if (idx < 0) {
|
||||||
throw new IllegalArgumentException( String.format( "Bit index (%s) may not be less than zero", idx ));
|
throw new IllegalArgumentException(String.format("Bit index (%s) may not be less than zero", idx));
|
||||||
}
|
}
|
||||||
workingValues.add( idx );
|
workingValues.add(idx);
|
||||||
});
|
});
|
||||||
this.values = new int[workingValues.size()];
|
this.values = new int[workingValues.size()];
|
||||||
int i=0;
|
int i = 0;
|
||||||
for (final Integer value : workingValues)
|
for (final Integer value : workingValues) {
|
||||||
{
|
|
||||||
values[i++] = value.intValue();
|
values[i++] = value.intValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +110,7 @@ public final class StaticHasher implements Hasher {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("shape (%s) does not match internal shape (%s)", shape, this.shape));
|
String.format("shape (%s) does not match internal shape (%s)", shape, this.shape));
|
||||||
}
|
}
|
||||||
return Arrays.stream( values ).iterator();
|
return Arrays.stream(values).iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -59,9 +59,9 @@ public final class MD5Cyclic implements HashFunction {
|
||||||
try {
|
try {
|
||||||
messageDigest = MessageDigest.getInstance(NAME);
|
messageDigest = MessageDigest.getInstance(NAME);
|
||||||
} catch (final NoSuchAlgorithmException e) {
|
} catch (final NoSuchAlgorithmException e) {
|
||||||
throw new IllegalStateException( e.getMessage() );
|
throw new IllegalStateException(e.getMessage());
|
||||||
}
|
}
|
||||||
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -49,7 +49,7 @@ public final class Murmur128x86Cyclic implements HashFunction {
|
||||||
* Constructs a Murmur3 x64 128 hash.
|
* Constructs a Murmur3 x64 128 hash.
|
||||||
*/
|
*/
|
||||||
public Murmur128x86Cyclic() {
|
public Murmur128x86Cyclic() {
|
||||||
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public final class Murmur32x86Iterative implements HashFunction {
|
||||||
* Constructs a Murmur3 x86 32 hash
|
* Constructs a Murmur3 x86 32 hash
|
||||||
*/
|
*/
|
||||||
public Murmur32x86Iterative() {
|
public Murmur32x86Iterative() {
|
||||||
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,7 +53,7 @@ public final class ObjectsHashIterative implements HashFunction {
|
||||||
* Constructs a hash that uses the Objects.hash method to has values.
|
* Constructs a hash that uses the Objects.hash method to has values.
|
||||||
*/
|
*/
|
||||||
public ObjectsHashIterative() {
|
public ObjectsHashIterative() {
|
||||||
signature = apply( HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
signature = apply(HashFunctionIdentity.prepareSignatureBuffer(this), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,7 +61,7 @@ public final class ObjectsHashIterative implements HashFunction {
|
||||||
if (seed == 0) {
|
if (seed == 0) {
|
||||||
last = 0;
|
last = 0;
|
||||||
}
|
}
|
||||||
final long result = Arrays.deepHashCode( new Object[] {last, buffer});
|
final long result = Arrays.deepHashCode(new Object[] { last, buffer });
|
||||||
last += result;
|
last += result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue