commit(
store: StateStore): Long
StreamingAggregationStateManager Contract — State Managers for Streaming Aggregation
StreamingAggregationStateManager is the abstraction of state managers that act as middlemen between state stores and the physical operators used in Streaming Aggregation (e.g. StateStoreSaveExec and StateStoreRestoreExec).
| Method | Description |
|---|---|
|
Commits all updates (changes) to the given state store and returns the new version Used exclusively when StateStoreSaveExec physical operator is executed. |
|
Looks up the value of the key from the state store (the key is non- Used exclusively when StateStoreRestoreExec physical operator is executed. |
|
Extracts the columns for the key from the input row Used when:
|
|
Gets the schema of the values in a state store Used when StateStoreRestoreExec and StateStoreSaveExec physical operators are executed |
|
Returns all Used exclusively when StateStoreSaveExec physical operator is executed. |
|
Returns all the keys in the state store Used exclusively when physical operators with |
|
Stores (puts) the given row in the given state store Used exclusively when StateStoreSaveExec physical operator is executed. |
|
Removes the key-value pair from the given state store per key Used exclusively when StateStoreSaveExec physical operator is executed (directly or indirectly as a WatermarkSupport) |
|
All values in the state store Used exclusively when StateStoreSaveExec physical operator is executed. |
StreamingAggregationStateManager supports two versions of state managers for streaming aggregations (per the spark.sql.streaming.aggregation.stateFormatVersion internal configuration property):
-
1(for the legacy StreamingAggregationStateManagerImplV1) -
2(for the default StreamingAggregationStateManagerImplV2)
|
Note
|
StreamingAggregationStateManagerBaseImpl is the one and only known direct implementation of the StreamingAggregationStateManager Contract in Spark Structured Streaming. |
|
Note
|
StreamingAggregationStateManager is a Scala sealed trait which means that all the implementations are in the same compilation unit (a single file).
|
Creating StreamingAggregationStateManager Instance — createStateManager Factory Method
createStateManager(
keyExpressions: Seq[Attribute],
inputRowAttributes: Seq[Attribute],
stateFormatVersion: Int): StreamingAggregationStateManager
createStateManager creates a new StreamingAggregationStateManager for a given stateFormatVersion:
-
StreamingAggregationStateManagerImplV1 for
stateFormatVersionbeing1 -
StreamingAggregationStateManagerImplV2 for
stateFormatVersionbeing2
createStateManager throws a IllegalArgumentException for any other stateFormatVersion:
Version [stateFormatVersion] is invalid
|
Note
|
createStateManager is used when StateStoreRestoreExec and StateStoreSaveExec physical operators are created.
|