-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-3454] Fix partition name in all code paths for LogRecordScanner #5252
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
Merged
codope
merged 2 commits into
apache:master
from
codope:HUDI-3454-init-log-reader-with-partition
Apr 8, 2022
Merged
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,7 @@ | |
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import static org.apache.hudi.common.fs.FSUtils.getRelativePartitionPath; | ||
| import static org.apache.hudi.common.testutils.SchemaTestUtil.getSimpleSchema; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
|
@@ -574,12 +575,13 @@ public void testBasicAppendAndScanMultipleFiles(ExternalSpillableMap.DiskMapType | |
| writer.close(); | ||
| FileCreateUtils.createDeltaCommit(basePath, "100", fs); | ||
| // scan all log blocks (across multiple log files) | ||
| List<String> logFilePaths = logFiles.stream() | ||
| .map(logFile -> logFile.getPath().toString()).collect(Collectors.toList()); | ||
| assertTrue(logFilePaths.size() > 0); | ||
| HoodieMergedLogRecordScanner scanner = HoodieMergedLogRecordScanner.newBuilder() | ||
| .withFileSystem(fs) | ||
| .withBasePath(basePath) | ||
| .withLogFilePaths( | ||
| logFiles.stream() | ||
| .map(logFile -> logFile.getPath().toString()).collect(Collectors.toList())) | ||
| .withLogFilePaths(logFilePaths) | ||
| .withReaderSchema(schema) | ||
| .withLatestInstantTime("100") | ||
| .withMaxMemorySizeInBytes(10240L) | ||
|
|
@@ -589,6 +591,7 @@ public void testBasicAppendAndScanMultipleFiles(ExternalSpillableMap.DiskMapType | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(logFilePaths.get(0)).getParent())) | ||
| .build(); | ||
|
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. Can we inline the fix into the HoodieMergedLogRecordScanner so that there is no need to change these classes ? |
||
|
|
||
| List<IndexedRecord> scannedRecords = new ArrayList<>(); | ||
|
|
@@ -803,6 +806,7 @@ public void testAvroLogRecordReaderBasic(ExternalSpillableMap.DiskMapType diskMa | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(200, scanner.getTotalLogRecords()); | ||
| Set<String> readKeys = new HashSet<>(200); | ||
|
|
@@ -881,6 +885,7 @@ public void testAvroLogRecordReaderWithRollbackTombstone(ExternalSpillableMap.Di | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(200, scanner.getTotalLogRecords(), "We read 200 records from 2 write batches"); | ||
| Set<String> readKeys = new HashSet<>(200); | ||
|
|
@@ -968,6 +973,7 @@ public void testAvroLogRecordReaderWithFailedPartialBlock(ExternalSpillableMap.D | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(200, scanner.getTotalLogRecords(), "We would read 200 records"); | ||
| Set<String> readKeys = new HashSet<>(200); | ||
|
|
@@ -1046,6 +1052,7 @@ public void testAvroLogRecordReaderWithDeleteAndRollback(ExternalSpillableMap.Di | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
|
|
||
| assertEquals(200, scanner.getTotalLogRecords(), "We still would read 200 records"); | ||
|
|
@@ -1092,6 +1099,7 @@ public void testAvroLogRecordReaderWithDeleteAndRollback(ExternalSpillableMap.Di | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| scanner.forEach(s -> readKeys.add(s.getKey().getRecordKey())); | ||
| assertEquals(200, readKeys.size(), "Stream collect should return all 200 records after rollback of delete"); | ||
|
|
@@ -1187,6 +1195,7 @@ public void testAvroLogRecordReaderWithDisorderDelete(ExternalSpillableMap.DiskM | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
|
|
||
| assertEquals(200, scanner.getTotalLogRecords(), "We still would read 200 records"); | ||
|
|
@@ -1290,6 +1299,7 @@ public void testAvroLogRecordReaderWithFailedRollbacks(ExternalSpillableMap.Disk | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(0, scanner.getTotalLogRecords(), "We would have scanned 0 records because of rollback"); | ||
|
|
||
|
|
@@ -1358,6 +1368,7 @@ public void testAvroLogRecordReaderWithInsertDeleteAndRollback(ExternalSpillable | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(0, scanner.getTotalLogRecords(), "We would read 0 records"); | ||
| FileCreateUtils.deleteDeltaCommit(basePath, "100", fs); | ||
|
|
@@ -1409,6 +1420,7 @@ public void testAvroLogRecordReaderWithInvalidRollback(ExternalSpillableMap.Disk | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(100, scanner.getTotalLogRecords(), "We still would read 100 records"); | ||
| final List<String> readKeys = new ArrayList<>(100); | ||
|
|
@@ -1479,6 +1491,7 @@ public void testAvroLogRecordReaderWithInsertsDeleteAndRollback(ExternalSpillabl | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(0, scanner.getTotalLogRecords(), "We would read 0 records"); | ||
| } | ||
|
|
@@ -1585,6 +1598,7 @@ public void testAvroLogRecordReaderWithMixedInsertsCorruptsAndRollback(ExternalS | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
| assertEquals(0, scanner.getTotalLogRecords(), "We would read 0 records"); | ||
| FileCreateUtils.deleteDeltaCommit(basePath, "100", fs); | ||
|
|
@@ -1659,6 +1673,7 @@ private void testAvroLogRecordReaderMergingMultipleLogFiles(int numRecordsInLog1 | |
| .withSpillableMapBasePath(BASE_OUTPUT_PATH) | ||
| .withDiskMapType(diskMapType) | ||
| .withBitCaskDiskMapCompressionEnabled(isCompressionEnabled) | ||
| .withPartition(getRelativePartitionPath(new Path(basePath), new Path(allLogFiles.get(0)).getParent())) | ||
| .build(); | ||
|
|
||
| assertEquals(Math.max(numRecordsInLog1, numRecordsInLog2), scanner.getNumMergedRecordsInLog(), | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.