richardstartin commented on a change in pull request #7707:
URL: https://github.com/apache/pinot/pull/7707#discussion_r743962262



##########
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:
       None whatsoever, but I also discovered that we create a lot more of 
these than I think is reasonable per query, and I think it may be wise to cache 
them externally. In case something changes externally, I want this method 
invocation to be consistent, even if the updates are racy.

##########
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:
       What if something changes? E.g. JSON often has variant types (e.g. 
string or number)

##########
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:
       instanceof checks aren’t worth trying to optimise away anyway, they’re 
intrinsified and speculatively eliminated with an uncommon trap, just like null 
checks




-- 
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-unsubscr...@pinot.apache.org

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



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

Reply via email to