small optimization: re-use a single TermDocs instance when deleting-by-Term

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@761000 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-04-01 18:25:18 +00:00
parent ef613da566
commit fe475f0176
1 changed files with 14 additions and 15 deletions

View File

@ -952,25 +952,24 @@ final class DocumentsWriter {
// Delete by term
Iterator iter = deletesFlushed.terms.entrySet().iterator();
while (iter.hasNext()) {
Entry entry = (Entry) iter.next();
Term term = (Term) entry.getKey();
TermDocs docs = reader.termDocs();
try {
while (iter.hasNext()) {
Entry entry = (Entry) iter.next();
Term term = (Term) entry.getKey();
TermDocs docs = reader.termDocs(term);
if (docs != null) {
docs.seek(term);
int limit = ((BufferedDeletes.Num) entry.getValue()).getNum();
try {
while (docs.next()) {
int docID = docs.doc();
if (docIDStart+docID >= limit)
break;
reader.deleteDocument(docID);
any = true;
}
} finally {
docs.close();
while (docs.next()) {
int docID = docs.doc();
if (docIDStart+docID >= limit)
break;
reader.deleteDocument(docID);
any = true;
}
}
} finally {
docs.close();
}
// Delete by docID