Skip to content

Commit

Permalink
- update mightContain function to handle dcc hash;
Browse files Browse the repository at this point in the history
  • Loading branch information
MykhailoNester committed Mar 10, 2022
1 parent 5e06ddb commit 40bceb6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions java/src/dgca/partialhash/filter/PartialVariableHashFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,19 @@ public int add(byte @NotNull [] data) throws IllegalArgumentException {
return dataLength - startPointer;
}

public boolean mightContain(byte[] value) {
return new BinarySearch().binarySearch(array, 0, array.length, new BigInteger(value));
/**
* Check whether filter contains dcc hash bytes. It will check bytes depending on the filter size value.
*
* @param dccHashBytes byte array of dcc hash.
* @return true is contains otherwise false
*/
public boolean mightContain(byte[] dccHashBytes) {
if (dccHashBytes.length < size) {
return false;
}

byte[] filterSizeBytes = Arrays.copyOf(dccHashBytes, size);
return new BinarySearch().binarySearch(array, 0, array.length, new BigInteger(filterSizeBytes));
}

public byte getSize() {
Expand Down

0 comments on commit 40bceb6

Please sign in to comment.