Annotation Type StateHint
-
@PublicEvolving @Retention(RUNTIME) @Target({TYPE,METHOD,PARAMETER}) public @interface StateHint
A hint that declares an intermediate result (i.e. state entry) that is managed by the framework (i.e. Flink managed state).State hints are primarily intended for
ProcessTableFunction. A PTF supports multiple state entries at the beginning of an eval()/onTimer() method (after an optional context parameter).Aggregating functions (i.e.
AggregateFunctionandTableAggregateFunction) support a single state entry at the beginning of an accumulate()/retract() method (i.e. the accumulator).Because state needs to be mutable for read and write access, only row or structured types qualify as a data type for state entries. For example,
@StateHint(name = "count", type = @DataTypeHint("ROW<count BIGINT>"))is a state entry with the data type BIGINT named "count".Note: A state entry is partitioned by a key and can not be accessed globally. The partitioning (or a single partition in case of no partitioning) is defined by the corresponding function call.
- See Also:
FunctionHint
-
-
Element Detail
-
name
String name
The name of the state entry. It must be unique among other state entries.This can be used to provide a descriptive name for the state entry. The name can be used for referencing the entry during clean up.
- Default:
- ""
-
-
-
type
DataTypeHint type
The data type hint for the state entry.This can be used to provide additional information about the expected data type of the argument. The
DataTypeHintannotation can be used to specify the data type explicitly or provide hints for the reflection-based extraction of the data type.- Default:
- @org.apache.flink.table.annotation.DataTypeHint
-
-
-
ttl
String ttl
The time-to-live (TTL) duration that automatically cleans up the state entry.It specifies a minimum time interval for how long idle state (i.e., state which was not updated by a create or write operation) will be retained. State will never be cleared until it was idle for less than the minimum time, and will be cleared at some time after it was idle.
Use this for being able to efficiently manage an ever-growing state size or for complying with data protection requirements.
The cleanup is based on processing time, which effectively corresponds to the wall clock time as defined by
System.currentTimeMillis()).The provided string must use Flink's duration syntax (e.g., "3 days", "45 min", "3 hours", "60 s"). If no unit is specified, the value is interpreted as milliseconds. The TTL setting on a state entry has higher precedence than the global state TTL configuration for the entire pipeline.
- See Also:
TimeUtils.parseDuration(String)
- Default:
- ""
-
-