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

Add another AnalyzerWrapper class that does not have its own cache, so delegate-only wrappers don't create thread local resources several times

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.9
    • 4.10, 6.0
    • modules/analysis
    • None
    • New

    Description

      This is a followup issue for the following Elasticsearch issue: https://github.com/elasticsearch/elasticsearch/pull/6714

      Basically the problem is the following:

      • Elasticsearch has a pool of Analyzers that are used for analysis in several indexes
      • Each index uses a different PerFieldAnalyzerWrapper

      PerFieldAnalyzerWrapper uses PER_FIELD_REUSE_STRATEGY. Because of this it caches the tokenstreams for every field. If there are many fields, this are a lot. In addition, the underlying analyzers may also cache tokenstreams and other PerFieldAnalyzerWrappers do the same, although the delegate Analyzer can always return the same components.

      We should add similar code to Elasticsearch's directly to Lucene: If the delegating Analyzer just delegates per Field or just wraps CharFilters around the Reader, there is no need to cache the TokenStreamComponents a second time in the delegating Analyzers. This is only needed, if the delegating Analyzers adds additional TokenFilters (like ShingleAnalyzerWrapper).

      We should name this new class DelegatingAnalyzerWrapper extends AnalyzerWrapper. The wrapComponents method must be final, because we are not allowed to add additional TokenFilters, but unlike ES, we don't need to disallow wrapping with CharFilters.

      Internally this class uses a private ReuseStrategy that just delegates to the underlying analyzer. It does not matter here if the strategy of the delegate is global or per field, this is private to the delegate.

      Attachments

        1. LUCENE-5803.patch
          16 kB
          Uwe Schindler
        2. LUCENE-5803.patch
          15 kB
          Uwe Schindler
        3. LUCENE-5803.patch
          14 kB
          Uwe Schindler
        4. LUCENE-5803.patch
          11 kB
          Uwe Schindler
        5. LUCENE-5803.patch
          9 kB
          Uwe Schindler
        6. LUCENE-5803.patch
          9 kB
          Uwe Schindler

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            uschindler Uwe Schindler
            uschindler Uwe Schindler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment