Timing out of states in mapWithState
<p>I wanted to write a function in mapwithstate which has timing-out enabled...</p>

<pre><code>def trackStateFunc(batchTime: Time, 
                    key: String, value: Option[Int], 
                    state: State[Long]): Option[(String, Long)] = {
   if (state.isTimingOut()) {
     //write state to database
     return None
   } else if (state.exists) {
       var c = state.get()
       if (value.getOrElse(null) != null) {
         //update c
         c = c + value
         state.update(c)
       }
       Some(key,c)
     } else {
         Some(key,value.getOrElse(0).toLong)
       }
}
</code></pre>

<p>I wanted to know if a sate has been timing-out then it would probably doesn't exits, do my above code doesn't throw any exception..</p>

<p>In which case the value <code>Option[int]</code> doesn't exist .. if it is timed out?</p>