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:50:34 UTC

[GitHub] [pinot] walterddr opened a new issue #7448: Support stateful ScalarFunction

walterddr opened a new issue #7448:
URL: https://github.com/apache/pinot/issues/7448


   Some of the `@ScalarFunction` we built and potentially other 3rd party customized function can benefit from a stateful optimization. E.g. if we know a scalarfunction is used with literal arguments. those literal arguments can be preprocessed (e.g. regexp pattern compilation)
   
   However since ScalarFunction are used not only during the query code path but also the ingestion codepath. we need to be support both the stateful and stateless version of the function to ensure performance optimization and compatibility. 
   
   https://github.com/apache/pinot/pull/7443 created an example of how this could benefit. But it doesn't work on the ingestion path and there are some other issues to consider:
   
   - [ ] need to guarantee that all the stateful version of the FunctionInvoker internal instances are properly initialized, in both query and ingestion code path
   - [ ] support type matching with Literal detection, there's no point of optimizing scalar function if there's no prior knowledge of the arguments, might as well just do the computation during actual call.
   - [ ] should not incur any additional branch condition in critical path. 
   - [ ] should ensure that multiple instances of the FunctionInvoker (and its underlying instances) doesn't share any states.
   


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


[GitHub] [pinot] walterddr edited a comment on issue #7448: Support stateful ScalarFunction

Posted by GitBox <gi...@apache.org>.
walterddr edited a comment on issue #7448:
URL: https://github.com/apache/pinot/issues/7448#issuecomment-922168972


   Initial design is:
   
   0. make `ScalarFunction` annotation support both class annotation and *static* method annotation
     - static version is the current implementation
     - class annotation supports both stateless and stateful version (this requires the PreprocessableScalarFunction interface to support 3 interface processStateful / processStateless / init)
   1. make `FunctionInvoker` support instantiating both the stateful and the stateless version of a "ScalarFunction" annotation. e.g. depending on the owner of this `FunctionInvoker` it can initialize invokable function in either stateful or stateless way --> this gives back the control to the owner (ScalarFunctionWrapper, or InBuiltFunctionEvaluator) to use the stateful or stateless version
   2. owner of `FunctionInvoker` decided to connect with either the stateful or the stateless interface (e.g. for ingestion we should probably use the stateless interface, while in query we probably can parse the Literal Transform and use the stateful version
   3. Existing user of the FunctionInvoker as is will go through the stateless code path, even with the class annotation. it will still go through the stateless implementation thanks to the additional API requirement. 
   4. A special issue with stateful Function. each time a FunctionInfo is encountered. a new FunctionInvoker must be instantiated --> this is the current behavior, but we need to make sure it stays this way going forward too. 
   
   Happy to take feedbacks on 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.

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


[GitHub] [pinot] walterddr edited a comment on issue #7448: Support stateful ScalarFunction

Posted by GitBox <gi...@apache.org>.
walterddr edited a comment on issue #7448:
URL: https://github.com/apache/pinot/issues/7448#issuecomment-922168972


   Initial design is:
   
   0. make `ScalarFunction` annotation support both class annotation and *static* method annotation
     - static version is the current implementation
     - class annotation supports both stateless and stateful version (this requires the PreprocessableScalarFunction interface to support 3 interface processStateful / processStateless / init)
   1. make `FunctionInvoker` support instantiating both the stateful and the stateless version of a "ScalarFunction" annotation. e.g. depending on the owner of this `FunctionInvoker` it can initialize invokable function in either stateful or stateless way --> this gives back the control to the owner (ScalarFunctionWrapper, or InBuiltFunctionEvaluator) to use the stateful or stateless version
   2. owner of `FunctionInvoker` decided to connect with either the stateful or the stateless interface (e.g. for ingestion we should probably use the stateless interface, while in query we probably can parse the Literal Transform and use the stateful version
   3. Existing user of the FunctionInvoker as is will go through the stateless code path, even with the class annotation. it will still go through the stateless implementation thanks to the additional API requirement. 
   4. A special issue with stateful Function. each time a FunctionInfo is encountered. a new FunctionInvoker must be instantiated --> this is the current behavior.
   
   Happy to take feedbacks on 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.

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


[GitHub] [pinot] Jackie-Jiang commented on issue #7448: Support stateful ScalarFunction

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on issue #7448:
URL: https://github.com/apache/pinot/issues/7448#issuecomment-923282158


   Great proposal!
   Currently the scalar function class is actually stateful (one instance of class in the `FunctionInvoker`). We do have a test for that (see `InbuiltFunctionEvaluatorTest.testStateSharedBetweenRowsForExecution()`.
   The problem is that we don't have a way to initialize the class. IMO there are 2 approaches:
   1. Add an `init()` method and explicitly invoke it on the caller side
   2. Initialize the class when the scalar function method is called the first time


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


[GitHub] [pinot] walterddr commented on issue #7448: Support stateful ScalarFunction

Posted by GitBox <gi...@apache.org>.
walterddr commented on issue #7448:
URL: https://github.com/apache/pinot/issues/7448#issuecomment-922168972


   Initial design is:
   
   0. make `ScalarFunction` annotation support both class annotation and *static* method annotation
     - static version is the current implementation
     - class annotation supports both stateless and stateful version (this requires the PreprocessableScalarFunction interface to support 3 interface processStateful / processStateless / init)
   1. make `FunctionInvoker` support instantiating both the stateful and the stateless version of a "ScalarFunction" annotation. e.g. depending on the owner of this `FunctionInvoker` it can initialize invokable function in either stateful or stateless way --> this gives back the control to the owner (ScalarFunctionWrapper, or InBuiltFunctionEvaluator) to use the stateful or stateless version
   2. owner of `FunctionInvoker` decided to connect with either the stateful or the stateless interface (e.g. for ingestion we should probably use the stateless interface, while in query we probably can parse the Literal Transform and use the stateful version
   3. Existing user of the FunctionInvoker as is will go through the stateless code path, even with the class annotation. it will still go through the stateless implementation thanks to the additional API requirement. 
   
   Happy to take feedbacks on 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.

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