You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by st...@apache.org on 2024/01/02 20:31:56 UTC
(hadoop-api-shim) 03/03: more reflection work while doing the parquet integrated binding
This is an automated email from the ASF dual-hosted git repository.
stevel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hadoop-api-shim.git
commit 260d8095d77ff02accfa76326710b9f48748c95a
Author: Steve Loughran <st...@cloudera.com>
AuthorDate: Tue Jan 2 20:31:41 2024 +0000
more reflection work while doing the parquet integrated binding
---
.../org/apache/hadoop/fs/shim/impl/FileRangeBridge.java | 10 ++--------
.../hadoop/fs/shim/impl/ShimReflectionSupport.java | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/FileRangeBridge.java b/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/FileRangeBridge.java
index 912c63c..6191554 100644
--- a/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/FileRangeBridge.java
+++ b/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/FileRangeBridge.java
@@ -63,14 +63,7 @@ public final class FileRangeBridge {
public FileRangeBridge() {
// try to load the class
- Class<?> cl;
- try {
- cl = this.getClass().getClassLoader().loadClass(CLASSNAME);
- } catch (ClassNotFoundException e) {
- LOG.debug("No {}", CLASSNAME);
- cl = null;
- }
- fileRangeInterface = cl;
+ fileRangeInterface = ShimReflectionSupport.loadClass(CLASSNAME);
// class found, so load the methods
_getOffset = loadInvocation(fileRangeInterface, long.class, "getOffset");
_getLength = loadInvocation(fileRangeInterface, int.class, "getLength");
@@ -84,6 +77,7 @@ public final class FileRangeBridge {
}
+
/**
* Is the bridge available.
*
diff --git a/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/ShimReflectionSupport.java b/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/ShimReflectionSupport.java
index 804dfa6..183a182 100644
--- a/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/ShimReflectionSupport.java
+++ b/hadoop-api-shim/src/main/java/org/apache/hadoop/fs/shim/impl/ShimReflectionSupport.java
@@ -268,4 +268,21 @@ public final class ShimReflectionSupport {
}
return result.toString();
}
+
+
+ /**
+ * Load a class; return null if it is not found.
+ * @param name classname.
+ * @return the class, if found
+ */
+ public static Class<?> loadClass(final String name) {
+ Class<?> cl;
+ try {
+ cl = ShimReflectionSupport.class.getClassLoader().loadClass(name);
+ } catch (ClassNotFoundException e) {
+ LOG.debug("No {}", name);
+ cl = null;
+ }
+ return cl;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org