Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
There two fields in EngineDataSetWithoutValueFilter.java used to fetch the minimum time.
// Some comments here private PriorityQueue<Long> timeHeap; private Set<Long> timeSet;
the Set is used to keep heap from storing duplicate time.
However, a TreeSet field can do both things. No duplicate time and ensure the time order. There is no need to use these two.
Especially, when we want to change to multiThread version, to keep the timeHeapPut thread safe, we have to add a synchronized onto the method, like this:
private synchronized void timeHeapPut(long time) { if (!timeSet.contains(time)) { timeSet.add(time); timeHeap.add(time); } }
But, if we only use TreeSet, we can simply use the corresponding version, ConcurrentSkipListSet, to replace it.
Attachments
Issue Links
- links to