StreamingAggregationStateManager Contract — State Managers for Streaming Aggregation
StreamingAggregationStateManager is the contract of state managers that are used in streaming aggregations (with StateStoreSaveExec and StateStoreRestoreExec physical operators).
| Method | Description | ||
|---|---|---|---|
|
|
Used exclusively when StateStoreSaveExec physical operator is executed. |
||
|
|
Gets the saved state for a non-null key from a state store Used exclusively when StateStoreRestoreExec physical operator is executed. |
||
|
|
Used when:
|
||
|
|
The schema for the state values Used when StateStoreRestoreExec and StateStoreSaveExec physical operators are executed. |
||
|
|
Returns all the Used exclusively when StateStoreSaveExec physical operator is executed. |
||
|
|
Returns all keys in a state store (as an iterator) Used exclusively when physical operators with |
||
|
|
Stores a row in a state store Used exclusively when StateStoreSaveExec physical operator is executed. |
||
|
|
Used exclusively when StateStoreSaveExec physical operator is executed (directly or indirectly as a WatermarkSupport) |
||
|
|
Returns all the values in a state store Used exclusively when StateStoreSaveExec physical operator is executed. |
StreamingAggregationStateManager supports two versions of state managers for streaming aggregations:
|
Note
|
The version of a state manager is controlled using spark.sql.streaming.aggregation.stateFormatVersion internal configuration property. |
|
Note
|
StreamingAggregationStateManagerBaseImpl is the one and only known base 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
|
1 2 3 4 5 6 7 8 |
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:
|
1 2 3 4 5 |
Version [stateFormatVersion] is invalid |
|
Note
|
createStateManager is used when StateStoreRestoreExec and StateStoreSaveExec physical operators are created.
|
spark技术分享