Repository navigation
Added BlockCache to HFile reader. #13427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pacificleo
wants to merge
2
commits into
apache:release-0.14.2
Choose a base branch
from
pacificleo:pw_blockcache_hfile
base: release-0.14.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,8 +24,10 @@ | |
| import org.apache.hudi.common.model.HoodieRecord; | ||
| import org.apache.hudi.common.model.HoodieRecord.HoodieRecordType; | ||
| import org.apache.hudi.common.util.Option; | ||
| import org.apache.hudi.common.util.StringUtils; | ||
| import org.apache.hudi.common.util.collection.ClosableIterator; | ||
| import org.apache.hudi.common.util.collection.CloseableMappingIterator; | ||
| import org.apache.hudi.common.util.hash.HashID; | ||
| import org.apache.hudi.exception.HoodieException; | ||
| import org.apache.hudi.exception.HoodieIOException; | ||
| import org.apache.hudi.io.storage.HoodieAvroHFileReader; | ||
|
|
@@ -176,7 +178,7 @@ protected <T> ClosableIterator<HoodieRecord<T>> deserializeRecords(byte[] conten | |
| Configuration hadoopConf = FSUtils.buildInlineConf(getBlockContentLocation().get().getHadoopConf()); | ||
| FileSystem fs = FSUtils.getFs(pathForReader.toString(), hadoopConf); | ||
| // Read the content | ||
| try (HoodieAvroHFileReader reader = new HoodieAvroHFileReader(hadoopConf, pathForReader, new CacheConfig(hadoopConf), | ||
| try (HoodieAvroHFileReader reader = new HoodieAvroHFileReader(hadoopConf, pathForReader, | ||
| fs, content, Option.of(getSchemaFromHeader()))) { | ||
| return unsafeCast(reader.getRecordIterator(readerSchema)); | ||
| } | ||
|
|
@@ -197,9 +199,15 @@ protected <T> ClosableIterator<HoodieRecord<T>> lookupRecords(List<String> sorte | |
| blockContentLoc.getContentPositionInLogFile(), | ||
| blockContentLoc.getBlockSize()); | ||
|
|
||
| // HFile BlockCache key is based on the name of the file. The inlinefs path has the format | ||
| // inlinefs://<path_to_outer_file>/<outer_file_scheme>/?start_offset=start_offset>&length=<length> whose filename | ||
| // component is parsed as "?start_offset=start_offset>&length=<length>" ignoring the actual outer file itself. | ||
| // To keep this unique (as cache keys should be unique for each file), we add a hash which is calculated from the | ||
| // entire filename. So the cache key would now be ?start_offset=start_offset>&length=<length>&pathHash=<hash> | ||
| final String pathHash = StringUtils.toHexString(HashID.hash(inlinePath.toString(), HashID.Size.BITS_128)); | ||
| Path cachableInlinePath = new Path(inlinePath.toString() + "&pathHash=" + pathHash); | ||
| try (final HoodieAvroHFileReader reader = | ||
| new HoodieAvroHFileReader(inlineConf, inlinePath, new CacheConfig(inlineConf), inlinePath.getFileSystem(inlineConf), | ||
| Option.of(getSchemaFromHeader()))) { | ||
| new HoodieAvroHFileReader(inlineConf, cachableInlinePath, inlinePath.getFileSystem(inlineConf), Option.of(getSchemaFromHeader()))) { | ||
| // Get writer's schema from the header | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 nit: small typo — - AI-generated; verify before applying. React 👍/👎 to flag quality. |
||
| final ClosableIterator<HoodieRecord<IndexedRecord>> recordIterator = | ||
| fullKey ? reader.getRecordsByKeysIterator(sortedKeys, readerSchema) : reader.getRecordsByKeyPrefixIterator(sortedKeys, readerSchema); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖
matcher.find()return value isn't checked here (and the same below on line 123 forlength). If the path doesn't contain?start_offset=<digits>for any reason,matcher.group(1)will throwIllegalStateException("No match found")with no path context — making diagnosis harder than the previous split-based failure. Could you checkfind()and throw aHoodieExceptionwith the offending path instead?- AI-generated; verify before applying. React 👍/👎 to flag quality.