Skip to content

Commit

Permalink
Fixed back API of Crc32cIntChecksum (apache#3826)
Browse files Browse the repository at this point in the history
### Motivation

In apache#3810 the signature of `Crc32cIntChecksum.resumeChecksum()` was changed to accept `offset` & `len` in the buffer.

Since this method is also used externally (in Pulsar), we should leave also the old method signature to avoid breaking the API when upgrading BK.
  • Loading branch information
merlimat authored and Anup Ghatage committed Jul 12, 2024
1 parent 8fed71c commit ae7addf
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ public static int computeChecksum(ByteBuf payload) {
return CRC32C_HASH.calculate(payload);
}

/**
* Computes crc32c checksum: if it is able to load crc32c native library then it computes using that native library
* which is faster as it computes using hardware machine instruction else it computes using crc32c algo.
*
* @param payload
* @return
*/
public static int computeChecksum(ByteBuf payload, int offset, int len) {
return CRC32C_HASH.calculate(payload, offset, len);
}

/**
* Computes incremental checksum with input previousChecksum and input payload
*
* @param previousChecksum : previously computed checksum
* @param payload
* @return
*/
public static int resumeChecksum(int previousChecksum, ByteBuf payload) {
return CRC32C_HASH.resume(previousChecksum, payload);
}

/**
* Computes incremental checksum with input previousChecksum and input payload
*
Expand Down

0 comments on commit ae7addf

Please sign in to comment.