mirror of https://github.com/apache/lucene.git
Speed up Lucene912PostingsReader nextDoc() impls. (#13963)
127 times out of 128, nextDoc() returns the next doc ID in the buffer. Currently, we check if the current doc is equal to the last doc ID in the block to know if we need to refill. We can do better by comparing the current index in the block with the block size, which is a bit more efficient since the latter is a constant.
This commit is contained in:
parent
60ddd08c95
commit
9359cfd32f
|
@ -77,6 +77,9 @@ Optimizations
|
|||
|
||||
* GITHUB#13961: Replace Map<String,Object> with IntObjectHashMap for DV producer. (Pan Guixin)
|
||||
|
||||
* GITHUB#13963: Speed up nextDoc() implementations in Lucene912PostingsReader.
|
||||
(Adrien Grand)
|
||||
|
||||
Bug Fixes
|
||||
---------------------
|
||||
* GITHUB#13832: Fixed an issue where the DefaultPassageFormatter.format method did not format passages as intended
|
||||
|
|
|
@ -580,7 +580,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase {
|
|||
|
||||
@Override
|
||||
public int nextDoc() throws IOException {
|
||||
if (doc == level0LastDocID) { // advance skip data on level 0
|
||||
if (docBufferUpto == BLOCK_SIZE) { // advance skip data on level 0
|
||||
moveToNextLevel0Block();
|
||||
}
|
||||
|
||||
|
@ -875,7 +875,7 @@ public final class Lucene912PostingsReader extends PostingsReaderBase {
|
|||
|
||||
@Override
|
||||
public int nextDoc() throws IOException {
|
||||
if (doc == level0LastDocID) { // advance level 0 skip data
|
||||
if (docBufferUpto == BLOCK_SIZE) { // advance level 0 skip data
|
||||
moveToNextLevel0Block();
|
||||
}
|
||||
|
||||
|
@ -1417,11 +1417,13 @@ public final class Lucene912PostingsReader extends PostingsReaderBase {
|
|||
|
||||
@Override
|
||||
public int nextDoc() throws IOException {
|
||||
if (doc == level0LastDocID) {
|
||||
moveToNextLevel0Block();
|
||||
} else if (needsRefilling) {
|
||||
refillDocs();
|
||||
needsRefilling = false;
|
||||
if (docBufferUpto == BLOCK_SIZE) {
|
||||
if (needsRefilling) {
|
||||
refillDocs();
|
||||
needsRefilling = false;
|
||||
} else {
|
||||
moveToNextLevel0Block();
|
||||
}
|
||||
}
|
||||
|
||||
return this.doc = (int) docBuffer[docBufferUpto++];
|
||||
|
@ -1644,8 +1646,9 @@ public final class Lucene912PostingsReader extends PostingsReaderBase {
|
|||
|
||||
@Override
|
||||
public int nextDoc() throws IOException {
|
||||
advanceShallow(doc + 1);
|
||||
if (needsRefilling) {
|
||||
if (docBufferUpto == BLOCK_SIZE) {
|
||||
advanceShallow(doc + 1);
|
||||
assert needsRefilling;
|
||||
refillDocs();
|
||||
needsRefilling = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue