Lucene - Core
  1. Lucene - Core
  2. LUCENE-5701

Move core closed listeners to AtomicReader

    Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.9, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Core listeners are very helpful when managing per-segment caches (filters, uninverted doc values, etc.) yet this API is only exposed on SegmentReader. If you want to use it today, you need to do instanceof checks, try to unwrap in case of a FilterAtomicReader and finally fall back to a reader closed listener if every other attempt to get the underlying SegmentReader failed.

      1. LUCENE-5701.patch
        19 kB
        Adrien Grand
      2. LUCENE-5701.patch
        18 kB
        Adrien Grand

        Activity

        Hide
        Robert Muir added a comment -

        +1

        Show
        Robert Muir added a comment - +1
        Hide
        Adrien Grand added a comment -

        Here is a patch:

        • add/removeCoreClosedListener is abstract on AtomicReader
        • SegmentReader keeps doing the same thing
        • FilterAtomicReader delegates the call
        • Composite implementations (ParallelAtomicReader, SlowCompositeReaderWrapper) and implementations that don't have a core (MemoryIndexReader) call the listener upon closing.
        Show
        Adrien Grand added a comment - Here is a patch: add/removeCoreClosedListener is abstract on AtomicReader SegmentReader keeps doing the same thing FilterAtomicReader delegates the call Composite implementations ( ParallelAtomicReader , SlowCompositeReaderWrapper ) and implementations that don't have a core ( MemoryIndexReader ) call the listener upon closing.
        Hide
        Robert Muir added a comment -

        Patch looks great. Can SlowCompositeReaderWrapper register the listener on 'in' somehow?

        That's its coreCacheKey: so if you have a directoryreader and you wrap it multiple times (e.g. on-the-fly), the caches are shared.

        Show
        Robert Muir added a comment - Patch looks great. Can SlowCompositeReaderWrapper register the listener on 'in' somehow? That's its coreCacheKey: so if you have a directoryreader and you wrap it multiple times (e.g. on-the-fly), the caches are shared.
        Hide
        Adrien Grand added a comment -

        Good catch, I had missed that SCRW didn't return this as a cache key. Here is a new patch, I made the IndexReader on which to apply the close listener explicit in addCoreClosedListenerAsReaderClosedListener and modified the test to make sure the listener is added to the wrapped reader.

        Show
        Adrien Grand added a comment - Good catch, I had missed that SCRW didn't return this as a cache key. Here is a new patch, I made the IndexReader on which to apply the close listener explicit in addCoreClosedListenerAsReaderClosedListener and modified the test to make sure the listener is added to the wrapped reader.
        Hide
        Robert Muir added a comment -

        Looks good, nice improvement!

        Show
        Robert Muir added a comment - Looks good, nice improvement!
        Hide
        ASF subversion and git services added a comment -

        Commit 1597180 from Adrien Grand in branch 'dev/trunk'
        [ https://svn.apache.org/r1597180 ]

        LUCENE-5701: Move core closed listeners to AtomicReader.

        Show
        ASF subversion and git services added a comment - Commit 1597180 from Adrien Grand in branch 'dev/trunk' [ https://svn.apache.org/r1597180 ] LUCENE-5701 : Move core closed listeners to AtomicReader.
        Hide
        ASF subversion and git services added a comment -

        Commit 1597181 from Adrien Grand in branch 'dev/trunk'
        [ https://svn.apache.org/r1597181 ]

        LUCENE-5701: This is a 4.9 change.

        Show
        ASF subversion and git services added a comment - Commit 1597181 from Adrien Grand in branch 'dev/trunk' [ https://svn.apache.org/r1597181 ] LUCENE-5701 : This is a 4.9 change.
        Hide
        ASF subversion and git services added a comment -

        Commit 1598487 from Adrien Grand in branch 'dev/branches/branch_4x'
        [ https://svn.apache.org/r1598487 ]

        LUCENE-5701: Move core closed listeners to AtomicReader.

        Show
        ASF subversion and git services added a comment - Commit 1598487 from Adrien Grand in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1598487 ] LUCENE-5701 : Move core closed listeners to AtomicReader.

          People

          • Assignee:
            Adrien Grand
            Reporter:
            Adrien Grand
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development