Github user jaxbihani commented on a diff in the pull request:
https://github.com/apache/flink/pull/2568#discussion_r81199485
--- Diff:
flink-libraries/flink-cep/src/main/java/org/apache/flink/cep/operator/AbstractCEPPatternOperator.java
---
@@ -126,11 +126,12 @@ public void restoreState(FSDataInputStream state)
throws Exception {
int numberPriorityQueueEntries = ois.readInt();
- priorityQueue = new
PriorityQueue<StreamRecord<IN>>(numberPriorityQueueEntries, new
StreamRecordComparator<IN>());
-
- for (int i = 0; i <numberPriorityQueueEntries; i++) {
- StreamElement streamElement =
streamRecordSerializer.deserialize(new DataInputViewStreamWrapper(ois));
- priorityQueue.offer(streamElement.<IN>asRecord());
+ if(numberPriorityQueueEntries > 0) {
+ priorityQueue = new
PriorityQueue<StreamRecord<IN>>(numberPriorityQueueEntries, new
StreamRecordComparator<IN>());
--- End diff --
I think if number of objects read are 0 then why would we want to create
object at all? Thats unnecessary and condition check will save some CPU cycles.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---