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


##########
hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieNativeAvroHFileReader.java:
##########
@@ -127,8 +128,17 @@ public String[] readMinMaxRecordKeys() {
   @Override
   public BloomFilter readBloomFilter() {
     try (HFileReader reader = newHFileReader()) {
+      // 1. Position points to the offset of first key-value pair.
       ByteBuffer byteBuffer = 
reader.getMetaBlock(KEY_BLOOM_FILTER_META_BLOCK).get();
-      return BloomFilterFactory.fromByteBuffer(byteBuffer,
+      // 2. Try to get the bytes for value only.
+      int keyLength = 10 + 
StringUtils.getUTF8Bytes(KEY_BLOOM_FILTER_META_BLOCK).length;
+      int valueLength = byteBuffer.limit() - keyLength - 1 - 
byteBuffer.position();
+      byte[] bloomFilterBytes = new byte[valueLength];
+      byteBuffer.position(keyLength + byteBuffer.position());
+      byteBuffer.get(bloomFilterBytes, 0, valueLength);
+      // 3. Deserialize value bytes into bloom filter.
+      return BloomFilterFactory.fromByteBuffer(
+          ByteBuffer.wrap(bloomFilterBytes),

Review Comment:
   If not, the reader test logic should not change.



##########
hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieNativeAvroHFileReader.java:
##########
@@ -127,8 +128,17 @@ public String[] readMinMaxRecordKeys() {
   @Override
   public BloomFilter readBloomFilter() {
     try (HFileReader reader = newHFileReader()) {
+      // 1. Position points to the offset of first key-value pair.
       ByteBuffer byteBuffer = 
reader.getMetaBlock(KEY_BLOOM_FILTER_META_BLOCK).get();
-      return BloomFilterFactory.fromByteBuffer(byteBuffer,
+      // 2. Try to get the bytes for value only.
+      int keyLength = 10 + 
StringUtils.getUTF8Bytes(KEY_BLOOM_FILTER_META_BLOCK).length;
+      int valueLength = byteBuffer.limit() - keyLength - 1 - 
byteBuffer.position();
+      byte[] bloomFilterBytes = new byte[valueLength];
+      byteBuffer.position(keyLength + byteBuffer.position());
+      byteBuffer.get(bloomFilterBytes, 0, valueLength);
+      // 3. Deserialize value bytes into bloom filter.
+      return BloomFilterFactory.fromByteBuffer(
+          ByteBuffer.wrap(bloomFilterBytes),

Review Comment:
   Does the way of writing and reading data in the meta block change? That can 
break the compatibility.



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