Uploaded image for project: 'Apache Apex Malhar'
  1. Apache Apex Malhar
  2. APEXMALHAR-23

Bug in offer(E e) function of com.datatorrent.lib.util.TopNSort.java

    XMLWordPrintableJSON

Details

    • Task
    • Status: Closed
    • Resolution: Fixed
    • None
    • 0.3.4
    • None
    • None

    Description

      In the current implementation offer(E e) of TopNSort.java

      @SuppressWarnings("unchecked")
      public boolean offer(E e)
      {
      if (q.size() <= qbound)

      { return q.offer(e); }

      boolean ret = true;
      boolean insert;
      Comparable<? super E> head = (Comparable<? super E>)q.peek();

      if (ascending)

      { // means head is the lowest value due to inversion insert = head.compareTo(e) <= 0; // e >= head }

      else

      { // means head is the highest value due to inversion insert = head.compareTo(e) >= 0; // head is <= e }

      if (insert && q.offer(e))

      { ret = true; q.poll(); }

      return ret;
      }

      the boolean variable ret should be initialized to false not true..

      Attachments

        Activity

          People

            chenar Chetan Narsude
            gaurav.gopi123 gaurav gupta
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: