[
https://issues.apache.org/jira/browse/DRILL-8376?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17656682#comment-17656682
]
ASF GitHub Bot commented on DRILL-8376:
---------------------------------------
cgivre commented on code in PR #2729:
URL: https://github.com/apache/drill/pull/2729#discussion_r1065940539
##########
contrib/udfs/src/main/java/org/apache/drill/exec/udfs/DistributionFunctions.java:
##########
@@ -51,31 +51,29 @@ public static class WidthBucketFunction implements
DrillSimpleFunc {
@Workspace
double binWidth;
+ @Workspace
+ int bucketCount;
+
@Output
IntHolder bucket;
@Override
public void setup() {
double max = MaxRangeValueHolder.value;
double min = MinRangeValueHolder.value;
- int bucketCount = bucketCountHolder.value;
+ bucketCount = bucketCountHolder.value;
binWidth = (max - min) / bucketCount;
}
@Override
public void eval() {
- // There is probably a more elegant way of doing this...
- double binFloor = MinRangeValueHolder.value;
- double binCeiling = binFloor + binWidth;
-
- for (int i = 1; i <= bucketCountHolder.value; i++) {
- if (inputValue.value <= binCeiling && inputValue.value > binFloor) {
- bucket.value = i;
- break;
- } else {
- binFloor = binCeiling;
- binCeiling = binWidth * (i + 1);
- }
+ if (inputValue.value < MinRangeValueHolder.value) {
+ bucket.value = 0;
+ } else if (inputValue.value > MaxRangeValueHolder.value) {
+ bucket.value = bucketCount + 1;
+ } else {
+ double f = (1 + (inputValue.value - MinRangeValueHolder.value) /
binWidth);
Review Comment:
Oops... That was a test variable. Removed.
> Add Distribution UDFs
> ---------------------
>
> Key: DRILL-8376
> URL: https://issues.apache.org/jira/browse/DRILL-8376
> Project: Apache Drill
> Issue Type: Improvement
> Components: Functions - Drill
> Affects Versions: 1.21.0
> Reporter: Charles Givre
> Assignee: Charles Givre
> Priority: Minor
>
> Add `width_bucket`, `pearson_correlation` and `kendall_correlation` to Drill
--
This message was sent by Atlassian Jira
(v8.20.10#820010)