linliu-code commented on code in PR #12866:
URL: https://github.com/apache/hudi/pull/12866#discussion_r2105694876


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileBlock.java:
##########
@@ -68,43 +77,38 @@ static class Header {
   }
 
   protected final HFileContext context;
-  protected final byte[] byteBuff;
-  protected final int startOffsetInBuff;
-  protected final int sizeCheckSum;
-  protected final int uncompressedEndOffset;
   private final HFileBlockType blockType;
-  protected final int onDiskSizeWithoutHeader;
-  protected final int uncompressedSizeWithoutHeader;
-  protected final int bytesPerChecksum;
-  private boolean isUnpacked = false;
-  protected byte[] compressedByteBuff;
-  protected int startOffsetInCompressedBuff;
 
+  protected Option<HFileBlockReadAttributes> readAttributesOpt;
+  protected Option<HFileBlockWriteAttributes> writeAttributesOpt;
+
+  /**
+   * Initialize HFileBlock for read.
+   */
   protected HFileBlock(HFileContext context,
                        HFileBlockType blockType,
                        byte[] byteBuff,
                        int startOffsetInBuff) {
     this.context = context;
     this.blockType = blockType;
-    this.onDiskSizeWithoutHeader = readInt(
-        byteBuff, startOffsetInBuff + 
Header.ON_DISK_SIZE_WITHOUT_HEADER_INDEX);
-    this.uncompressedSizeWithoutHeader = readInt(
-        byteBuff, startOffsetInBuff + 
Header.UNCOMPRESSED_SIZE_WITHOUT_HEADER_INDEX);
-    this.bytesPerChecksum = readInt(
-        byteBuff, startOffsetInBuff + Header.BYTES_PER_CHECKSUM_INDEX);
-    this.sizeCheckSum = numChecksumBytes(getOnDiskSizeWithHeader(), 
bytesPerChecksum);
-    if (CompressionCodec.NONE.equals(context.getCompressionCodec())) {
-      isUnpacked = true;
-      this.startOffsetInBuff = startOffsetInBuff;
-      this.byteBuff = byteBuff;
-    } else {
-      this.startOffsetInCompressedBuff = startOffsetInBuff;
-      this.compressedByteBuff = byteBuff;
-      this.startOffsetInBuff = 0;
-      this.byteBuff = allocateBufferForUnpacking();
-    }
-    this.uncompressedEndOffset =
-        this.startOffsetInBuff + HFILEBLOCK_HEADER_SIZE + 
uncompressedSizeWithoutHeader;
+    HFileBlockReadAttributes readAttributes =
+        new HFileBlockReadAttributes(this.context, byteBuff, 
startOffsetInBuff);
+    this.readAttributesOpt = Option.of(readAttributes);
+  }
+
+  /**
+   * Initialize HFileBlock for write.
+   */
+  protected HFileBlock(HFileContext context,
+                       HFileBlockType blockType,
+                       long previousBlockOffset) {
+    this.context = context;
+    this.blockType = blockType;
+    HFileBlockWriteAttributes writeAttributes = new 
HFileBlockWriteAttributes.Builder()
+        .blockSize(context.getBlockSize())
+        .previousBlockOffset(previousBlockOffset)
+        .build();
+    writeAttributesOpt = Option.of(writeAttributes);

Review Comment:
   Done.



-- 
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]

Reply via email to