How to use min in aggregateByKey


#1

iam trying to get min functionality in aggregateByKey ,somehow it is not working

given below is the code i used

val agg = orderssum.aggregateByKey((0.0f))(
(k,v) => ( if(k < v) k else v ),
(t,p) => ( if ( t < p) t else p)
)

it is returning 0.0 for min for all rows


#2

INITIALIZE highest possible value while computing MINIMUM,
INITIALIZE lowest possible value while computing MAXIMUM
Ex.(0, 99999999.99999999)