Skip to content

Commit

Permalink
Simplify bucket reducer logic
Browse files Browse the repository at this point in the history
  • Loading branch information
szehon-ho committed Apr 3, 2024
1 parent ad61b0c commit a88970b
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,12 @@ object BucketFunction extends ScalarFunction[Int] with ReducibleFunction[Int, In
otherNumBuckets: Int): Reducer[Int, Int] = {

if (otherFunc == BucketFunction) {
if ((thisNumBuckets > otherNumBuckets)
&& (thisNumBuckets % otherNumBuckets == 0)) {
BucketReducer(thisNumBuckets, otherNumBuckets)
} else {
val gcd = this.gcd(thisNumBuckets, otherNumBuckets)
if (gcd != thisNumBuckets) {
BucketReducer(thisNumBuckets, gcd)
} else {
null
}
val gcd = this.gcd(thisNumBuckets, otherNumBuckets)
if (gcd != thisNumBuckets) {
return BucketReducer(thisNumBuckets, gcd)
}
} else {
null
}
null
}

private def gcd(a: Int, b: Int): Int = BigInt(a).gcd(BigInt(b)).toInt
Expand Down

0 comments on commit a88970b

Please sign in to comment.