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



##########
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:
       Oh, what a silly typo when trying to demonstrate the problem with the 
concept. Try this one instead:
   
   ```java
     @Test
     public void testFloatSet() {
       Set<Float> set = new HashSet<>();
       set.add(0.8F);
       assertTrue(set.contains(0.1F + 0.1F + 0.1F + 0.1F + 0.1F + 0.1F + 0.1F + 
0.1F));
     }
   ```
   
   I think you understand the pitfalls of floating point equality and the point 
I am trying to make. Distinguishing between 0.8 and 0.8000001 is poor UX.




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