Skip to content

Conversation

@yihua
Copy link
Contributor

@yihua yihua commented Apr 23, 2025

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

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@github-actions github-actions bot added the size:S PR with lines of changes in (10, 100] label Apr 23, 2025

Option<HoodieFileReader> baseFileReader = Option.empty();
if (dataFilePath.isPresent()) {
baseFileReader = Option.of(HoodieIOFactory.getIOFactory(metaClient.getStorage()).getReaderFactory(recordMerger.getRecordType()).getFileReader(getReaderConfigs(storageConf), dataFilePath.get()));
Copy link
Contributor

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.

Copy link
Contributor Author

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 =
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed now.

@yihua yihua force-pushed the HUDI-9336-extract-reader-logic branch from 273427f to 6d3e45b Compare April 25, 2025 21:27
@github-actions github-actions bot added size:M PR with lines of changes in (100, 300] and removed size:S PR with lines of changes in (10, 100] labels Apr 25, 2025
import java.util.Map;
import java.util.Properties;

public class HoodieFileSliceReader<T> extends LogFileIterator<T> {
Copy link
Contributor Author

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()));
Copy link
Contributor Author

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>() {
Copy link
Contributor Author

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.

@hudi-bot
Copy link
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Copy link
Contributor

@the-other-tim-brown the-other-tim-brown left a 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

@yihua
Copy link
Contributor Author

yihua commented May 2, 2025

Overall the refactor looks good to me. I am assuming there are already tests covering these paths

Yes, existing tests cover the logic.

@codope codope merged commit e4d01dd into apache:master May 2, 2025
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants