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
Build AcidInfo only for ORC-ACID tables #8259
Closed
losipiuk
wants to merge
5
commits into
trinodb:master
from
losipiuk:lo/fix-read-insert-only-tables-2
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
827ad35
Build AcidInfo only for ORC-ACID tables
losipiuk 2d9db0b
empty
findepi 2b2cd75
fixup! Build AcidInfo only for ORC-ACID tables
findepi b7b0d54
fixup! Build AcidInfo only for ORC-ACID tables
findepi 38332e2
fixup! Build AcidInfo only for ORC-ACID tables
findepi File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -483,6 +483,7 @@ private ListenableFuture<?> loadPartition(HivePartitionMetadata partition) | |
List<Path> readPaths; | ||
List<HdfsFileStatusWithId> fileStatusOriginalFiles = ImmutableList.of(); | ||
AcidInfo.Builder acidInfoBuilder = AcidInfo.builder(path); | ||
boolean isFullAcid = AcidUtils.isFullAcidTable(table.getParameters()); | ||
if (AcidUtils.isTransactionalTable(table.getParameters())) { | ||
AcidUtils.Directory directory = hdfsEnvironment.doAs(hdfsContext.getIdentity().getUser(), () -> AcidUtils.getAcidState( | ||
path, | ||
|
@@ -491,7 +492,7 @@ private ListenableFuture<?> loadPartition(HivePartitionMetadata partition) | |
false, | ||
true)); | ||
|
||
if (AcidUtils.isFullAcidTable(table.getParameters())) { | ||
if (isFullAcid) { | ||
// From Hive version >= 3.0, delta/base files will always have file '_orc_acid_version' with value >= '2'. | ||
Path baseOrDeltaPath = directory.getBaseDirectory() != null | ||
? directory.getBaseDirectory() | ||
|
@@ -566,24 +567,35 @@ private ListenableFuture<?> loadPartition(HivePartitionMetadata partition) | |
e.getNestedDirectoryPath(), | ||
splitFactory.getPartitionName())); | ||
} | ||
lastResult = hiveSplitSource.addToQueue(getBucketedSplits(files, splitFactory, tableBucketInfo.get(), bucketConversion, splittable, acidInfoBuilder.build())); | ||
Optional<AcidInfo> acidInfo = Optional.empty(); | ||
if (isFullAcid) { | ||
acidInfo = acidInfoBuilder.build(); | ||
} | ||
lastResult = hiveSplitSource.addToQueue(getBucketedSplits(files, splitFactory, tableBucketInfo.get(), bucketConversion, splittable, acidInfo)); | ||
} | ||
|
||
for (HdfsFileStatusWithId hdfsFileStatusWithId : fileStatusOriginalFiles) { | ||
List<LocatedFileStatus> locatedFileStatuses = ImmutableList.of((LocatedFileStatus) hdfsFileStatusWithId.getFileStatus()); | ||
Optional<AcidInfo> acidInfo = Optional.of(acidInfoBuilder.buildWithRequiredOriginalFiles(getRequiredBucketNumber(hdfsFileStatusWithId.getFileStatus().getPath()))); | ||
Optional<AcidInfo> acidInfo = Optional.empty(); | ||
if (isFullAcid) { | ||
acidInfo = Optional.of(acidInfoBuilder.buildWithRequiredOriginalFiles(getRequiredBucketNumber(hdfsFileStatusWithId.getFileStatus().getPath()))); | ||
} | ||
lastResult = hiveSplitSource.addToQueue(getBucketedSplits(locatedFileStatuses, splitFactory, tableBucketInfo.get(), bucketConversion, splittable, acidInfo)); | ||
} | ||
|
||
return lastResult; | ||
} | ||
|
||
for (Path readPath : readPaths) { | ||
fileIterators.addLast(createInternalHiveSplitIterator(readPath, fs, splitFactory, splittable, acidInfoBuilder.build())); | ||
Optional<AcidInfo> acidInfo = Optional.empty(); | ||
if (isFullAcid) { | ||
acidInfo = acidInfoBuilder.build(); | ||
} | ||
fileIterators.addLast(createInternalHiveSplitIterator(readPath, fs, splitFactory, splittable, acidInfo)); | ||
} | ||
|
||
if (!fileStatusOriginalFiles.isEmpty()) { | ||
fileIterators.addLast(generateOriginalFilesSplits(splitFactory, fileStatusOriginalFiles, splittable, acidInfoBuilder)); | ||
fileIterators.addLast(generateOriginalFilesSplits(splitFactory, fileStatusOriginalFiles, splittable, acidInfoBuilder, isFullAcid)); | ||
} | ||
|
||
return COMPLETED_FUTURE; | ||
|
@@ -703,12 +715,16 @@ private Iterator<InternalHiveSplit> generateOriginalFilesSplits( | |
InternalHiveSplitFactory splitFactory, | ||
List<HdfsFileStatusWithId> originalFileLocations, | ||
boolean splittable, | ||
AcidInfo.Builder acidInfoBuilder) | ||
AcidInfo.Builder acidInfoBuilder, | ||
boolean isFullAcid) | ||
Comment on lines
+718
to
+719
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. should |
||
{ | ||
return originalFileLocations.stream() | ||
.map(HdfsFileStatusWithId::getFileStatus) | ||
.map(fileStatus -> { | ||
Optional<AcidInfo> acidInfo = Optional.of(acidInfoBuilder.buildWithRequiredOriginalFiles(getRequiredBucketNumber(fileStatus.getPath()))); | ||
Optional<AcidInfo> acidInfo = Optional.empty(); | ||
if (isFullAcid) { | ||
acidInfo = Optional.of(acidInfoBuilder.buildWithRequiredOriginalFiles(getRequiredBucketNumber(fileStatus.getPath()))); | ||
} | ||
return splitFactory.createInternalHiveSplit( | ||
(LocatedFileStatus) fileStatus, | ||
OptionalInt.empty(), | ||
|
This file contains 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
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.
since the method is long anyway, let's use
?:
for brevity and to have variables final.