public override TermsEnum GetEnumerator() { return(docTermOrds.GetTermsEnum()); }
public override TermsEnum GetIterator(TermsEnum reuse) { return(docTermOrds.GetTermsEnum()); }
public override void SetNextReader(AtomicReaderContext context) { if (m_segmentFacetCounts != null) { m_segmentResults.Add(CreateSegmentResult()); } groupFieldTermsIndex = FieldCache.DEFAULT.GetTermsIndex(context.AtomicReader, m_groupField); facetFieldDocTermOrds = FieldCache.DEFAULT.GetDocTermOrds(context.AtomicReader, m_facetField); facetFieldNumTerms = (int)facetFieldDocTermOrds.ValueCount; if (facetFieldNumTerms == 0) { facetOrdTermsEnum = null; } else { facetOrdTermsEnum = facetFieldDocTermOrds.GetTermsEnum(); } // [facetFieldNumTerms() + 1] for all possible facet values and docs not containing facet field m_segmentFacetCounts = new int[facetFieldNumTerms + 1]; m_segmentTotalCount = 0; segmentGroupedFacetHits.Clear(); foreach (GroupedFacetHit groupedFacetHit in groupedFacetHits) { int groupOrd = groupedFacetHit.groupValue == null ? -1 : groupFieldTermsIndex.LookupTerm(groupedFacetHit.groupValue); if (groupedFacetHit.groupValue != null && groupOrd < 0) { continue; } int facetOrd; if (groupedFacetHit.facetValue != null) { if (facetOrdTermsEnum == null || !facetOrdTermsEnum.SeekExact(groupedFacetHit.facetValue)) { continue; } facetOrd = (int)facetOrdTermsEnum.Ord; } else { facetOrd = facetFieldNumTerms; } // (facetFieldDocTermOrds.numTerms() + 1) for all possible facet values and docs not containing facet field int segmentGroupedFacetsIndex = groupOrd * (facetFieldNumTerms + 1) + facetOrd; segmentGroupedFacetHits.Put(segmentGroupedFacetsIndex); } if (m_facetPrefix != null) { TermsEnum.SeekStatus seekStatus; if (facetOrdTermsEnum != null) { seekStatus = facetOrdTermsEnum.SeekCeil(m_facetPrefix); } else { seekStatus = TermsEnum.SeekStatus.END; } if (seekStatus != TermsEnum.SeekStatus.END) { m_startFacetOrd = (int)facetOrdTermsEnum.Ord; } else { m_startFacetOrd = 0; m_endFacetOrd = 0; return; } BytesRef facetEndPrefix = BytesRef.DeepCopyOf(m_facetPrefix); facetEndPrefix.Append(UnicodeUtil.BIG_TERM); seekStatus = facetOrdTermsEnum.SeekCeil(facetEndPrefix); if (seekStatus != TermsEnum.SeekStatus.END) { m_endFacetOrd = (int)facetOrdTermsEnum.Ord; } else { m_endFacetOrd = facetFieldNumTerms; // Don't include null... } } else { m_startFacetOrd = 0; m_endFacetOrd = facetFieldNumTerms + 1; } }