apache / apache/lucene

Should DocIdSetIterator#docID be final?

Open
#14,887 3 comments 0 reactions 0 assignees View on GitHub
type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

`DocIdSetIterator#docID` is always a simple getter, but because we allow many different implementations, it almost always requires a virtual call in practice, which makes it not so cheap.

We could instead have a protected `DocIdSetIterator#docID` field, make `DocIdSetIterator#docID()` return it, and update the contract of `nextDoc()` and `advance(int)` to require updating this `docID` field. Most implementations already do this, it would mostly be a change for wrappers (including `ConjunctionDISI`), which would need to copy the current doc ID of the wrapped iterator to their `docID` field.

Contributor guide

Open the contributing guide

Research direction

Start with DocIdSetIterator and inspect its docID(), nextDoc(), and advance(int) contract, then audit implementations and wrappers such as ConjunctionDISI. Determine which implementations already track the current document and which must copy a wrapped iterator's value; done means the field-based contract works consistently across the affected implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.