This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit c004cc686df8b258bc19610b7c4c8df8507367a1
Author: Steve Carlin <scar...@cloudera.com>
AuthorDate: Sat Feb 20 08:43:32 2021 -0800

    IMPALA-10525: Add param to BuiltinsDb to defer initialization
    
    BuiltinsDb currently initializes all the builtin functions on
    initialization. Part of the initialization task is to interact with
    the C++ code to fetch the signatures of the functions.  This doesn't
    work if a third party extension wants to use the BuiltinsDb but does
    not have access to the C++ library at runtime.
    
    The solution is to add an alternative way to initalize the BuiltinsDb,
    through a Loader class.
    
    Change-Id: I1941a2494efe15b63514d849873eeb1c4ed8a981
    Reviewed-on: http://gerrit.cloudera.org:8080/17093
    Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
    Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com>
---
 .../main/java/org/apache/impala/catalog/BuiltinsDb.java  | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/fe/src/main/java/org/apache/impala/catalog/BuiltinsDb.java 
b/fe/src/main/java/org/apache/impala/catalog/BuiltinsDb.java
index bc29fd4..6a1a609 100644
--- a/fe/src/main/java/org/apache/impala/catalog/BuiltinsDb.java
+++ b/fe/src/main/java/org/apache/impala/catalog/BuiltinsDb.java
@@ -70,7 +70,7 @@ public class BuiltinsDb extends Db {
   // Size in bytes of RankState used for rank() and dense_rank().
   private static final int RANK_INTERMEDIATE_SIZE = 16;
 
-  private static BuiltinsDb INSTANCE;
+  private static Db INSTANCE;
 
   public static final String NAME = "_impala_builtins";
 
@@ -81,6 +81,13 @@ public class BuiltinsDb extends Db {
     return INSTANCE;
   }
 
+  public static synchronized Db getInstance(BuiltinsDbLoader loader) {
+    if (INSTANCE == null) {
+      INSTANCE = loader.getBuiltinsDbInstance();
+    }
+    return INSTANCE;
+  }
+
   private BuiltinsDb() {
     super(NAME, createMetastoreDb(NAME));
     setIsSystemDb(true);
@@ -1524,4 +1531,11 @@ public class BuiltinsDb extends Db {
     }
     return null;
   }
+
+  /**
+   * BuiltinsDbLoader allows a third party extension to create their own 
BuiltinsDb.
+   */
+  public interface BuiltinsDbLoader {
+    Db getBuiltinsDbInstance();
+  }
 }

Reply via email to