theMadKing
theMadKing

Reputation: 2074

Scala Null for Double (Min Comparison for Aggregate)

So I have a function called AggregateByKey,

val initialValue:(Double, Double,Double,Double,Double) = (0.0,0.0,0.0,0.0,0.0)

I have a component of the AggregateByKey that does a min: math.min(u._4,v) The problem is that the initial value is 0.0 so if there are no negative numbers it always is 0.0 because its comparing the incoming number to 0.0. I've also tried to null.asInstanceOf[Double] but that also does not work. Does anyone have any thoughts on how to solve for this?

Upvotes: 1

Views: 312

Answers (1)

Rok Kralj
Rok Kralj

Reputation: 48725

Use this istead of 0.0:

Double.PositiveInfinity

Upvotes: 1

Related Questions