Package org.apache.spark.sql.streaming
Interface ValueState<S>
- All Superinterfaces:
Serializable
Interface used for arbitrary stateful operations with the v2 API to capture single value state.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Function to remove the state for the current grouping key.boolean
exists()
Function to check whether state exists for current grouping key or not.get()
Function to get the state value for the current grouping key.void
Function to update the value of the state for the current grouping key to the new value.
-
Method Details
-
clear
void clear()Function to remove the state for the current grouping key. -
exists
boolean exists()Function to check whether state exists for current grouping key or not.- Returns:
- - true if state exists, false otherwise.
-
get
S get()Function to get the state value for the current grouping key. If the state exists, the value is returned. If the state does not exist, the default value for the type is returned for AnyVal types and null for AnyRef types.Note that it's always recommended to check whether the state exists or not by calling exists() before calling get().
- Returns:
- - the value of the state if it exists. If the state does not exist, the default value for the type is returned for AnyVal types and null for AnyRef types.
-
update
Function to update the value of the state for the current grouping key to the new value.- Parameters:
newState
- - the new value
-