Copilot commented on code in PR #18952:
URL: https://github.com/apache/pinot/pull/18952#discussion_r3555483045


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/columnminmaxvalue/ColumnMinMaxValueGenerator.java:
##########
@@ -365,21 +365,21 @@ private void 
addColumnMinMaxValueWithoutDictionary(ColumnMetadata columnMetadata
           if (isSingleValue) {
             for (int docId = 0; docId < numDocs; docId++) {
               byte[] value = rawIndexReader.getBytes(docId, readerContext);
-              if (min == null || ByteArray.compare(value, min) > 0) {
+              if (min == null || ByteArray.compare(value, min) < 0) {
                 min = value;
               }
-              if (max == null || ByteArray.compare(value, max) < 0) {
+              if (max == null || ByteArray.compare(value, max) > 0) {
                 max = value;

Review Comment:
   In the BYTES branch, `min`/`max` are initialized to null and only populated 
inside the doc loop. If a segment has `numDocs == 0`, `min`/`max` stay null and 
the subsequent `new ByteArray(min)` / `new ByteArray(max)` will lead to a 
NullPointerException when persisting the values (because `toString()` 
ultimately dereferences the underlying byte[]). Other stored types pass null 
through to `addColumnMinMaxValueInfo()`, which already handles nulls by setting 
`MIN_MAX_VALUE_INVALID`.



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