salvatorecampagna opened a new issue, #16447:
URL: https://github.com/apache/lucene/issues/16447

   ## Summary
   
   `Weight.scorerSupplier(LeafReaderContext)` currently declares `throws 
IOException`. Removing it would make the existing planning-time contract 
enforceable at compile time.
   
   ## Motivation
   
   `scorerSupplier()` is a planning-time method, invoked on every segment and 
every clause of a `BooleanQuery` before execution begins. It should be cheap: 
no reader opens or other I/O. Expensive work belongs in 
`ScorerSupplier#get(long leadCost)`, which is invoked only during execution.
   
   The `throws IOException` declaration makes it possible to accidentally call 
I/O methods such as `LeafReader.getBinaryDocValues()` directly inside 
`scorerSupplier()`. The API therefore relies on documentation and code review 
to enforce the contract.
   
   Lucene has already removed `throws IOException` from a number of methods 
that are not expected to perform I/O: `LeafReader#getPointValues` (#16057), 
`LeafReader#terms` (#16058), `LeafReader#getDocCount` (#16059), and 
`ScorerSupplier#setTopLevelScoringClause` (#14291). Removing it from 
`Weight.scorerSupplier()` would follow the same direction.
   
   ## Proposed change
   
   Remove `throws IOException` from `Weight.scorerSupplier(LeafReaderContext)` 
and update implementations accordingly. Existing overrides would need to drop 
the `throws IOException` declaration. Implementations that currently perform 
I/O inside `scorerSupplier()` would also need to defer that work to 
`ScorerSupplier#get()`, while implementations that only perform metadata 
lookups would require no behavioral changes.
   
   The Javadoc should be updated in the same change by removing the `@throws 
IOException` tag and explicitly documenting that `scorerSupplier()` must not 
perform I/O or other expensive work, which should instead be deferred to 
`ScorerSupplier#get()`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to