Skip to content
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

HIVE-28584: Add the reader parameter when orcTail is initialized #5514

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions ql/src/java/org/apache/hadoop/hive/ql/io/orc/OrcInputFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
import org.apache.orc.StripeInformation;
import org.apache.orc.StripeStatistics;
import org.apache.orc.TypeDescription;
import org.apache.orc.impl.BufferChunk;
import org.apache.orc.impl.InStream;
import org.apache.orc.impl.OrcTail;
import org.apache.orc.impl.SchemaEvolution;
Expand Down Expand Up @@ -1669,8 +1670,13 @@ private void populateAndCacheStripeDetails() throws IOException {
OrcFile.readerOptions(context.conf)
.filesystem(fs)
.maxLength(context.isAcid ? AcidUtils.getLogicalLength(fs, file) : file.getLen()))) {
orcTail = new OrcTail(orcReader.getFileTail(), orcReader.getSerializedFileFooter(),
file.getModificationTime());
BufferChunk bufferChunk = new BufferChunk(orcReader.getSerializedFileFooter(),
getStripeStatisticsOffset(orcReader.getFileTail()));
orcTail = new OrcTail(orcReader.getFileTail(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Follow the ORC change: https://github.com/apache/orc/pull/549/files#diff-379a4569d065dfbffdc854790e0de07329025e608e0fb0f5bc03b8a4b9d00f92
Can we use Reader.getStripeStatistics in Apache Spark instead?

bufferChunk,
file.getModificationTime(),
orcReader);

if (context.cacheStripeDetails) {
context.footerCache.put(new FooterCacheKey(fsFileId, file.getPath()), orcTail);
}
Expand Down Expand Up @@ -1724,6 +1730,20 @@ private void populateAndCacheStripeDetails() throws IOException {
}
}

private long getMetadataOffset(OrcProto.FileTail tail) {
OrcProto.PostScript ps = tail.getPostscript();
return tail.getFileLength()
- 1
- tail.getPostscriptLength()
- ps.getFooterLength()
- ps.getMetadataLength();
}

private long getStripeStatisticsOffset(OrcProto.FileTail tail) {
OrcProto.PostScript ps = tail.getPostscript();
return getMetadataOffset(tail) - ps.getStripeStatisticsLength();
}

private long computeProjectionSize(List<OrcProto.Type> fileTypes,
List<OrcProto.ColumnStatistics> stats, boolean[] fileIncluded) throws FileFormatException {
// Exclude ORC <root> and ACID <row> struct elements to avoid full schema size estimation
Expand Down
Loading