From b58675a60c22bb9d4b7f4d549e7c3008e2392005 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Sat, 19 Jun 2010 20:45:21 +0000 Subject: [PATCH] SOLR-1965: use native array access for facet.method=fcs git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@956292 13f79535-47bb-0310-9956-ffa450edef68 --- .../PerSegmentSingleValuedFaceting.java | 71 ++++++++++++++++--- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java b/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java index 80a70839c03..03eaebbf8c6 100755 --- a/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java +++ b/solr/src/java/org/apache/solr/request/PerSegmentSingleValuedFaceting.java @@ -7,6 +7,10 @@ import org.apache.lucene.search.FieldCache; import org.apache.lucene.search.Filter; import org.apache.lucene.util.PriorityQueue; import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.packed.Direct16; +import org.apache.lucene.util.packed.Direct32; +import org.apache.lucene.util.packed.Direct8; +import org.apache.lucene.util.packed.PackedInts; import org.apache.solr.common.SolrException; import org.apache.solr.common.params.FacetParams; import org.apache.solr.common.util.NamedList; @@ -248,21 +252,66 @@ class PerSegmentSingleValuedFaceting { DocIdSet idSet = baseSet.getDocIdSet(reader); DocIdSetIterator iter = idSet.iterator(); - if (startTermIndex==0 && endTermIndex==si.numOrd()) { - // specialized version when collecting counts for all terms - int doc; - while ((doc = iter.nextDoc()) < DocIdSetIterator.NO_MORE_DOCS) { - counts[si.getOrd(doc)]++; + + //// + PackedInts.Reader ordReader = si.getDocToOrd(); + int doc; + + if (ordReader instanceof Direct32) { + int[] ords = ((Direct32)ordReader).getArray(); + if (prefix==null) { + while ((doc = iter.nextDoc()) < DocIdSetIterator.NO_MORE_DOCS) { + counts[ords[doc]]++; + } + } else { + while ((doc = iter.nextDoc()) < DocIdSetIterator.NO_MORE_DOCS) { + int term = ords[doc]; + int arrIdx = term-startTermIndex; + if (arrIdx>=0 && arrIdx=0 && arrIdx=0 && arrIdx=0 && arrIdx=0 && arrIdx