From 49799e031f7370023870ca5609b3bb56e6b502e5 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Thu, 2 Feb 2012 01:37:50 +0000 Subject: [PATCH] LUCENE-1536: avoid needless checking of livedocs for solr DocSets git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1239432 13f79535-47bb-0310-9956-ffa450edef68 --- solr/core/src/java/org/apache/solr/search/BitDocSet.java | 7 +++++-- solr/core/src/java/org/apache/solr/search/DocSet.java | 9 ++++++--- .../src/java/org/apache/solr/search/SortedIntDocSet.java | 7 +++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/search/BitDocSet.java b/solr/core/src/java/org/apache/solr/search/BitDocSet.java index 9b0d8f12866..63397912531 100644 --- a/solr/core/src/java/org/apache/solr/search/BitDocSet.java +++ b/solr/core/src/java/org/apache/solr/search/BitDocSet.java @@ -17,6 +17,7 @@ package org.apache.solr.search; +import org.apache.lucene.index.AtomicReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.AtomicReaderContext; import org.apache.lucene.search.BitsFilteredDocIdSet; @@ -249,7 +250,9 @@ public class BitDocSet extends DocSetBase { return new Filter() { @Override public DocIdSet getDocIdSet(final AtomicReaderContext context, final Bits acceptDocs) throws IOException { - IndexReader reader = context.reader(); + AtomicReader reader = context.reader(); + // all Solr DocSets that are used as filters only include live docs + final Bits acceptDocs2 = acceptDocs == null ? null : (reader.getLiveDocs() == acceptDocs ? null : acceptDocs); if (context.isTopLevel) { return BitsFilteredDocIdSet.wrap(bs, acceptDocs); @@ -306,7 +309,7 @@ public class BitDocSet extends DocSetBase { }; } - }, acceptDocs); + }, acceptDocs2); } }; } diff --git a/solr/core/src/java/org/apache/solr/search/DocSet.java b/solr/core/src/java/org/apache/solr/search/DocSet.java index a5e0a29780e..d15e14b2979 100644 --- a/solr/core/src/java/org/apache/solr/search/DocSet.java +++ b/solr/core/src/java/org/apache/solr/search/DocSet.java @@ -17,6 +17,7 @@ package org.apache.solr.search; +import org.apache.lucene.index.AtomicReader; import org.apache.solr.common.SolrException; import org.apache.lucene.util.Bits; import org.apache.lucene.util.OpenBitSet; @@ -272,8 +273,10 @@ abstract class DocSetBase implements DocSet { return new Filter() { @Override - public DocIdSet getDocIdSet(final AtomicReaderContext context, final Bits acceptDocs) throws IOException { - IndexReader reader = context.reader(); + public DocIdSet getDocIdSet(final AtomicReaderContext context, Bits acceptDocs) throws IOException { + AtomicReader reader = context.reader(); + // all Solr DocSets that are used as filters only include live docs + final Bits acceptDocs2 = acceptDocs == null ? null : (reader.getLiveDocs() == acceptDocs ? null : acceptDocs); if (context.isTopLevel) { return BitsFilteredDocIdSet.wrap(bs, acceptDocs); @@ -321,7 +324,7 @@ abstract class DocSetBase implements DocSet { return null; } - }, acceptDocs); + }, acceptDocs2); } }; } diff --git a/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java b/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java index 54188904e4f..bac0b8d8634 100755 --- a/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java +++ b/solr/core/src/java/org/apache/solr/search/SortedIntDocSet.java @@ -17,6 +17,7 @@ package org.apache.solr.search; +import org.apache.lucene.index.AtomicReader; import org.apache.lucene.util.Bits; import org.apache.lucene.util.OpenBitSet; import org.apache.lucene.search.BitsFilteredDocIdSet; @@ -658,7 +659,9 @@ public class SortedIntDocSet extends DocSetBase { @Override public DocIdSet getDocIdSet(final AtomicReaderContext context, final Bits acceptDocs) throws IOException { - IndexReader reader = context.reader(); + AtomicReader reader = context.reader(); + // all Solr DocSets that are used as filters only include live docs + final Bits acceptDocs2 = acceptDocs == null ? null : (reader.getLiveDocs() == acceptDocs ? null : acceptDocs); final int base = context.docBase; final int maxDoc = reader.maxDoc(); @@ -759,7 +762,7 @@ public class SortedIntDocSet extends DocSetBase { return null; } - }, acceptDocs); + }, acceptDocs2); } }; }