[
https://issues.apache.org/jira/browse/DRILL-5533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16022514#comment-16022514
]
ASF GitHub Bot commented on DRILL-5533:
---------------------------------------
Github user arina-ielchiieva commented on a diff in the pull request:
https://github.com/apache/drill/pull/843#discussion_r118188385
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java
---
@@ -31,29 +31,25 @@
import org.codehaus.janino.Scanner;
import org.mortbay.util.IO;
-import com.google.common.collect.Maps;
-
/**
* To avoid the cost of initializing all functions up front,
- * this class contains all informations required to initializing a
function when it is used.
+ * this class contains all information required to initializing a function
when it is used.
*/
public class FunctionInitializer {
- static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(FunctionInitializer.class);
+ private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(FunctionInitializer.class);
private final String className;
private final ClassLoader classLoader;
- private Map<String, CompilationUnit> functionUnits = Maps.newHashMap();
--- End diff --
It was used in `convertToCompilationUnit`. Before loading function body we
checked if it was loaded before in `functionUnits` map. If not - function body
was loaded, if yes - previously loaded compilation unit was returned. With
incorrectly implemented DCL such check prevented us from loading function body
from disk each time, through threads were entering synchronized block anyway.
With correctly implemented DCL we don't need to store this intermediate result.
First thread will load all information about methods and imports, others will
use this information.
> Fix flag assignment in FunctionInitializer.checkInit() method
> -------------------------------------------------------------
>
> Key: DRILL-5533
> URL: https://issues.apache.org/jira/browse/DRILL-5533
> Project: Apache Drill
> Issue Type: Bug
> Affects Versions: 1.10.0
> Reporter: Arina Ielchiieva
> Assignee: Arina Ielchiieva
> Priority: Minor
>
> FunctionInitializer.checkInit() method uses DCL to ensure that function body
> is loaded only once. But flag parameter is never updated and all threads are
> entering synchronized block.
> Also FunctionInitializer.getImports() always returns empty list.
> https://github.com/apache/drill/blob/3e8b01d5b0d3013e3811913f0fd6028b22c1ac3f/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/FunctionInitializer.java
> Changes:
> 1. Fix DCL in FunctionInitializer.checkInit() method (update flag parameter
> when function body is loaded).
> 2. Fix ImportGrabber.getImports() method to return list with imports.
> 3. Add unit tests for FunctionInitializer.
> 4. Minor refactoring (rename methods, add javadoc).
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)