Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-1369

Eliminate unnecessary uses of Hashtable and Vector

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.2
    • Fix Version/s: 2.4
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      Lucene uses Vector, Hashtable and Enumeration when it doesn't need to. Changing to ArrayList and HashMap may provide better performance.

      There are a few places Vector shows up in the API. IMHO, List should have been used for parameters and return values.

      There are a few distinct usages of these classes:

      1. internal but with ArrayList or HashMap would do as well. These can simply be replaced.
      2. internal and synchronization is required. Either leave as is or use a collections synchronization wrapper.
      3. As a parameter to a method where List or Map would do as well. For contrib, just replace. For core, deprecate current and add new method signature.
      4. Generated by JavaCC. (All *.jj files.) Nothing to be done here.
      5. As a base class. Not sure what to do here. (Only applies to SegmentInfos extends Vector, but it is not used in a safe manner in all places. Perhaps, implements List would be better.)
      6. As a return value from a package protected method, but synchronization is not used. Change return type.
      7. As a return value to a final method. Change to List or Map.

      In using a Vector the following iteration pattern is frequently used.
      for (int i = 0; i < v.size(); i++) {
      Object o = v.elementAt;
      }

      This is an indication that synchronization is unimportant. The list could change during iteration.

        Attachments

        1. LUCENE-1369.patch
          87 kB
          DM Smith

          Activity

            People

            • Assignee:
              mikemccand Michael McCandless
              Reporter:
              dmsmith DM Smith
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: