You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/06/09 20:16:51 UTC

[GitHub] [incubator-pinot] Jackie-Jiang opened a new pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Jackie-Jiang opened a new pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531


   The problem is caused by Reflections library not being thread-safe when multiple threads are accessing the same jar file.
   Read more about the thread-safety issue here: https://github.com/ronmamo/reflections/issues/81
   Users are reporting the same issue even with the latest Reflections version 0.9.12.
   A common solution is to downgrade Reflections to 0.9.9, but we have other dependencies rely on 0.9.11, so downgrading might cause other issues.
   
   The solution introduced here is by replacing the static block with an init() method so that we can control when to scan the files to avoid the thread-safety issue.
   Another benefit of using an init() method is that the exception won't be swallowed (the exception in static block will be swallowed and query engine will start getting ClassNotFoundException)
   
   This PR also introduces a convention for the plugin methods using reflection, where the class must includes ".function." in its class path.
   This can significantly reduce the time of class scanning (reduced from 4 seconds to 200 ms locally)
   
   
   ## Description
   Add a description of your PR here.
   A good description should include pointers to an issue or design document, etc.
   ## Upgrade Notes
   Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
   * [ ] Yes (Please label as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
   
   Does this PR fix a zero-downtime upgrade introduced earlier?
   * [ ] Yes (Please label this as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
   
   Does this PR otherwise need attention when creating release notes? Things to consider:
   - New configuration options
   - Deprecation of configurations
   - Signature changes to public methods/interfaces
   - New plugins added or old plugins removed
   * [ ] Yes (Please label this PR as **<code>release-notes</code>** and complete the section on Release Notes)
   ## Release Notes
   If you have tagged this as either backward-incompat or release-notes,
   you MUST add text here that you would like to see appear in release notes of the
   next release.
   
   If you have a series of commits adding or enabling a feature, then
   add this section only in final commit that marks the feature completed.
   Refer to earlier release notes to see examples of text
   
   ## Documentation
   If you have introduced a new feature or configuration, please add it to the documentation as well.
   See https://docs.pinot.apache.org/developers/developers-and-contributors/update-document


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437743484



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
##########
@@ -39,62 +38,63 @@
  */
 public class FunctionRegistry {
   private static final Logger LOGGER = LoggerFactory.getLogger(FunctionRegistry.class);
-  private static final Map<String, FunctionInfo> _functionInfoMap = new HashMap<>();
+  private static final Map<String, FunctionInfo> FUNCTION_INFO_MAP = new HashMap<>();
+
+  private static boolean _initialized = false;
 
   /**
-   * Given a function name, asserts that a corresponding function was registered during construction and returns it
+   * Initializes the FunctionRegistry by registering the scalar functions via reflection.
+   * NOTE: In order to plugin methods using reflection, the methods should be inside a class that includes ".function."
+   *       in its class path. This convention can significantly reduce the time of class scanning.
    */
-  public static FunctionInfo getFunctionByName(String functionName) {
-    Preconditions.checkArgument(_functionInfoMap.containsKey(functionName.toLowerCase()));
-    return _functionInfoMap.get(functionName.toLowerCase());
+  public static synchronized void init() {
+    if (_initialized) {
+      LOGGER.info("FunctionRegistry is already initialized");
+      return;
+    }
+
+    long startTimeMs = System.currentTimeMillis();
+    Reflections reflections = new Reflections(
+        new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
+            .filterInputsBy(new FilterBuilder.Include(".*\\.function\\..*"))
+            .setScanners(new MethodAnnotationsScanner()));
+    Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
+    for (Method method : methodSet) {
+      ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
+      if (scalarFunction.enabled()) {
+        if (!scalarFunction.name().isEmpty()) {
+          FunctionRegistry.registerFunction(scalarFunction.name(), method);
+        } else {
+          FunctionRegistry.registerFunction(method);
+        }
+      }
+    }
+    LOGGER.info("Initialized FunctionRegistry within {}ms", System.currentTimeMillis() - startTimeMs);

Review comment:
       It was taking several seconds before adding filter on the class path. That is another reason why we should explicitly initialize it instead of waiting for class loader to run the static block. Before the change, the reflection happens when the first query arrives, which means the first query have to wait for several seconds. Right now it should take ~200ms, and it happens in the instance setup.
   Added the map size and functions registered.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437750886



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
##########
@@ -39,62 +38,63 @@
  */
 public class FunctionRegistry {
   private static final Logger LOGGER = LoggerFactory.getLogger(FunctionRegistry.class);
-  private static final Map<String, FunctionInfo> _functionInfoMap = new HashMap<>();
+  private static final Map<String, FunctionInfo> FUNCTION_INFO_MAP = new HashMap<>();
+
+  private static boolean _initialized = false;
 
   /**
-   * Given a function name, asserts that a corresponding function was registered during construction and returns it
+   * Initializes the FunctionRegistry by registering the scalar functions via reflection.
+   * NOTE: In order to plugin methods using reflection, the methods should be inside a class that includes ".function."
+   *       in its class path. This convention can significantly reduce the time of class scanning.
    */
-  public static FunctionInfo getFunctionByName(String functionName) {
-    Preconditions.checkArgument(_functionInfoMap.containsKey(functionName.toLowerCase()));
-    return _functionInfoMap.get(functionName.toLowerCase());
+  public static synchronized void init() {
+    if (_initialized) {
+      LOGGER.info("FunctionRegistry is already initialized");
+      return;
+    }
+
+    long startTimeMs = System.currentTimeMillis();
+    Reflections reflections = new Reflections(
+        new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
+            .filterInputsBy(new FilterBuilder.Include(".*\\.function\\..*"))
+            .setScanners(new MethodAnnotationsScanner()));
+    Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
+    for (Method method : methodSet) {
+      ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
+      if (scalarFunction.enabled()) {
+        if (!scalarFunction.name().isEmpty()) {
+          FunctionRegistry.registerFunction(scalarFunction.name(), method);
+        } else {
+          FunctionRegistry.registerFunction(method);
+        }
+      }
+    }
+    LOGGER.info("Initialized FunctionRegistry within {}ms", System.currentTimeMillis() - startTimeMs);
+    _initialized = true;
   }
 
   /**
-   * Given a function name and a set of argument types, asserts that a corresponding function
-   * was registered during construction and returns it
+   * Registers a method with the name of the method.
    */
-  public static FunctionInfo getFunctionByNameWithApplicableArgumentTypes(String functionName,
-      Class<?>[] argumentTypes) {
-    FunctionInfo functionInfo = getFunctionByName(functionName);
-    Preconditions.checkArgument(functionInfo.isApplicable(argumentTypes));
-    return functionInfo;
-  }
-
-  public static void registerFunction(Method method) {
+  public static synchronized void registerFunction(Method method) {
     registerFunction(method.getName().toLowerCase(), method);
   }
 
-  public static void registerFunction(String name, Method method) {
+  /**
+   * Registers a method with the given function name.
+   */
+  public static synchronized void registerFunction(String functionName, Method method) {
     FunctionInfo functionInfo = new FunctionInfo(method, method.getDeclaringClass());
-    _functionInfoMap.put(name, functionInfo);
+    FUNCTION_INFO_MAP.put(functionName, functionInfo);
   }
 
-  public static boolean containsFunctionByName(String funcName) {
-    return _functionInfoMap.containsKey(funcName.toLowerCase());
-  }
-
-  static {
-    try {
-
-      Reflections reflections = new Reflections(
-          new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
-              .setScanners(new MethodAnnotationsScanner()));
-
-      Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
-      for (Method method : methodSet) {
-        ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
-        if (scalarFunction.enabled()) {
-          if (!scalarFunction.name().isEmpty()) {
-            FunctionRegistry.registerFunction(scalarFunction.name(), method);
-          } else {
-            FunctionRegistry.registerFunction(method);
-          }
-        }
-      }
-
-    } catch (Exception e) {
-      LOGGER.error("Caught exception when registering function", e);
-      throw new IllegalStateException(e);
-    }
+  /**
+   * Returns the {@link FunctionInfo} associated with the given function name, or {@code null} if there is no method
+   * registered under the name. This method should be called after the FunctionRegistry is initialized and all methods
+   * are already registered.
+   */
+  @Nullable
+  public static FunctionInfo getFunctionByName(String functionName) {
+    return FUNCTION_INFO_MAP.get(functionName.toLowerCase());

Review comment:
       Added




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mayankshriv commented on pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
mayankshriv commented on pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#issuecomment-641553854


   Thanks a lot for identifying this issue, and providing a fix. Could you please elaborate a bit on how the thread safety issue leads to query compilation error?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437745012



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
##########
@@ -39,62 +38,63 @@
  */
 public class FunctionRegistry {
   private static final Logger LOGGER = LoggerFactory.getLogger(FunctionRegistry.class);
-  private static final Map<String, FunctionInfo> _functionInfoMap = new HashMap<>();
+  private static final Map<String, FunctionInfo> FUNCTION_INFO_MAP = new HashMap<>();
+
+  private static boolean _initialized = false;
 
   /**
-   * Given a function name, asserts that a corresponding function was registered during construction and returns it
+   * Initializes the FunctionRegistry by registering the scalar functions via reflection.
+   * NOTE: In order to plugin methods using reflection, the methods should be inside a class that includes ".function."

Review comment:
       There is no easy way to enforce this for user-side classes because we can only load the classes at runtime. Added the log for all the registered functions so that at least we can catch the problem if the class is not with the correct class path.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437749424



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -667,21 +666,23 @@ protected static Expression invokeCompileTimeFunctionExpression(Expression funcE
       function.getOperands().set(i, operand);
     }
     String funcName = function.getOperator();
-    if (FunctionRegistry.containsFunctionByName(funcName) && compilable) {

Review comment:
       `FunctionRegistry.getFunctionByName()` can handle function name not registered by returning `null`. I have a `null` check after this to save the extra hash lookup.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] sajjad-moradi commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437740412



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
##########
@@ -39,62 +38,63 @@
  */
 public class FunctionRegistry {
   private static final Logger LOGGER = LoggerFactory.getLogger(FunctionRegistry.class);
-  private static final Map<String, FunctionInfo> _functionInfoMap = new HashMap<>();
+  private static final Map<String, FunctionInfo> FUNCTION_INFO_MAP = new HashMap<>();
+
+  private static boolean _initialized = false;
 
   /**
-   * Given a function name, asserts that a corresponding function was registered during construction and returns it
+   * Initializes the FunctionRegistry by registering the scalar functions via reflection.
+   * NOTE: In order to plugin methods using reflection, the methods should be inside a class that includes ".function."
+   *       in its class path. This convention can significantly reduce the time of class scanning.
    */
-  public static FunctionInfo getFunctionByName(String functionName) {
-    Preconditions.checkArgument(_functionInfoMap.containsKey(functionName.toLowerCase()));
-    return _functionInfoMap.get(functionName.toLowerCase());
+  public static synchronized void init() {
+    if (_initialized) {
+      LOGGER.info("FunctionRegistry is already initialized");
+      return;
+    }
+
+    long startTimeMs = System.currentTimeMillis();
+    Reflections reflections = new Reflections(
+        new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
+            .filterInputsBy(new FilterBuilder.Include(".*\\.function\\..*"))
+            .setScanners(new MethodAnnotationsScanner()));
+    Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
+    for (Method method : methodSet) {
+      ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
+      if (scalarFunction.enabled()) {
+        if (!scalarFunction.name().isEmpty()) {
+          FunctionRegistry.registerFunction(scalarFunction.name(), method);
+        } else {
+          FunctionRegistry.registerFunction(method);
+        }
+      }
+    }
+    LOGGER.info("Initialized FunctionRegistry within {}ms", System.currentTimeMillis() - startTimeMs);
+    _initialized = true;
   }
 
   /**
-   * Given a function name and a set of argument types, asserts that a corresponding function
-   * was registered during construction and returns it
+   * Registers a method with the name of the method.
    */
-  public static FunctionInfo getFunctionByNameWithApplicableArgumentTypes(String functionName,
-      Class<?>[] argumentTypes) {
-    FunctionInfo functionInfo = getFunctionByName(functionName);
-    Preconditions.checkArgument(functionInfo.isApplicable(argumentTypes));
-    return functionInfo;
-  }
-
-  public static void registerFunction(Method method) {
+  public static synchronized void registerFunction(Method method) {
     registerFunction(method.getName().toLowerCase(), method);
   }
 
-  public static void registerFunction(String name, Method method) {
+  /**
+   * Registers a method with the given function name.
+   */
+  public static synchronized void registerFunction(String functionName, Method method) {
     FunctionInfo functionInfo = new FunctionInfo(method, method.getDeclaringClass());
-    _functionInfoMap.put(name, functionInfo);
+    FUNCTION_INFO_MAP.put(functionName, functionInfo);
   }
 
-  public static boolean containsFunctionByName(String funcName) {
-    return _functionInfoMap.containsKey(funcName.toLowerCase());
-  }
-
-  static {
-    try {
-
-      Reflections reflections = new Reflections(
-          new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
-              .setScanners(new MethodAnnotationsScanner()));
-
-      Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
-      for (Method method : methodSet) {
-        ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
-        if (scalarFunction.enabled()) {
-          if (!scalarFunction.name().isEmpty()) {
-            FunctionRegistry.registerFunction(scalarFunction.name(), method);
-          } else {
-            FunctionRegistry.registerFunction(method);
-          }
-        }
-      }
-
-    } catch (Exception e) {
-      LOGGER.error("Caught exception when registering function", e);
-      throw new IllegalStateException(e);
-    }
+  /**
+   * Returns the {@link FunctionInfo} associated with the given function name, or {@code null} if there is no method
+   * registered under the name. This method should be called after the FunctionRegistry is initialized and all methods
+   * are already registered.
+   */
+  @Nullable
+  public static FunctionInfo getFunctionByName(String functionName) {
+    return FUNCTION_INFO_MAP.get(functionName.toLowerCase());

Review comment:
       Could you make a function like `canonicalize(functionName)` and use it here and also in `registerFunction` method where FUNCTION_INFO_MAP gets populated so in future we won't miss converting to lowercase?

##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -667,21 +666,23 @@ protected static Expression invokeCompileTimeFunctionExpression(Expression funcE
       function.getOperands().set(i, operand);
     }
     String funcName = function.getOperator();
-    if (FunctionRegistry.containsFunctionByName(funcName) && compilable) {

Review comment:
       why are you removing this check?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mcvsubbu commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437729537



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
##########
@@ -39,62 +38,63 @@
  */
 public class FunctionRegistry {
   private static final Logger LOGGER = LoggerFactory.getLogger(FunctionRegistry.class);
-  private static final Map<String, FunctionInfo> _functionInfoMap = new HashMap<>();
+  private static final Map<String, FunctionInfo> FUNCTION_INFO_MAP = new HashMap<>();
+
+  private static boolean _initialized = false;
 
   /**
-   * Given a function name, asserts that a corresponding function was registered during construction and returns it
+   * Initializes the FunctionRegistry by registering the scalar functions via reflection.
+   * NOTE: In order to plugin methods using reflection, the methods should be inside a class that includes ".function."
+   *       in its class path. This convention can significantly reduce the time of class scanning.
    */
-  public static FunctionInfo getFunctionByName(String functionName) {
-    Preconditions.checkArgument(_functionInfoMap.containsKey(functionName.toLowerCase()));
-    return _functionInfoMap.get(functionName.toLowerCase());
+  public static synchronized void init() {
+    if (_initialized) {
+      LOGGER.info("FunctionRegistry is already initialized");
+      return;
+    }
+
+    long startTimeMs = System.currentTimeMillis();
+    Reflections reflections = new Reflections(
+        new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.apache.pinot"))
+            .filterInputsBy(new FilterBuilder.Include(".*\\.function\\..*"))
+            .setScanners(new MethodAnnotationsScanner()));
+    Set<Method> methodSet = reflections.getMethodsAnnotatedWith(ScalarFunction.class);
+    for (Method method : methodSet) {
+      ScalarFunction scalarFunction = method.getAnnotation(ScalarFunction.class);
+      if (scalarFunction.enabled()) {
+        if (!scalarFunction.name().isEmpty()) {
+          FunctionRegistry.registerFunction(scalarFunction.name(), method);
+        } else {
+          FunctionRegistry.registerFunction(method);
+        }
+      }
+    }
+    LOGGER.info("Initialized FunctionRegistry within {}ms", System.currentTimeMillis() - startTimeMs);

Review comment:
       why are we measuring the time to init functions? do we expect it to take a long time?
   Also, if we logging it may be useful to log the map size here, and also each function as they are registered




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#discussion_r437703543



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/FunctionRegistry.java
##########
@@ -39,62 +38,63 @@
  */
 public class FunctionRegistry {
   private static final Logger LOGGER = LoggerFactory.getLogger(FunctionRegistry.class);
-  private static final Map<String, FunctionInfo> _functionInfoMap = new HashMap<>();
+  private static final Map<String, FunctionInfo> FUNCTION_INFO_MAP = new HashMap<>();
+
+  private static boolean _initialized = false;
 
   /**
-   * Given a function name, asserts that a corresponding function was registered during construction and returns it
+   * Initializes the FunctionRegistry by registering the scalar functions via reflection.
+   * NOTE: In order to plugin methods using reflection, the methods should be inside a class that includes ".function."

Review comment:
       Curious if there's any way to enforce this, so we ensure that future changes adhere to this?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] codecov-commenter commented on pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531#issuecomment-641673684


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=h1) Report
   > Merging [#5531](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/1beaab59b73f26c4e35f3b9bc856b03806cddf5a&el=desc) will **increase** coverage by `0.29%`.
   > The diff coverage is `73.34%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/5531/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz)](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #5531      +/-   ##
   ==========================================
   + Coverage   66.44%   66.74%   +0.29%     
   ==========================================
     Files        1075     1096      +21     
     Lines       54773    56414    +1641     
     Branches     8168     8412     +244     
   ==========================================
   + Hits        36396    37655    +1259     
   - Misses      15700    15982     +282     
   - Partials     2677     2777     +100     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #integrationtests | `45.35% <53.10%> (?)` | |
   | #unittests | `56.93% <63.22%> (?)` | |
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...quota/HelixExternalViewBasedQueryQuotaManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvcXVlcnlxdW90YS9IZWxpeEV4dGVybmFsVmlld0Jhc2VkUXVlcnlRdW90YU1hbmFnZXIuamF2YQ==) | `67.87% <0.00%> (ø)` | |
   | [...org/apache/pinot/common/function/FunctionInfo.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vRnVuY3Rpb25JbmZvLmphdmE=) | `73.33% <ø> (ø)` | |
   | [...org/apache/pinot/common/utils/CommonConstants.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvQ29tbW9uQ29uc3RhbnRzLmphdmE=) | `39.02% <0.00%> (+0.92%)` | :arrow_up: |
   | [...troller/helix/core/retention/RetentionManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JldGVudGlvbi9SZXRlbnRpb25NYW5hZ2VyLmphdmE=) | `80.28% <0.00%> (+1.11%)` | :arrow_up: |
   | [...he/pinot/controller/util/AutoAddInvertedIndex.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci91dGlsL0F1dG9BZGRJbnZlcnRlZEluZGV4LmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../org/apache/pinot/core/common/BaseBlockValSet.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vQmFzZUJsb2NrVmFsU2V0LmphdmE=) | `3.03% <0.00%> (-1.32%)` | :arrow_down: |
   | [.../java/org/apache/pinot/core/common/DataSource.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9jb21tb24vRGF0YVNvdXJjZS5qYXZh) | `100.00% <ø> (ø)` | |
   | [...data/manager/realtime/DefaultSegmentCommitter.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvRGVmYXVsdFNlZ21lbnRDb21taXR0ZXIuamF2YQ==) | `80.00% <ø> (ø)` | |
   | [...e/data/manager/realtime/SplitSegmentCommitter.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvU3BsaXRTZWdtZW50Q29tbWl0dGVyLmphdmE=) | `63.63% <ø> (ø)` | |
   | [...re/io/reader/impl/v1/FixedBitMultiValueReader.java](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9pby9yZWFkZXIvaW1wbC92MS9GaXhlZEJpdE11bHRpVmFsdWVSZWFkZXIuamF2YQ==) | `100.00% <ø> (ø)` | |
   | ... and [422 more](https://codecov.io/gh/apache/incubator-pinot/pull/5531/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=footer). Last update [a1a2434...503eff8](https://codecov.io/gh/apache/incubator-pinot/pull/5531?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang merged pull request #5531: Fix the failure caused by Reflections in FunctionRegistry

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged pull request #5531:
URL: https://github.com/apache/incubator-pinot/pull/5531


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org