yihua opened a new pull request, #19083:
URL: https://github.com/apache/hudi/pull/19083

   ### Describe the issue this Pull Request addresses
   
   Stacked on top of #19071 (please review that first). On top of the 
HBase-readable block-index work there, the native HFile writer still wrote an 
incorrect "previous block offset" in every data block header for multi-block 
files.
   
   `HFileWriterImpl.flushCurrentDataBlock()` started each new data block with 
`currentOffset` (where the new block begins) instead of `lastDataBlockOffset` 
(the block just written), so every data block after the first recorded its own 
offset as the previous-block offset. The first block is `-1`, so the 
single-block golden tests in #19071 never exercised it.
   
   ### Summary and Changelog
   
   - `HFileWriterImpl`: pass `lastDataBlockOffset` (not `currentOffset`) when 
creating the next data block, so the previous-block-offset header points at the 
prior block.
   - `TestHFileReadCompatibility`: add 
`hbaseReaderSeekBeforeWorksOnNativeMultiBlockFile`, which reads a 
native-written multi-block file with the HBase reader and asserts 
`seekBefore(key(i))` returns `key(i - 1)` for every record.
   
   The native `hudi-io` reader is forward-only (`seekTo` / `next`) and never 
reads this field, so the bug is latent for Hudi's own reads. The HBase reader 
uses it in `HFileScanner.seekBefore()` to step back to the prior block; with 
the wrong value it re-reads the same block and throws `IllegalStateException: 
blockSeek with seekBefore at the first key of the block` at every block 
boundary.
   
   ### Impact
   
   Storage-format / cross-reader compatibility: an HBase reader can now 
`seekBefore` (reverse positioning) over native-written multi-block HFiles. No 
public API change; no change to single-block files or to forward reads/point 
lookups.
   
   ### Risk Level
   
   low
   
   The fix only changes the previous-block-offset header (an 8-byte field 
already written); the native reader ignores it and forward reads are 
unaffected. The new HBase-reader regression test was verified to throw 
`IllegalStateException` against the pre-fix writer and to pass after the fix.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [x] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [x] Enough context is provided in the sections above
   - [x] Adequate tests were added if applicable
   


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