Yuan Tian created IOTDB-285:
-------------------------------
Summary: Duplicate fields in EngineDataSetWithoutValueFilter.java
Key: IOTDB-285
URL: https://issues.apache.org/jira/browse/IOTDB-285
Project: Apache IoTDB
Issue Type: Improvement
Reporter: Yuan Tian
There two fields in EngineDataSetWithoutValueFilter.java used to fetch the
minimum time.
{code:java}
// Some comments here
private PriorityQueue<Long> timeHeap;
private Set<Long> timeSet;
{code}
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:
{code:java}
private synchronized void timeHeapPut(long time) {
if (!timeSet.contains(time)) {
timeSet.add(time);
timeHeap.add(time);
}
}
{code}
But, if we only use TreeSet, we can simply use the corresponding version,
ConcurrentSkipListSet, to replace it.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)