Reputation: 303
I'm using the updateStateByKey function in Spark Streaming application to persist and update the status for each key. The question is I want to know the "key" inside the update function.
input.updateStateByKey(updateStateByKeyOfUsers)
def updateStateByKeyOfUsers(newUsers: Seq[Set[String]],
userStatus: Option[(#####)]
): Option[(#####)] = {
//How to get the "Key"
}
-Tao
Upvotes: 4
Views: 701
Reputation: 523
Generally speaking, Spark API does not let you obtain a key. Which is quite sad. You have two options: either include a key in each of inputs or include it in a state.
Upvotes: 4