Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUCENE-9352: Add iteratorCost function to Scorable #1554

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions lucene/core/src/java/org/apache/lucene/search/Scorable.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public void setMinCompetitiveScore(float minScore) throws IOException {
// no-op by default
}

/**
* Returns the estimated cost of the {@link DocIdSetIterator} associated with this {@link Scorable}.
* 0 is the default value if the {@link Scorable} doesn't have any associated {@link DocIdSetIterator}.
*/
public long iteratorCost() {
return 0;
}

/**
* Returns child sub-scorers positioned on the current document
* @lucene.experimental
Expand Down
8 changes: 8 additions & 0 deletions lucene/core/src/java/org/apache/lucene/search/Scorer.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public Weight getWeight() {
*/
public abstract DocIdSetIterator iterator();

/**
* Returns the estimated cost of the {@link DocIdSetIterator} associated with this {@link Scorer}.
*/
@Override
public long iteratorCost() {
return iterator().cost();
}

/**
* Optional method: Return a {@link TwoPhaseIterator} view of this
* {@link Scorer}. A return value of {@code null} indicates that
Expand Down