Package org.apache.spark.sql.streaming
Interface ListState<S>
- All Superinterfaces:
Serializable
Interface used for arbitrary stateful operations with the v2 API to capture list value state.
-
Method Summary
Modifier and TypeMethodDescriptionvoidappendList(Object newState) Function to append a list of entries to the existing state list.voidappendValue(S newState) Function to append a single entry to the existing state list.voidclear()Function to remove the state for the current grouping key.booleanexists()Function to check whether state exists for current grouping key or not.scala.collection.Iterator<S>get()Function to get the list of elements in the state as an iterator.voidFunction to update the value of the state with a new list.
-
Method Details
-
appendList
Function to append a list of entries to the existing state list.Note that if this is the first time the state is being appended to, the state will be initialized to an empty list before appending the new entries.
- Parameters:
newState- - list of elements to be appended
-
appendValue
Function to append a single entry to the existing state list.Note that if this is the first time the state is being appended to, the state will be initialized to an empty list before appending the new entry.
- Parameters:
newState- - single list element to be appended
-
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
scala.collection.Iterator<S> get()Function to get the list of elements in the state as an iterator. If the state does not exist, an empty iterator is returned.Note that it's always recommended to check whether the state exists or not by calling exists() before calling get().
- Returns:
- - an iterator of elements in the state if it exists, an empty iterator otherwise.
-
put
Function to update the value of the state with a new list.Note that this will replace the existing value with the new value.
- Parameters:
newState- - new list of elements
-