Lucene - Core
  1. Lucene - Core
  2. LUCENE-2865

Pass a context struct to Weight#scorer instead of naked booleans

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0-ALPHA
    • Fix Version/s: 4.0-ALPHA
    • Component/s: core/search
    • Labels:
      None
    • Lucene Fields:
      New, Patch Available

      Description

      Weight#scorer(AtomicReaderContext, boolean, boolean) is hard to extend if another boolean like "needsScoring" or similar flags / information need to be passed to Scorers. An immutable struct would make such an extension trivial / way easier.

      1. LUCENE-2865.patch
        40 kB
        Simon Willnauer
      2. LUCENE-2865.patch
        40 kB
        Simon Willnauer

        Activity

        Hide
        Simon Willnauer added a comment -

        here is a patch that adds a ScorerContext to replace those two booleans. ScorerContext follows a "copy on write" pattern similar to a builder pattern that only modifies the context if the values actually change. Seems pretty straight forward so far.

        Show
        Simon Willnauer added a comment - here is a patch that adds a ScorerContext to replace those two booleans. ScorerContext follows a "copy on write" pattern similar to a builder pattern that only modifies the context if the values actually change. Seems pretty straight forward so far.
        Hide
        Uwe Schindler added a comment -

        Looks good!

        I would make the ctor private and then use ScorerContext.default().x().y() as pattern (default returns the template). I like this design more

        Show
        Uwe Schindler added a comment - Looks good! I would make the ctor private and then use ScorerContext.default().x().y() as pattern (default returns the template). I like this design more
        Hide
        Simon Willnauer added a comment -

        I would make the ctor private and then use ScorerContext.default().x().y() as pattern (default returns the template). I like this design more

        Jawohl! - Since default is a keyword in java I used ScorerContext#def() instead. I fixed some JDoc issues, made all ScorerContext ctors private and added a changes.txt entry

        seems like we are good to go

        Show
        Simon Willnauer added a comment - I would make the ctor private and then use ScorerContext.default().x().y() as pattern (default returns the template). I like this design more Jawohl! - Since default is a keyword in java I used ScorerContext#def() instead. I fixed some JDoc issues, made all ScorerContext ctors private and added a changes.txt entry seems like we are good to go
        Hide
        Uwe Schindler added a comment -

        +1 to commit, looks good.

        For later we should fix BooleanQuery.explain() to use default context, too. topScorer=true is wrong for explain (but has no effect here).

        Show
        Uwe Schindler added a comment - +1 to commit, looks good. For later we should fix BooleanQuery.explain() to use default context, too. topScorer=true is wrong for explain (but has no effect here).
        Hide
        Simon Willnauer added a comment -

        Committed revision 1058592.

        thanks uwe for the review

        Show
        Simon Willnauer added a comment - Committed revision 1058592. thanks uwe for the review

          People

          • Assignee:
            Simon Willnauer
            Reporter:
            Simon Willnauer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development