You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2011/12/21 19:05:53 UTC
svn commit: r1221826 - in /lucene/dev/trunk:
lucene/src/java/org/apache/lucene/util/SentinelIntSet.java
solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
Author: yonik
Date: Wed Dec 21 18:05:52 2011
New Revision: 1221826
URL: http://svn.apache.org/viewvc?rev=1221826&view=rev
Log:
SOLR-2950: QEC comparator bug fixes, including deleted docs handling
Modified:
lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java?rev=1221826&r1=1221825&r2=1221826&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/util/SentinelIntSet.java Wed Dec 21 18:05:52 2011
@@ -30,6 +30,11 @@ public class SentinelIntSet {
public final int emptyVal;
public int rehashCount; // the count at which a rehash should be done
+ /**
+ *
+ * @param size The minimum number of elements this set should be able to hold without re-hashing (i.e. the slots are guaranteed not to change)
+ * @param emptyVal The integer value to use for EMPTY
+ */
public SentinelIntSet(int size, int emptyVal) {
this.emptyVal = emptyVal;
int tsize = Math.max(org.apache.lucene.util.BitUtil.nextHighestPowerOfTwo(size), 1);
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java?rev=1221826&r1=1221825&r2=1221826&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java Wed Dec 21 18:05:52 2011
@@ -25,6 +25,7 @@ import org.apache.lucene.document.Docume
import org.apache.lucene.index.*;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.*;
+import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.SentinelIntSet;
import org.apache.lucene.util.automaton.Automaton;
@@ -518,18 +519,23 @@ public class QueryElevationComponent ext
//convert the ids to Lucene doc ids, the ordSet and termValues needs to be the same size as the number of elevation docs we have
ordSet.clear();
Fields fields = context.reader.fields();
+ if (fields == null) return this;
Terms terms = fields.terms(fieldname);
+ if (terms == null) return this;
termsEnum = terms.iterator(termsEnum);
BytesRef term = new BytesRef();
+ Bits liveDocs = context.reader.getLiveDocs();
for (String id : elevations.ids) {
term.copyChars(id);
if (seen.contains(id) == false && termsEnum.seekExact(term, false)) {
- docsEnum = termsEnum.docs(null, docsEnum, false);
+ docsEnum = termsEnum.docs(liveDocs, docsEnum, false);
if (docsEnum != null) {
int docId = docsEnum.nextDoc();
+ if (docId == DocIdSetIterator.NO_MORE_DOCS ) continue; // must have been deleted
termValues[ordSet.put(docId)] = BytesRef.deepCopyOf(term);
seen.add(id);
+ assert docsEnum.nextDoc() == DocIdSetIterator.NO_MORE_DOCS;
}
}
}