Skip to content

Commit

Permalink
Fix supportVectoredIO for bad hadoop version string
Browse files Browse the repository at this point in the history
There are cases where the hadoop version info may not be respecting
the semantic versioning. It is the case for the hadoop version
provided in some of the AWS managed services. This causes
a ExceptionInInitializerError while trying to instantiate and ORC
file reader.

Fixing this by defaulting to non vectored IO in case the semantic
versioning is not respected
  • Loading branch information
otorreno committed Jul 25, 2024
1 parent e818d56 commit 0a06fd1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions java/shims/src/java/org/apache/orc/impl/HadoopShims.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,18 @@ ByteBuffer readBuffer(int maxLength,
boolean endVariableLengthBlock(OutputStream output) throws IOException;

default boolean supportVectoredIO() {
// HADOOP-18103 is available since Apache Hadoop 3.3.5+
String[] versionParts = VersionInfo.getVersion().split("[.]");
int major = Integer.parseInt(versionParts[0]);
int minor = Integer.parseInt(versionParts[1]);
int patch = Integer.parseInt(versionParts[2]);
return major == 3 && (minor > 3 || (minor == 3 && patch > 4));
try {
// HADOOP-18103 is available since Apache Hadoop 3.3.5+
String[] versionParts = VersionInfo.getVersion().split("[.]");
int major = Integer.parseInt(versionParts[0]);
int minor = Integer.parseInt(versionParts[1]);
int patch = Integer.parseInt(versionParts[2]);
return major == 3 && (minor > 3 || (minor == 3 && patch > 4));
} catch (final NumberFormatException e) {
// There could be cases where we are not able to parse the version
// Here we are defaulting to the non vectoredIO if that is the case
return false;
}
}

/**
Expand Down

0 comments on commit 0a06fd1

Please sign in to comment.