gortiz commented on code in PR #8979:
URL: https://github.com/apache/pinot/pull/8979#discussion_r959225492


##########
pinot-core/src/main/java/org/apache/pinot/core/common/NullableRowBasedBlockValueFetcher.java:
##########
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.core.common;
+
+import org.roaringbitmap.RoaringBitmap;
+
+
+public class NullableRowBasedBlockValueFetcher extends 
RowBasedBlockValueFetcher {

Review Comment:
   The reason to create a subclass here is to do not affect the hot path if 
possible. `RowBasedBlockValueFetcher.getRow` is in the hot path and therefore 
the simpler the code, the better. If we move the code to 
`RowBasedBlockValueFetcher`, we will need to check whether there are nulls or 
not on every `RowBasedBlockValueFetcher.getRow`.
   
   With the `NullableRowBasedBlockValueFetcher` approach, there is not explicit 
condition: Either the value fetcher will be nullable or not. Of course there is 
an implicit condition: we transformed the explicit `if` into a polymorphic 
call. Given that we only have two classes that are `RowBasedBlockValueFetcher` 
(the base one and the nullable one) the JIT will optimize that quite well.
   
   I assume that most of the time either a almost all queries will enable or 
disable null handling (in other words, I don't expect changing the null 
handling value very often in production). Therefore the JIT will see that 
almost always the class that is used is `NullableRowBasedBlockValueFetcher` or 
`RowBasedBlockValueFetcher` and will compile the code accordingly.
   
   I have to say that this is a guess and I don't have empiric data, but I'm 
sure either using polymorphism as I suggest or adding a condition, as you do, 
is always going to be better (in performance and readability) than the solution 
we are using right now where `_nullBitmaps` is associated with each operator 
and the conditional logic is replicated in several places



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