Can you help understand averageCarrierDelay?
Closed this issue · 1 comments
asarkar commented
val averageCarrierDelay =
Flow[FlightDelayRecord]
.groupBy(30, _.uniqueCarrier)
.fold(("", 0, 0)) {
(x: (String, Int, Int), y: FlightDelayRecord) =>
val count = x._2 + 1
val totalMins = x._3 + Try(y.arrDelayMins.toInt).getOrElse(0)
(y.uniqueCarrier, count, totalMins)
}.mergeSubstreams
What's the Tuple3[String, Int, Int]
? Where does it come from in the flow?
asarkar commented
Never mind, got it. Tuple3[String, Int, Int]
is the zero
in fold[T](zero: T)(f: (T, Out) ⇒ T): Repr[T]
. It doesn't come from elsewhere in the flow.