wuda0112 commented on a change in pull request #224: URL: https://github.com/apache/lucene/pull/224#discussion_r694488864
########## File path: lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextFieldsReader.java ########## @@ -357,19 +380,55 @@ public int nextDoc() throws IOException { } } + private int advanceTarget(int target) throws IOException { + if (seekTo > 0) { + in.seek(seekTo); + seekTo = -1; + } + assert docID() < target; + int doc; + do { + doc = readDoc(); + } while (doc < target); + return doc; + } + @Override public int advance(int target) throws IOException { - // Naive -- better to index skip data - return slowAdvance(target); + advanceShallow(target); + return advanceTarget(target); } @Override public long cost() { return cost; } + + @Override + public void advanceShallow(int target) throws IOException { + if (skipReader.hasSkipList()) { + if (target > nextSkipDoc) { + int numSkipped = skipReader.skipTo(target) + 1; + if (numSkipped > lastNumSkipped) { Review comment: i just want to express "this time we have skipped docs", but it is redundant,unnecessary -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org