-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-9336] Extract common logic of getting reader for secondary index #13212
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
Conversation
|
|
||
| Option<HoodieFileReader> baseFileReader = Option.empty(); | ||
| if (dataFilePath.isPresent()) { | ||
| baseFileReader = Option.of(HoodieIOFactory.getIOFactory(metaClient.getStorage()).getReaderFactory(recordMerger.getRecordType()).getFileReader(getReaderConfigs(storageConf), dataFilePath.get())); |
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.
This reader is never getting closed and it will lead to leaks.
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.
Yes. This is fixed now.
| Option<StoragePath> dataFilePath, | ||
| HoodieIndexDefinition indexDefinition, | ||
| String instantTime) throws Exception { | ||
| HoodieFileSliceReader fileSliceReader = |
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.
+1 for closing it after the iterator is consumed after while loop.
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.
Fixed now.
273427f to
6d3e45b
Compare
| import java.util.Map; | ||
| import java.util.Properties; | ||
|
|
||
| public class HoodieFileSliceReader<T> extends LogFileIterator<T> { |
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.
This class is going to be removed and all the usage will be replaced by HoodieFileGroupReader. So fixing the close behavior in a simple way in this PR.
|
|
||
| Option<HoodieFileReader> baseFileReader = Option.empty(); | ||
| if (dataFilePath.isPresent()) { | ||
| baseFileReader = Option.of(HoodieIOFactory.getIOFactory(metaClient.getStorage()).getReaderFactory(recordMerger.getRecordType()).getFileReader(getReaderConfigs(storageConf), dataFilePath.get())); |
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.
Yes. This is fixed now.
| metaClient.getTableConfig().getProps(), | ||
| Option.empty(), Option.empty()); | ||
| ClosableIterator<HoodieRecord> fileSliceIterator = ClosableIterator.wrap(fileSliceReader); | ||
| return new ClosableIterator<HoodieRecord>() { |
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.
This closable iterator and the file slice reader are going to be closed properly after #13178 is landed.
the-other-tim-brown
left a comment
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.
Overall the refactor looks good to me. I am assuming there are already tests covering these paths
Yes, existing tests cover the logic. |
Change Logs
This PR extracts common logic of getting the file slice reader for secondary index to reduce code duplication. It also makes changes to close resources in the file slice reader and the iterator for the secondary index properly.
Impact
Improves code maintainability and resource management
Risk level
none
Documentation Update
none
Contributor's checklist