voonhous commented on code in PR #13724:
URL: https://github.com/apache/hudi/pull/13724#discussion_r2284076407


##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileReaderImpl.java:
##########
@@ -20,379 +20,67 @@
 package org.apache.hudi.io.hfile;
 
 import org.apache.hudi.common.util.Option;
-import org.apache.hudi.common.util.ValidationUtils;
 import org.apache.hudi.io.SeekableDataInputStream;
 
-import org.apache.logging.log4j.util.Strings;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.TreeMap;
-
-import static org.apache.hudi.io.hfile.HFileBlock.HFILEBLOCK_HEADER_SIZE;
-import static org.apache.hudi.io.hfile.HFileUtils.readMajorVersion;
 
 /**
  * An implementation a {@link HFileReader}.
  */
-public class HFileReaderImpl implements HFileReader {
-  private final SeekableDataInputStream stream;
-  private final long fileSize;
-
-  private final HFileCursor cursor;
-  private boolean isMetadataInitialized = false;
-  private HFileTrailer trailer;
-  private HFileContext context;
-  private TreeMap<Key, BlockIndexEntry> dataBlockIndexEntryMap;
-  private TreeMap<Key, BlockIndexEntry> metaBlockIndexEntryMap;
-  private HFileInfo fileInfo;
-  private Option<BlockIndexEntry> currentDataBlockEntry;
-  private Option<HFileDataBlock> currentDataBlock;
+public class HFileReaderImpl extends BaseHFileReaderImpl {
 
   public HFileReaderImpl(SeekableDataInputStream stream, long fileSize) {
-    this.stream = stream;
-    this.fileSize = fileSize;
-    this.cursor = new HFileCursor();
-    this.currentDataBlockEntry = Option.empty();
-    this.currentDataBlock = Option.empty();
+    super(stream, fileSize);
   }
 
   @Override
   public synchronized void initializeMetadata() throws IOException {
-    if (this.isMetadataInitialized) {
-      return;
-    }
-
-    // Read Trailer (serialized in Proto)
-    this.trailer = readTrailer(stream, fileSize);
-    this.context = HFileContext.builder()
-        .compressionCodec(trailer.getCompressionCodec())
-        .build();
-    HFileBlockReader blockReader = new HFileBlockReader(
-        context, stream, trailer.getLoadOnOpenDataOffset(),
-        fileSize - HFileTrailer.getTrailerSize());
-    this.dataBlockIndexEntryMap = readDataBlockIndex(
-        blockReader, trailer.getDataIndexCount(), 
trailer.getNumDataIndexLevels());
-    HFileRootIndexBlock metaIndexBlock =
-        (HFileRootIndexBlock) blockReader.nextBlock(HFileBlockType.ROOT_INDEX);
-    this.metaBlockIndexEntryMap = 
metaIndexBlock.readBlockIndex(trailer.getMetaIndexCount(), true);
-    HFileFileInfoBlock fileInfoBlock =
-        (HFileFileInfoBlock) blockReader.nextBlock(HFileBlockType.FILE_INFO);
-    this.fileInfo = fileInfoBlock.readFileInfo();
-    this.isMetadataInitialized = true;
+    super.initializeMetadata();

Review Comment:
   Oops, let me fix this, in retrospect, this is unnecessary, 
`BaseHFileReaderImpl` should be renamed to `HFileReaderImpl`.



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