Lucene - Core
  1. Lucene - Core
  2. LUCENE-1185

[PATCH] Avoid checking for TermBuffer in SegmentTermEnum#scanTo

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3, 2.3.1, 2.4
    • Fix Version/s: 2.4
    • Component/s: core/index
    • Labels:
      None
    • Environment:

      any

    • Lucene Fields:
      New, Patch Available

      Description

      It seems that SegmentTermEnum#scanTo is a critical method which is called very often, especially whenever we iterate over a sequence of terms in an index.

      When that method is called, the first thing happens is that it checks whether a temporary TermBuffer "scratch" has already been initialized.

      In fact, this is not necessary. We can simply declare and initialize the "scratch"-Buffer at the class-level (right now, the initial value is null). Java's lazy-loading capabilities allow this without adding any memory footprint for cases where we do not need that buffer.

      The attached patch takes care of this. We now save one comparison per term.
      In addition to that, the patch renames "scratch" to "scanBuffer", which aligns with the naming of the other two buffers that are declared in the class.

        Activity

        Christian Kohlschütter created issue -
        Hide
        Christian Kohlschütter added a comment -

        The patch.

        Show
        Christian Kohlschütter added a comment - The patch.
        Christian Kohlschütter made changes -
        Field Original Value New Value
        Attachment patch-SegmentTermEnum.diff [ 12376212 ]
        Christian Kohlschütter made changes -
        Attachment patch-SegmentTermEnum.diff [ 12376212 ]
        Hide
        Christian Kohlschütter added a comment -

        The patch.

        Show
        Christian Kohlschütter added a comment - The patch.
        Christian Kohlschütter made changes -
        Attachment LUCENE-1185-SegmentTermEnum.patch [ 12376219 ]
        Hide
        Michael Busch added a comment -

        Committed. Thanks Christian!

        Show
        Michael Busch added a comment - Committed. Thanks Christian!
        Michael Busch made changes -
        Lucene Fields [Patch Available, New] [New, Patch Available]
        Fix Version/s 2.4 [ 12312681 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Michael McCandless made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12424192 ] Default workflow, editable Closed status [ 12562586 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12562586 ] jira [ 12583542 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Christian Kohlschütter
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development