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/11/05 20:49:27 UTC

[GitHub] [pinot] Jackie-Jiang commented on a change in pull request #7707: lighter weight LiteralTransformFunction, avoid excessive array fills

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



##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/LiteralTransformFunction.java
##########
@@ -128,64 +122,88 @@ public Dictionary getDictionary() {
 
   @Override
   public int[] transformToIntValuesSV(ProjectionBlock projectionBlock) {
-    if (_intResult == null) {
-      _intResult = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL];
+    int numDocs = projectionBlock.getNumDocs();
+    Object ref = _result;

Review comment:
       Any performance benefit of caching member variable into a local variable?

##########
File path: pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/LiteralTransformFunction.java
##########
@@ -128,64 +122,88 @@ public Dictionary getDictionary() {
 
   @Override
   public int[] transformToIntValuesSV(ProjectionBlock projectionBlock) {
-    if (_intResult == null) {
-      _intResult = new int[DocIdSetPlanNode.MAX_DOC_PER_CALL];
+    int numDocs = projectionBlock.getNumDocs();
+    Object ref = _result;
+    if (!(ref instanceof int[]) || ((int[]) ref).length < numDocs) {

Review comment:
       Per the current way of query execution, we can make the following assumptions:
   1. Only one type of the result will be read
   2. The first projection block will contain the most `numDocs` (up to 10K)
   
   With these assumptions we can change the check to
   ```suggestion
       if (ref == null) {
         ...
       } else {
         assert (ref instanceof int[]) && ((int[]) ref).length >= numDocs;
       }
   ```
   
   If the assumption break, we'd better let it throw exception, or the performance will degrade because we will end up filling the array multiple times.




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