-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement missing prepareSeekExact methods for TermsEnum
In apache/lucene#13359 a new "prepareSeekExact" method was added that can improve seeking on TermsEnum implementations. Two of our own subclasses of TermsEnum don't seem to support seeking for text, so we can safely throw an UOE there. The third (FilterableTermsEnum) changes to simple returning a Supplier for the actual "seek" method for now.
- Loading branch information
Showing
3 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import org.apache.lucene.util.BitSet; | ||
import org.apache.lucene.util.Bits; | ||
import org.apache.lucene.util.BytesRef; | ||
import org.apache.lucene.util.IOBooleanSupplier; | ||
import org.elasticsearch.core.Nullable; | ||
|
||
import java.io.IOException; | ||
|
@@ -61,7 +62,7 @@ static class Holder { | |
protected BytesRef current; | ||
protected final int docsEnumFlag; | ||
|
||
public FilterableTermsEnum(IndexReader reader, String field, int docsEnumFlag, @Nullable Query filter) throws IOException { | ||
public FilterableTermsEnum(IndexReader reader, String field, int docsEnumFlag, @Nullable Query f) throws IOException { | ||
if ((docsEnumFlag != PostingsEnum.FREQS) && (docsEnumFlag != PostingsEnum.NONE)) { | ||
throw new IllegalArgumentException("invalid docsEnumFlag of " + docsEnumFlag); | ||
} | ||
|
@@ -176,6 +177,11 @@ public boolean seekExact(BytesRef text) throws IOException { | |
} | ||
} | ||
|
||
@Override | ||
public IOBooleanSupplier prepareSeekExact(BytesRef bytesRef) { | ||
return () -> this.seekExact(bytesRef); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jpountz
Contributor
|
||
} | ||
|
||
@Override | ||
public int docFreq() throws IOException { | ||
return currentDocFreq; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jpountz I took this from BaseTermsEnum, I don't know if this can be done differently so far. This implementation seems to wrap a number of TermsEnum/Bitset pairs that are create in its contructor, and "seek" later loops over them. I don't know enough about your change in Lucene to decide whether also looping over those inner enums and call "prepareSeekExact" would be the better option here.