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


##########
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:
   What is the overhead of computing the hash code of a large byte array from a 
large HFile block?



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