Permalink
Browse files

upgrade to solr 3.4

  • Loading branch information...
1 parent 82038f8 commit a569dcd69ff629c936948480cbfb2dbaf3c4747e @tjake committed Oct 6, 2011
Showing with 45 additions and 1 deletion.
  1. +1 −1 ivy.xml
  2. +44 −0 src/org/apache/lucene/search/LucandraFieldCache.java
View
@@ -27,7 +27,7 @@
<dependency org="commons-cli" name="commons-cli" rev="1.1" conf="* -> *,!sources,!javadoc"/>
<dependency org="commons-lang" name="commons-lang" rev="2.4" conf="* -> *,!sources,!javadoc"/>
<dependency org="commons-collections" name="commons-collections" rev="3.2.1" conf="* -> *,!sources,!javadoc"/>
- <dependency org="org.apache.solr" name="solr-core" rev="3.3.0" conf="* -> *,!javadoc">
+ <dependency org="org.apache.solr" name="solr-core" rev="3.4.0" conf="* -> *,!javadoc">
<exclude org="org.mortbay.jetty"/>
<exclude org="org.slf4j"/>
</dependency>
@@ -30,6 +30,7 @@
import org.apache.log4j.Logger;
import org.apache.lucene.index.*;
import org.apache.lucene.util.FieldCacheSanityChecker;
+import org.apache.lucene.util.OpenBitSet;
import org.apache.lucene.util.StringHelper;
import org.apache.solr.core.SolandraCoreContainer;
@@ -56,6 +57,7 @@ private synchronized void init()
caches.put(Double.TYPE, new DoubleCache(this));
caches.put(String.class, new StringCache(this));
caches.put(StringIndex.class, new StringIndexCache(this));
+ caches.put(UnValuedDocsCache.class, new UnValuedDocsCache(this));
}
public synchronized void purgeAllCaches()
@@ -320,6 +322,42 @@ public int hashCode()
}
}
+ static final class UnValuedDocsCache extends Cache {
+ UnValuedDocsCache(FieldCache wrapper) {
+ super(wrapper);
+ }
+
+ @Override
+ protected Object createValue(IndexReader reader, Entry entryKey)
+ throws IOException {
+ Entry entry = entryKey;
+ String field = entry.field;
+
+ if (reader.maxDoc() == reader.docFreq(new Term(field))) {
+ return DocIdSet.EMPTY_DOCIDSET;
+ }
+
+ OpenBitSet res = new OpenBitSet(reader.maxDoc());
+ TermDocs termDocs = reader.termDocs();
+ TermEnum termEnum = reader.terms (new Term (field));
+ try {
+ do {
+ Term term = termEnum.term();
+ if (term==null || term.field() != field) break;
+ termDocs.seek (termEnum);
+ while (termDocs.next()) {
+ res.fastSet(termDocs.doc());
+ }
+ } while (termEnum.next());
+ } finally {
+ termDocs.close();
+ termEnum.close();
+ }
+ res.flip(0, reader.maxDoc());
+ return res;
+ }
+ }
+
// inherit javadocs
public byte[] getBytes(IndexReader reader, String field) throws IOException
{
@@ -863,4 +901,10 @@ public PrintStream getInfoStream()
{
return infoStream;
}
+
+ @Override
+ public DocIdSet getUnValuedDocs(IndexReader reader, String field) throws IOException
+ {
+ return (DocIdSet) caches.get(UnValuedDocsCache.class).get(reader, new Entry(field, null));
+ }
}

0 comments on commit a569dcd

Please sign in to comment.