Uploaded image for project: 'Apache IoTDB'
  1. Apache IoTDB
  2. IOTDB-285

Duplicate fields in EngineDataSetWithoutValueFilter.java

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.9.0
    • 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

          Activity

            People

              Unassigned Unassigned
              jackietien Yuan Tian
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m