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



##########
File path: 
pinot-core/src/main/java/org/apache/pinot/core/operator/transform/function/InTransformFunction.java
##########
@@ -81,77 +95,112 @@ public TransformResultMetadata getResultMetadata() {
     switch (storedType) {
       case INT:
         int[] intValues = 
_transformFunction.transformToIntValuesSV(projectionBlock);
-        int[][] inIntValues = new int[_valueTransformFunctions.length][];
-        for (int i = 0; i < _valueTransformFunctions.length; i++) {
-          inIntValues[i] = 
_valueTransformFunctions[i].transformToIntValuesSV(projectionBlock);
-        }
-        for (int i = 0; i < length; i++) {
-          for (int j = 0; j < inIntValues.length; j++) {
-            _results[i] = inIntValues[j][i] == intValues[i] ? 1 : _results[i];
+        if (!_stringValueSet.isEmpty()) {
+          Set<Integer> inIntValues = new HashSet<>();
+          for (String inValue : _stringValueSet) {
+            inIntValues.add(Integer.parseInt(inValue));
+          }
+          for (int i = 0; i < length; i++) {
+            _results[i] = inIntValues.contains(intValues[i]) ? 1 : 0;
+          }
+        } else {
+          int[][] inIntValues = new int[_valueTransformFunctions.length][];
+          for (int i = 0; i < _valueTransformFunctions.length; i++) {
+            inIntValues[i] = 
_valueTransformFunctions[i].transformToIntValuesSV(projectionBlock);
+          }
+          for (int i = 0; i < length; i++) {
+            for (int j = 0; j < inIntValues.length; j++) {
+              _results[i] = inIntValues[j][i] == intValues[i] ? 1 : 
_results[i];
+            }
           }
         }
         break;
       case LONG:
         long[] longValues = 
_transformFunction.transformToLongValuesSV(projectionBlock);
-        long[][] inLongValues = new long[_valueTransformFunctions.length][];
-        for (int i = 0; i < _valueTransformFunctions.length; i++) {
-          inLongValues[i] = 
_valueTransformFunctions[i].transformToLongValuesSV(projectionBlock);
-        }
-        for (int i = 0; i < length; i++) {
-          for (int j = 0; j < inLongValues.length; j++) {
-            _results[i] = inLongValues[j][i] == longValues[i] ? 1 : 
_results[i];
+        if (!_stringValueSet.isEmpty()) {
+          Set<Long> inLongValues = new HashSet<>();
+          for (String inValue : _stringValueSet) {
+            inLongValues.add(Long.parseLong(inValue));
+          }
+          for (int i = 0; i < length; i++) {
+            _results[i] = inLongValues.contains(longValues[i]) ? 1 : 0;
+          }
+        } else {
+          long[][] inLongValues = new long[_valueTransformFunctions.length][];
+          for (int i = 0; i < _valueTransformFunctions.length; i++) {
+            inLongValues[i] = 
_valueTransformFunctions[i].transformToLongValuesSV(projectionBlock);
+          }
+          for (int i = 0; i < length; i++) {
+            for (int j = 0; j < inLongValues.length; j++) {
+              _results[i] = inLongValues[j][i] == longValues[i] ? 1 : 
_results[i];
+            }
           }
         }
         break;
       case FLOAT:
         float[] floatValues = 
_transformFunction.transformToFloatValuesSV(projectionBlock);
-        float[][] inFloatValues = new float[_valueTransformFunctions.length][];
-        for (int i = 0; i < _valueTransformFunctions.length; i++) {
-          inFloatValues[i] = 
_valueTransformFunctions[i].transformToFloatValuesSV(projectionBlock);
-        }
-        for (int i = 0; i < length; i++) {
-          for (int j = 0; j < inFloatValues.length; j++) {
-            _results[i] = Float.compare(inFloatValues[j][i], floatValues[i]) 
== 0 ? 1 : _results[i];
+        if (!_stringValueSet.isEmpty()) {

Review comment:
       @richardstartin Does the test fail because it should be `0.1F + 0.9F`? I 
tried it and it works.
   Good point on the fuzzy comparison, but currently we don't have that and 
only use exact match for floating point values (same as the IN in where clause, 
and EQUALS, NOT_EQUALS etc.). I'd suggest keeping the current behavior and 
revisit if necessary.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to