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 2021/09/17 18:04:00 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7443: adding instance method initialization

Jackie-Jiang commented on a change in pull request #7443:
URL: https://github.com/apache/pinot/pull/7443#discussion_r711253498



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java
##########
@@ -328,14 +329,27 @@ public static String normalize(String input) {
 
   /**
    * see Normalizer#normalize(String, Form)
-   * @param input
-   * @param form
-   * @return transforms string with the specified normalization form
    */
-  @ScalarFunction
-  public static String normalize(String input, String form) {
-    Normalizer.Form targetForm = Normalizer.Form.valueOf(form);
-    return Normalizer.normalize(input, targetForm);
+  public static class NormalizeFunction implements InitializableScalarFunction {
+    private Normalizer.Form _form;
+
+    @Override
+    public void init(Object... arguments) {
+      Preconditions.checkState(arguments.length == 2
+          && arguments[1] instanceof String);
+      _form = Normalizer.Form.valueOf((String) arguments[1]);
+    }
+
+    /**
+     * see Normalizer#normalize(String, Form)
+     * @param input
+     * @param form
+     * @return transforms string with the specified normalization form
+     */
+    @ScalarFunction
+    String normalize(String input, String form) {

Review comment:
       There are other callers to `FunctionInvoker.invoke()`, and we need to make sure all of them call `init()` first




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

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