masteryhx commented on code in PR #19679:
URL: https://github.com/apache/flink/pull/19679#discussion_r934228172
##########
flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/HeapAggregatingState.java:
##########
@@ -136,18 +144,29 @@ public ACC apply(ACC accumulator, IN value) {
}
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "rawtypes"})
static <T, K, N, SV, S extends State, IS extends S> IS create(
StateDescriptor<S, SV> stateDesc,
StateTable<K, N, SV> stateTable,
- TypeSerializer<K> keySerializer) {
- return (IS)
- new HeapAggregatingState<>(
- stateTable,
- keySerializer,
- stateTable.getStateSerializer(),
- stateTable.getNamespaceSerializer(),
- stateDesc.getDefaultValue(),
- ((AggregatingStateDescriptor<T, SV, ?>)
stateDesc).getAggregateFunction());
+ TypeSerializer<K> keySerializer,
+ @Nullable IS existingState) {
+ return existingState == null
+ ? (IS)
+ new HeapAggregatingState<>(
Review Comment:
I think using `createOrUpdate` is fine to make all state operations
centralized and it may be not so confused.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]