This is an automated email from the ASF dual-hosted git repository.

smengcl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new ec6dd34d679 HDDS-15111. Remove unused ChecksumByteBuffer 
implementations from PureJava CRC helpers (#10127)
ec6dd34d679 is described below

commit ec6dd34d679ed393c932d32aeedcc33f6514026b
Author: Siyao Meng <[email protected]>
AuthorDate: Thu May 7 19:16:35 2026 -0700

    HDDS-15111. Remove unused ChecksumByteBuffer implementations from PureJava 
CRC helpers (#10127)
---
 .../common/dev-support/findbugsExcludeFile.xml     |  5 --
 .../hadoop/ozone/common/ChecksumByteBuffer.java    | 78 ----------------------
 .../ozone/common/PureJavaCrc32ByteBuffer.java      | 11 +--
 .../ozone/common/PureJavaCrc32CByteBuffer.java     | 11 +--
 .../ozone/common/TestChecksumByteBuffer.java       |  4 +-
 .../common/TestChecksumImplsComputeSameValues.java |  4 +-
 6 files changed, 16 insertions(+), 97 deletions(-)

diff --git a/hadoop-hdds/common/dev-support/findbugsExcludeFile.xml 
b/hadoop-hdds/common/dev-support/findbugsExcludeFile.xml
index b80471fe376..bf9af0c6cf7 100644
--- a/hadoop-hdds/common/dev-support/findbugsExcludeFile.xml
+++ b/hadoop-hdds/common/dev-support/findbugsExcludeFile.xml
@@ -28,9 +28,4 @@
     <Class name="org.apache.hadoop.ozone.OzoneConsts"/>
     <Bug pattern="DMI_HARDCODED_ABSOLUTE_FILENAME" />
   </Match>
-  <Match>
-    <Class 
name="org.apache.hadoop.ozone.common.ChecksumByteBuffer$CrcIntTable" />
-    <Method name="update" />
-    <Bug pattern="SF_SWITCH_FALLTHROUGH,SF_SWITCH_NO_DEFAULT" />
-  </Match>
 </FindBugsFilter>
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChecksumByteBuffer.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChecksumByteBuffer.java
index 9cf4d85caa7..3a1d88d734d 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChecksumByteBuffer.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/ChecksumByteBuffer.java
@@ -23,7 +23,6 @@
 
 import java.nio.ByteBuffer;
 import java.util.zip.Checksum;
-import org.apache.ratis.util.Preconditions;
 
 /**
  * A sub-interface of {@link Checksum}
@@ -47,81 +46,4 @@ public interface ChecksumByteBuffer extends Checksum {
   default void update(byte[] b, int off, int len) {
     update(ByteBuffer.wrap(b, off, len).asReadOnlyBuffer());
   }
-
-  /**
-   * An abstract class implementing {@link ChecksumByteBuffer}
-   * with a 32-bit checksum and a lookup table.
-   */
-  @SuppressWarnings("innerassignment")
-  abstract class CrcIntTable implements ChecksumByteBuffer {
-    /** Current CRC value with bit-flipped. */
-    private int crc;
-
-    CrcIntTable() {
-      reset();
-      Preconditions.assertTrue(getTable().length == 8 * (1 << 8));
-    }
-
-    abstract int[] getTable();
-
-    @Override
-    public final long getValue() {
-      return (~crc) & 0xffffffffL;
-    }
-
-    @Override
-    public final void reset() {
-      crc = 0xffffffff;
-    }
-
-    @Override
-    public final void update(int b) {
-      crc = (crc >>> 8) ^ getTable()[(((crc ^ b) << 24) >>> 24)];
-    }
-
-    @Override
-    public final void update(ByteBuffer b) {
-      crc = update(crc, b, getTable());
-    }
-
-    private static int update(int crc, ByteBuffer b, int[] table) {
-      for (; b.remaining() > 7;) {
-        final int c0 = (b.get() ^ crc) & 0xff;
-        final int c1 = (b.get() ^ (crc >>>= 8)) & 0xff;
-        final int c2 = (b.get() ^ (crc >>>= 8)) & 0xff;
-        final int c3 = (b.get() ^ (crc >>> 8)) & 0xff;
-        crc = (table[0x700 + c0] ^ table[0x600 + c1])
-            ^ (table[0x500 + c2] ^ table[0x400 + c3]);
-
-        final int c4 = b.get() & 0xff;
-        final int c5 = b.get() & 0xff;
-        final int c6 = b.get() & 0xff;
-        final int c7 = b.get() & 0xff;
-
-        crc ^= (table[0x300 + c4] ^ table[0x200 + c5])
-            ^ (table[0x100 + c6] ^ table[c7]);
-      }
-
-      // loop unroll - duff's device style
-      switch (b.remaining()) {
-      case 7:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      case 6:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      case 5:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      case 4:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      case 3:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      case 2:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      case 1:
-        crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
-      default: // noop
-      }
-
-      return crc;
-    }
-  }
 }
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32ByteBuffer.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32ByteBuffer.java
index 23c36308470..46cddb7a76c 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32ByteBuffer.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32ByteBuffer.java
@@ -19,9 +19,12 @@
 
 /**
  * Similar to {@link org.apache.hadoop.util.PureJavaCrc32}
- * except that this class implement {@link ChecksumByteBuffer}.
+ * except that this class previously implemented {@link ChecksumByteBuffer}.
+ * The checksum-update methods were removed because no remaining production or
+ * test code uses them, and this class now exists only to provide the
+ * precomputed table-backed {@link #mod(long)} helper.
  */
-public final class PureJavaCrc32ByteBuffer extends 
ChecksumByteBuffer.CrcIntTable {
+public final class PureJavaCrc32ByteBuffer {
   /**
    * CRC-32 lookup table generated by the polynomial 0xEDB88320.
    * See also org.apache.hadoop.util.TestPureJavaCrc32.Table.
@@ -549,9 +552,7 @@ public final class PureJavaCrc32ByteBuffer extends 
ChecksumByteBuffer.CrcIntTabl
       0xA8C40105, 0x646E019B, 0xEAE10678, 0x264B06E6
   };
 
-  @Override
-  int[] getTable() {
-    return T;
+  private PureJavaCrc32ByteBuffer() {
   }
 
   /**
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32CByteBuffer.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32CByteBuffer.java
index 88a3b354e67..92b22ce0d55 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32CByteBuffer.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/PureJavaCrc32CByteBuffer.java
@@ -23,9 +23,12 @@
 
 /**
  * Similar to {@link org.apache.hadoop.util.PureJavaCrc32C}
- * except that this class implement {@link ChecksumByteBuffer}.
+ * except that this class previously implemented {@link ChecksumByteBuffer}.
+ * The checksum-update methods were removed because no remaining production or
+ * test code uses them, and this class now exists only to provide the
+ * precomputed table-backed {@link #mod(long)} helper.
  */
-public final class PureJavaCrc32CByteBuffer extends 
ChecksumByteBuffer.CrcIntTable {
+public final class PureJavaCrc32CByteBuffer {
   /**
    * CRC-32C lookup table generated by the polynomial 0x82F63B78.
    * See also org.apache.hadoop.util.TestPureJavaCrc32.Table.
@@ -553,9 +556,7 @@ public final class PureJavaCrc32CByteBuffer extends 
ChecksumByteBuffer.CrcIntTab
       0xC451B7CC, 0x8D6DCAEB, 0x56294D82, 0x1F1530A5
   };
 
-  @Override
-  int[] getTable() {
-    return T;
+  private PureJavaCrc32CByteBuffer() {
   }
 
   /**
diff --git 
a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumByteBuffer.java
 
b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumByteBuffer.java
index 6151d71da56..8aadad822e5 100644
--- 
a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumByteBuffer.java
+++ 
b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumByteBuffer.java
@@ -33,14 +33,14 @@
  */
 public class TestChecksumByteBuffer {
   @Test
-  public void testPureJavaCrc32ByteBuffer() {
+  public void testCrc32ByteBufferFactory() {
     final Checksum expected = new PureJavaCrc32();
     final ChecksumByteBuffer testee = ChecksumByteBufferFactory.crc32Impl();
     new VerifyChecksumByteBuffer(expected, testee).testCorrectness();
   }
 
   @Test
-  public void testPureJavaCrc32CByteBuffer() {
+  public void testCrc32CByteBufferFactory() {
     final Checksum expected = new PureJavaCrc32C();
     final ChecksumByteBuffer testee = ChecksumByteBufferFactory.crc32CImpl();
     new VerifyChecksumByteBuffer(expected, testee).testCorrectness();
diff --git 
a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumImplsComputeSameValues.java
 
b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumImplsComputeSameValues.java
index 3cb41fd586b..bb4358dd875 100644
--- 
a/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumImplsComputeSameValues.java
+++ 
b/hadoop-hdds/common/src/test/java/org/apache/hadoop/ozone/common/TestChecksumImplsComputeSameValues.java
@@ -45,7 +45,7 @@ public void testCRC32ImplsMatch() {
     data.put(RandomUtils.secure().randomBytes(data.remaining()));
     for (int bpc : bytesPerChecksum) {
       List<ChecksumByteBuffer> impls = new ArrayList<>();
-      impls.add(new PureJavaCrc32ByteBuffer());
+      impls.add(ChecksumByteBufferFactory.crc32Impl());
       impls.add(new ChecksumByteBufferImpl(new PureJavaCrc32()));
       impls.add(new ChecksumByteBufferImpl(new CRC32()));
       if (NativeCRC32Wrapper.isAvailable()) {
@@ -61,7 +61,7 @@ public void testCRC32CImplsMatch() {
     data.put(RandomUtils.secure().randomBytes(data.remaining()));
     for (int bpc : bytesPerChecksum) {
       List<ChecksumByteBuffer> impls = new ArrayList<>();
-      impls.add(new PureJavaCrc32CByteBuffer());
+      impls.add(ChecksumByteBufferFactory.crc32CImpl());
       impls.add(new ChecksumByteBufferImpl(new PureJavaCrc32C()));
       try {
         impls.add(new ChecksumByteBufferImpl(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to