jojochuang commented on code in PR #3581:
URL: https://github.com/apache/ozone/pull/3581#discussion_r924985908


##########
hadoop-ozone/client/src/main/java/org/apache/hadoop/ozone/client/checksum/ReplicatedBlockChecksumComputer.java:
##########
@@ -69,4 +83,62 @@ private void computeMd5Crc() throws IOException {
     LOG.debug("number of chunks={}, md5out={}",
         chunkInfoList.size(), fileMD5);
   }
+
+  // compute the block checksum of CompositeCrc,
+  // which is the incremental computation of chunk checksums
+  private void computeCompositeCrc() throws IOException {
+    DataChecksum.Type dataChecksumType = null;
+    long bytesPerCrc = 0;
+    long chunkSize = 0;
+    if (chunkInfoList.size() > 0) {
+      final ContainerProtos.ChunkInfo firstChunkInfo = chunkInfoList.get(0);
+      switch (firstChunkInfo.getChecksumData().getType()) {
+      case CRC32C:
+        dataChecksumType = DataChecksum.Type.CRC32C;
+        break;
+      case CRC32:
+        dataChecksumType = DataChecksum.Type.CRC32;
+        break;
+      default:
+        throw new IllegalArgumentException("unsupported checksum type");
+      }
+      chunkSize = firstChunkInfo.getLen();
+      bytesPerCrc = firstChunkInfo.getChecksumData().getBytesPerChecksum();
+    }
+
+    CrcComposer blockCrcComposer =
+        CrcComposer.newCrcComposer(dataChecksumType, chunkSize);

Review Comment:
   will fail if chunkInfoList.size() == 0



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to