richardstartin commented on a change in pull request #8137: URL: https://github.com/apache/pinot/pull/8137#discussion_r801110383
########## File path: pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/AggregationFunctionType.java ########## @@ -81,14 +87,28 @@ public String getName() { return _name; } + public static boolean isAggregationFunction(String functionName) { + if (NAMES.contains(functionName)) { + return true; + } + if (functionName.regionMatches(true, 0, "percentile", 0, 10)) { + try { + getAggregationFunctionType(functionName); + return true; + } catch (Exception ignore) { + } + } + String upperCaseFunctionName = functionName.replace("_", "").toUpperCase(); + return NAMES.contains(upperCaseFunctionName); + } + /** * Returns the corresponding aggregation function type for the given function name. * <p>NOTE: Underscores in the function name are ignored. */ public static AggregationFunctionType getAggregationFunctionType(String functionName) { - String upperCaseFunctionName = StringUtils.remove(functionName, '_').toUpperCase(); - if (upperCaseFunctionName.startsWith("PERCENTILE")) { - String remainingFunctionName = upperCaseFunctionName.substring(10); + if (functionName.regionMatches(true, 0, "percentile", 0, 10)) { Review comment: `regionMatches` feels like the better option to me: ``` Benchmark (_function) Mode Cnt Score Error Units StartsWith.regionMatches percentile_foo avgt 5 14.793 ± 0.467 ns/op StartsWith.regionMatches:·gc.alloc.rate percentile_foo avgt 5 ≈ 10⁻⁴ MB/sec StartsWith.regionMatches:·gc.alloc.rate.norm percentile_foo avgt 5 ≈ 10⁻⁵ B/op StartsWith.regionMatches:·gc.count percentile_foo avgt 5 ≈ 0 counts StartsWith.regionMatches PERCENTILE_FOO avgt 5 26.785 ± 0.480 ns/op StartsWith.regionMatches:·gc.alloc.rate PERCENTILE_FOO avgt 5 ≈ 10⁻⁴ MB/sec StartsWith.regionMatches:·gc.alloc.rate.norm PERCENTILE_FOO avgt 5 ≈ 10⁻⁵ B/op StartsWith.regionMatches:·gc.count PERCENTILE_FOO avgt 5 ≈ 0 counts StartsWith.regionMatches doesn't match avgt 5 7.091 ± 0.034 ns/op StartsWith.regionMatches:·gc.alloc.rate doesn't match avgt 5 ≈ 10⁻⁴ MB/sec StartsWith.regionMatches:·gc.alloc.rate.norm doesn't match avgt 5 ≈ 10⁻⁶ B/op StartsWith.regionMatches:·gc.count doesn't match avgt 5 ≈ 0 counts StartsWith.startsWith percentile_foo avgt 5 36.754 ± 0.447 ns/op StartsWith.startsWith:·gc.alloc.rate percentile_foo avgt 5 965.883 ± 11.124 MB/sec StartsWith.startsWith:·gc.alloc.rate.norm percentile_foo avgt 5 56.000 ± 0.001 B/op StartsWith.startsWith:·gc.churn.G1_Eden_Space percentile_foo avgt 5 970.448 ± 4.635 MB/sec StartsWith.startsWith:·gc.churn.G1_Eden_Space.norm percentile_foo avgt 5 56.265 ± 0.591 B/op StartsWith.startsWith:·gc.churn.G1_Old_Gen percentile_foo avgt 5 0.001 ± 0.005 MB/sec StartsWith.startsWith:·gc.churn.G1_Old_Gen.norm percentile_foo avgt 5 ≈ 10⁻⁴ B/op StartsWith.startsWith:·gc.count percentile_foo avgt 5 40.000 counts StartsWith.startsWith:·gc.time percentile_foo avgt 5 22.000 ms StartsWith.startsWith PERCENTILE_FOO avgt 5 16.395 ± 0.523 ns/op StartsWith.startsWith:·gc.alloc.rate PERCENTILE_FOO avgt 5 ≈ 10⁻⁴ MB/sec StartsWith.startsWith:·gc.alloc.rate.norm PERCENTILE_FOO avgt 5 ≈ 10⁻⁵ B/op StartsWith.startsWith:·gc.count PERCENTILE_FOO avgt 5 ≈ 0 counts StartsWith.startsWith doesn't match avgt 5 31.228 ± 1.392 ns/op StartsWith.startsWith:·gc.alloc.rate doesn't match avgt 5 1137.484 ± 48.866 MB/sec StartsWith.startsWith:·gc.alloc.rate.norm doesn't match avgt 5 56.000 ± 0.001 B/op StartsWith.startsWith:·gc.churn.G1_Eden_Space doesn't match avgt 5 1139.195 ± 256.337 MB/sec StartsWith.startsWith:·gc.churn.G1_Eden_Space.norm doesn't match avgt 5 56.079 ± 11.876 B/op StartsWith.startsWith:·gc.churn.G1_Old_Gen doesn't match avgt 5 0.002 ± 0.005 MB/sec StartsWith.startsWith:·gc.churn.G1_Old_Gen.norm doesn't match avgt 5 ≈ 10⁻⁴ B/op StartsWith.startsWith:·gc.count doesn't match avgt 5 47.000 counts StartsWith.startsWith:·gc.time doesn't match avgt 5 25.000 ms ``` -- 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