Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-785

Refactor repetitive comparison/loop code in CompiledIn.evaluate

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0.0-incubating.M2
    • querying
    • None

    Description

      In CompiledIn.evaluate we can see repetitive loops, each one differing only in the cast to a specific array type. For example:
      // handle each type of primitive array
      if (evalColln instanceof long[]) {
      long[] a = (long[])evalColln;
      for (int i = 0; i < a.length; i++) {
      Object e = Long.valueOf(a[i]);
      if (TypeUtils.compare(evalElm, e, TOK_EQ).equals(Boolean.TRUE))

      { return Boolean.TRUE; }
      }
      return Boolean.FALSE;
      }

      if (evalColln instanceof double[]) {
      double[] a = (double[])evalColln;
      for (int i = 0; i < a.length; i++) {
      Object e = Double.valueOf(a[i]);
      if (TypeUtils.compare(evalElm, e, TOK_EQ).equals(Boolean.TRUE)) { return Boolean.TRUE; }

      }
      return Boolean.FALSE;
      }

      We should be able to write a test to exercise this code and then write a single loop that handles all object thypes as the comparison is actually done by the TypeUtils.compare() method.

      Attachments

        Activity

          People

            jasonhuynh Jason Huynh
            jasonhuynh Jason Huynh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: