Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.3, 1.7.2, 1.8.1
-
We have added a new method MapState#isEmpty() which enables users to check whether a map state is empty. The new method is 40% faster than mapState.keys().iterator().hasNext() when using the RocksDB state backend.
Description
Currently, there existed several scenarios to check whether map state is empty in Flink source code, e.g.TemporalRowTimeJoinOperator, AbstractRowTimeUnboundedPrecedingOver.
Developers would use below command to check whether the map state is empty:
boolean noRecordsToProcess = !inputState.keys().iterator().hasNext();
However, if we use RocksDBStateBackend, inputState.keys().iterator().hasNext() would actually call 1 seek and 128 next actions in RocksDBMapState, in which the redundant next actions are not what we want.
I have two options to improve this:
- Modify RocksDBMapState back to previous design which would first load one element and then load more elements in the follow-up queries. However, this would effect the performance of other map state methods.
- Add a isEmpty() method in the public evolving interface MapState, so that we could use it to check whether the map state is empty without any redundant RocksDB actions.
I prefer to the 2nd option.
Attachments
Issue Links
- is caused by
-
FLINK-8639 Fix always need to seek multiple times when iterator RocksDBMapState
- Closed
- is related to
-
FLINK-13846 Implement benchmark case on MapState#isEmpty
- Closed
- links to