You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/07/14 19:44:15 UTC

[GitHub] [pinot] Jackie-Jiang opened a new pull request, #9059: Fix string length in MutableColumnStatistics

Jackie-Jiang opened a new pull request, #9059:
URL: https://github.com/apache/pinot/pull/9059

   Fix the MutableColumnStatistics for:
   - Correctly count the byte length of string instead of character length
   - Support BIG_DECIMAL
   - Reduce the unnecessary dictionary scan


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

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


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


[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #9059: Fix string length in MutableColumnStatistics

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on code in PR #9059:
URL: https://github.com/apache/pinot/pull/9059#discussion_r921625117


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/converter/stats/MutableColumnStatistics.java:
##########
@@ -70,46 +76,57 @@ public int getCardinality() {
 
   @Override
   public int getLengthOfShortestElement() {
-    // Length of longest string
-    int minStringLength = Integer.MAX_VALUE;
-
-    // If this column is a string/bytes column, iterate over the dictionary to find the maximum length
-    FieldSpec.DataType dataType = _dataSource.getDataSourceMetadata().getDataType();
-    int length = _dictionary.length();
-
-    if (dataType.equals(FieldSpec.DataType.STRING)) {
-      for (int i = 0; i < length; i++) {
-        minStringLength = Math.min(_dictionary.getStringValue(i).length(), minStringLength);
-      }
-    } else if (dataType.equals(FieldSpec.DataType.BYTES)) {
-      for (int i = 0; i < length; i++) {
-        minStringLength = Math.min(_dictionary.getBytesValue(i).length, minStringLength);
-      }
-    }
-
-    return minStringLength;
+    collectElementLengthIfNeeded();
+    return _minElementLength;
   }
 
   @Override
   public int getLengthOfLargestElement() {
-    // Length of longest string
-    int maximumStringLength = 0;
+    collectElementLengthIfNeeded();
+    return _maxElementLength;
+  }
 
-    // If this column is a string/bytes column, iterate over the dictionary to find the maximum length
-    FieldSpec.DataType dataType = _dataSource.getDataSourceMetadata().getDataType();
-    int length = _dictionary.length();
+  private void collectElementLengthIfNeeded() {
+    if (_minElementLength >= 0) {

Review Comment:
   Yes. Currently we scan the dictionary multiple times because we call `getLengthOfShortestElement()` and `getLengthOfLargestElement()` multiple times. This avoids that.



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

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


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


[GitHub] [pinot] Jackie-Jiang merged pull request #9059: Fix string length in MutableColumnStatistics

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged PR #9059:
URL: https://github.com/apache/pinot/pull/9059


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

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


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


[GitHub] [pinot] navina commented on a diff in pull request #9059: Fix string length in MutableColumnStatistics

Posted by GitBox <gi...@apache.org>.
navina commented on code in PR #9059:
URL: https://github.com/apache/pinot/pull/9059#discussion_r921621792


##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/realtime/converter/stats/MutableColumnStatistics.java:
##########
@@ -70,46 +76,57 @@ public int getCardinality() {
 
   @Override
   public int getLengthOfShortestElement() {
-    // Length of longest string
-    int minStringLength = Integer.MAX_VALUE;
-
-    // If this column is a string/bytes column, iterate over the dictionary to find the maximum length
-    FieldSpec.DataType dataType = _dataSource.getDataSourceMetadata().getDataType();
-    int length = _dictionary.length();
-
-    if (dataType.equals(FieldSpec.DataType.STRING)) {
-      for (int i = 0; i < length; i++) {
-        minStringLength = Math.min(_dictionary.getStringValue(i).length(), minStringLength);
-      }
-    } else if (dataType.equals(FieldSpec.DataType.BYTES)) {
-      for (int i = 0; i < length; i++) {
-        minStringLength = Math.min(_dictionary.getBytesValue(i).length, minStringLength);
-      }
-    }
-
-    return minStringLength;
+    collectElementLengthIfNeeded();
+    return _minElementLength;
   }
 
   @Override
   public int getLengthOfLargestElement() {
-    // Length of longest string
-    int maximumStringLength = 0;
+    collectElementLengthIfNeeded();
+    return _maxElementLength;
+  }
 
-    // If this column is a string/bytes column, iterate over the dictionary to find the maximum length
-    FieldSpec.DataType dataType = _dataSource.getDataSourceMetadata().getDataType();
-    int length = _dictionary.length();
+  private void collectElementLengthIfNeeded() {
+    if (_minElementLength >= 0) {

Review Comment:
   is this check done so we don't calculate the element length more than once for a given dictionary ? 



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

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


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