• Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9
    • Fix Version/s: 3.3, 4.0-ALPHA
    • Component/s: core/index
    • Labels:
    • Lucene Fields:
      New, Patch Available


      Applying the attached patch shows the improvements to that I think should be done. All logic that does anything at all is moved to instance methods of the inner class Resolution. I argue this is more object-oriented.

      1. In cases where Resolution is an argument to the method, I can simply invoke the appropriate call on the Resolution object. Formerly there was a big branch if/else.
      2. Instead of "synchronized" being used seemingly everywhere, synchronized is used to sync on the object that is not threadsafe, be it a DateFormat or Calendar instance.
      3. Since different DateFormat and Calendar instances are created per-Resolution, there is now less lock contention since threads using different resolutions will not use the same locks.
      4. The old implementation of timeToString rounded the time before formatting it. That's unnecessary since the format only includes the resolution desired.
      5. round() now uses a switch statement that benefits from fall-through (no break).

      Another debatable improvement that could be made is putting the resolution instances into an array indexed by format length. This would mean I could remove the switch in lookupResolutionByLength() and avoid the length constants there. Maybe that would be a bit too over-engineered when the switch is fine.

      1. LUCENE-1736.patch
        8 kB
        Steve Rowe
      2. LUCENE-1736_DateTools_improvements.patch
        8 kB
        David Smiley
      3. cleanerDateTools.patch
        11 kB
        David Smiley


        Robert Muir made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Steve Rowe made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 3.3 [ 12316470 ]
        Resolution Fixed [ 1 ]
        Steve Rowe made changes -
        Attachment LUCENE-1736.patch [ 12481635 ]
        Steve Rowe made changes -
        Assignee Steven Rowe [ steve_rowe ]
        David Smiley made changes -
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12563506 ] jira [ 12585100 ]
        Mark Thomas made changes -
        Workflow jira [ 12469911 ] Default workflow, editable Closed status [ 12563506 ]
        Robert Muir made changes -
        Component/s Index [ 12310232 ]
        Mark Miller made changes -
        Fix Version/s 3.1 [ 12314025 ]
        David Smiley made changes -
        Field Original Value New Value
        Attachment cleanerDateTools.patch [ 12412819 ]
        David Smiley created issue -


          • Assignee:
            Steve Rowe
            David Smiley
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: