You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "wombatu-kun (via GitHub)" <gi...@apache.org> on 2026/10/16 06:14:15 UTC
Re: [PR] perf(io): Avoid per-entry KeyValue allocation in HFileDataBlock.seekTo [hudi]
wombatu-kun commented on code in PR #19021:
URL: https://github.com/apache/hudi/pull/19021#discussion_r3870596455
##########
hudi-io/src/main/java/org/apache/hudi/io/hfile/HFileDataBlock.java:
##########
@@ -96,39 +99,57 @@ static HFileDataBlock createDataBlockToWrite(HFileContext context,
int seekTo(HFileCursor cursor, Key key, int blockStartOffsetInFile) {
int relativeOffset = cursor.getOffset() - blockStartOffsetInFile;
int lastRelativeOffset = relativeOffset;
+ // The key-value cached at the starting position, if any. It is only consulted to re-cache it
+ // in the cursor when the lookup lands "in range" on the very first comparison; entries scanned
+ // past are compared directly against the backing buffer below (no per-entry KeyValue/Key
+ // allocation), so this is emptied after the first iteration and the cursor falls back to a
+ // deferred read.
Option<KeyValue> lastKeyValue = cursor.getKeyValue();
+ // The lookup key content is fixed across the scan; hoist it out of the loop. Note the lookup
+ // key may be a UTF8StringKey, so use the polymorphic content accessors (no 2-byte prefix).
+ byte[] lookupBytes = key.getBytes();
+ int lookupContentOffset = key.getContentOffset();
+ int lookupContentLength = key.getContentLength();
Review Comment:
Done ce844f731309
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org