LUCENE-6161: reuse DocsEnum when resolving deleted terms/queries to doc id

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1649599 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-01-05 17:53:18 +00:00
parent 6a4273b200
commit a13b71aa41
1 changed files with 27 additions and 25 deletions

View File

@ -408,7 +408,7 @@ class BufferedUpdatesStream implements Accountable {
TermsEnum termsEnum = null; TermsEnum termsEnum = null;
String currentField = null; String currentField = null;
DocsEnum docs = null; DocsEnum docsEnum = null;
assert checkDeleteTerm(null); assert checkDeleteTerm(null);
@ -433,36 +433,38 @@ class BufferedUpdatesStream implements Accountable {
} }
if (termsEnum == null) { if (termsEnum == null) {
// no terms in this field
continue; continue;
} }
assert checkDeleteTerm(term); assert checkDeleteTerm(term);
// System.out.println(" term=" + term); // System.out.println(" term=" + term);
if (termsEnum.seekExact(term.bytes())) { if (termsEnum.seekExact(term.bytes())) {
// we don't need term frequencies for this // we don't need term frequencies for this
DocsEnum docsEnum = termsEnum.docs(rld.getLiveDocs(), docs, DocsEnum.FLAG_NONE); docsEnum = termsEnum.docs(rld.getLiveDocs(), docsEnum, DocsEnum.FLAG_NONE);
//System.out.println("BDS: got docsEnum=" + docsEnum); //System.out.println("BDS: got docsEnum=" + docsEnum);
if (docsEnum != null) { assert docsEnum != null;
while (true) {
final int docID = docsEnum.nextDoc(); while (true) {
//System.out.println(Thread.currentThread().getName() + " del term=" + term + " doc=" + docID); final int docID = docsEnum.nextDoc();
if (docID == DocIdSetIterator.NO_MORE_DOCS) { //System.out.println(Thread.currentThread().getName() + " del term=" + term + " doc=" + docID);
break; if (docID == DocIdSetIterator.NO_MORE_DOCS) {
} break;
if (!any) { }
rld.initWritableLiveDocs(); if (!any) {
any = true; rld.initWritableLiveDocs();
} any = true;
// NOTE: there is no limit check on the docID }
// when deleting by Term (unlike by Query) // NOTE: there is no limit check on the docID
// because on flush we apply all Term deletes to // when deleting by Term (unlike by Query)
// each segment. So all Term deleting here is // because on flush we apply all Term deletes to
// against prior segments: // each segment. So all Term deleting here is
if (rld.delete(docID)) { // against prior segments:
delCount++; if (rld.delete(docID)) {
} delCount++;
} }
} }
} }
@ -488,7 +490,7 @@ class BufferedUpdatesStream implements Accountable {
String currentField = null; String currentField = null;
TermsEnum termsEnum = null; TermsEnum termsEnum = null;
DocsEnum docs = null; DocsEnum docsEnum = null;
//System.out.println(Thread.currentThread().getName() + " numericDVUpdate reader=" + reader); //System.out.println(Thread.currentThread().getName() + " numericDVUpdate reader=" + reader);
for (DocValuesUpdate update : updates) { for (DocValuesUpdate update : updates) {
@ -514,19 +516,19 @@ class BufferedUpdatesStream implements Accountable {
termsEnum = terms.iterator(termsEnum); termsEnum = terms.iterator(termsEnum);
} else { } else {
termsEnum = null; termsEnum = null;
continue; // no terms in that field
} }
} }
if (termsEnum == null) { if (termsEnum == null) {
// no terms in this field
continue; continue;
} }
// System.out.println(" term=" + term); // System.out.println(" term=" + term);
if (termsEnum.seekExact(term.bytes())) { if (termsEnum.seekExact(term.bytes())) {
// we don't need term frequencies for this // we don't need term frequencies for this
DocsEnum docsEnum = termsEnum.docs(rld.getLiveDocs(), docs, DocsEnum.FLAG_NONE); docsEnum = termsEnum.docs(rld.getLiveDocs(), docsEnum, DocsEnum.FLAG_NONE);
//System.out.println("BDS: got docsEnum=" + docsEnum); //System.out.println("BDS: got docsEnum=" + docsEnum);
DocValuesFieldUpdates dvUpdates = dvUpdatesContainer.getUpdates(update.field, update.type); DocValuesFieldUpdates dvUpdates = dvUpdatesContainer.getUpdates(update.field, update.type);