Github user arina-ielchiieva commented on a diff in the pull request:
https://github.com/apache/drill/pull/843#discussion_r118186385
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java
---
@@ -74,41 +70,43 @@ public String getClassName() {
* @return the imports of this class (for java code gen)
*/
public List<String> getImports() {
- checkInit();
+ loadFunctionBody();
return imports;
}
/**
- * @param methodName
+ * @param methodName method name
* @return the content of the method (for java code gen inlining)
*/
public String getMethod(String methodName) {
- checkInit();
+ loadFunctionBody();
return methods.get(methodName);
}
- private void checkInit() {
- if (ready) {
+ /**
+ * Loads function body: methods (for instance, eval, setup, reset) and
imports.
+ * Loading is done once per class instance upon first function
invocation.
+ * Double-checked locking is used to avoid concurrency issues
+ * when two threads are trying to load the function body at the same
time.
+ */
+ private void loadFunctionBody() {
+ if (isLoaded) {
return;
}
synchronized (this) {
- if (ready) {
+ if (isLoaded) {
return;
}
- // get function body.
-
+ logger.debug("Getting function body for the {}", className);
--- End diff --
Done.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---