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


##########
hudi-common/src/main/java/org/apache/hudi/io/storage/HFileReaderFactory.java:
##########
@@ -55,9 +58,34 @@ public HFileReaderFactory(HoodieStorage storage,
   public HFileReader createHFileReader() throws IOException {
     final long fileSize = determineFileSize();
     final SeekableDataInputStream inputStream = createInputStream(fileSize);
+    
+    if (shouldEnableBlockCaching()) {
+      HFileReaderConfig config = createHFileReaderConfig();
+      String filePath = getFilePath();
+      return new CachingHFileReaderImpl(inputStream, fileSize, filePath, 
config);
+    }
+    
     return new HFileReaderImpl(inputStream, fileSize);
   }
 
+  private boolean shouldEnableBlockCaching() {
+    return metadataConfig.getHFileBlockCacheEnabled();
+  }
+
+  private HFileReaderConfig createHFileReaderConfig() {
+    int blockCacheSize = metadataConfig.getHFileBlockCacheSize();
+    int cacheTtlMinutes = metadataConfig.getHFileBlockCacheTTLMinutes();
+    return new HFileReaderConfig(blockCacheSize, cacheTtlMinutes);
+  }
+
+  private String getFilePath() {
+    if (fileSource.isLeft()) {
+      return fileSource.asLeft().toString();
+    }
+    // For byte array content, use a hash-based identifier
+    return "bytes:" + Arrays.hashCode(fileSource.asRight());

Review Comment:
   Let's track this in a separate PR too.



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