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

IndexWriter.getMergingSegments should return a Set, not Collection

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/index
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      IndexWriter.getMergingSegments is called by the MergePolicy so that it can filter out segments to merge using mergingSegments.contains(seg). The implementation is a HashSet, thankfully but the declared type of this method ought to be defined as a Set as well.

        Activity

        Hide
        dsmiley David Smiley added a comment -

        Here's a simple patch. I altered the callers likewise.

        I figure this will have no back-compat concern.

        Show
        dsmiley David Smiley added a comment - Here's a simple patch. I altered the callers likewise. I figure this will have no back-compat concern.
        Hide
        mikemccand Michael McCandless added a comment -

        +1

        Show
        mikemccand Michael McCandless added a comment - +1
        Hide
        jpountz Adrien Grand added a comment -

        +1 Should we also wrap with a Collections.unmodifiableSet to prevent callers from modifying IndexWriter's state?

        Show
        jpountz Adrien Grand added a comment - +1 Should we also wrap with a Collections.unmodifiableSet to prevent callers from modifying IndexWriter's state?

          People

          • Assignee:
            dsmiley David Smiley
            Reporter:
            dsmiley David Smiley
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:

              Development