You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by sh...@apache.org on 2023/03/01 09:34:33 UTC
[bookkeeper] branch master updated: Fixed back API of Crc32cIntChecksum (#3826)
This is an automated email from the ASF dual-hosted git repository.
shoothzj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 73294ce00f Fixed back API of Crc32cIntChecksum (#3826)
73294ce00f is described below
commit 73294ce00f039151f484dccf5c3d03114c852c73
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Wed Mar 1 01:34:27 2023 -0800
Fixed back API of Crc32cIntChecksum (#3826)
### Motivation
In #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.
---
.../circe/checksum/Crc32cIntChecksum.java | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java b/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java
index 40c6080823..65a77b1492 100644
--- a/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java
+++ b/circe-checksum/src/main/java/com/scurrilous/circe/checksum/Crc32cIntChecksum.java
@@ -46,6 +46,28 @@ public class Crc32cIntChecksum {
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
*