/// <summary> /// (non-Javadoc) /// see java.util.Iterator#next() /// </summary> /// <returns></returns> public override string Next() { if ((m_index >= 0) && (m_index >= m_countLengthMinusOne)) { throw new IndexOutOfRangeException("No more facets in this iteration"); } m_index++; m_facet = m_valList.GetPrimitiveValue(m_index); base.m_count = _count.Get(m_index); return(m_valList.Get(m_index)); }
public virtual Explanation Explain(AtomicReader reader, int doc, Explanation innerExplanation) { if (reader is BoboSegmentReader) { BoboSegmentReader boboReader = (BoboSegmentReader)reader; object dataObj = boboReader.GetFacetData(m_timeFacetName); if (dataObj is FacetDataCache) { FacetDataCache facetDataCache = (FacetDataCache)(boboReader.GetFacetData(m_timeFacetName)); BigSegmentedArray orderArray = facetDataCache.OrderArray; TermInt64List termList = (TermInt64List)facetDataCache.ValArray; Explanation finalExpl = new Explanation(); finalExpl.AddDetail(innerExplanation); float rawScore = innerExplanation.Value; long timeVal = termList.GetPrimitiveValue(orderArray.Get(doc)); float timeScore = ComputeTimeFactor(timeVal); float finalScore = CombineScores(timeScore, rawScore); finalExpl.Value = finalScore; finalExpl.Description = "final score = (time score: " + timeScore + ") * (raw score: " + rawScore + "), timeVal: " + timeVal; return(finalExpl); } else { throw new InvalidOperationException("underlying facet data must be of type FacetDataCache<long>"); } } else { throw new ArgumentException("reader not instance of " + typeof(BoboSegmentReader)); } }
private void Aggregate() { if (m_isAggregated) { return; } m_isAggregated = true; int startIdx = m_valArray.IndexOf(m_start); if (startIdx < 0) { startIdx = -(startIdx + 1); } int endIdx = m_valArray.IndexOf(m_end); if (endIdx < 0) { endIdx = -(endIdx + 1); } BigSegmentedArray baseCounts = m_baseCollector.GetCountDistribution(); if (m_start is long) { long start = Convert.ToInt64(m_start); long unit = Convert.ToInt64(m_unit); TermInt64List valArray = (TermInt64List)m_valArray; for (int i = startIdx; i < endIdx; i++) { long val = valArray.GetPrimitiveValue(i); int idx = (int)((val - start) / unit); if (idx >= 0 && idx < m_count.Length) { m_count.Add(idx, m_count.Get(idx) + baseCounts.Get(i)); } } } else if (m_start is int) { int start = Convert.ToInt32(m_start); int unit = Convert.ToInt32(m_unit); TermInt32List valArray = (TermInt32List)m_valArray; for (int i = startIdx; i < endIdx; i++) { int val = valArray.GetPrimitiveValue(i); int idx = ((val - start) / unit); if (idx >= 0 && idx < m_count.Length) { m_count.Add(idx, m_count.Get(idx) + baseCounts.Get(i)); } } } else { double start = Convert.ToDouble(m_start); double unit = Convert.ToDouble(m_unit); for (int i = startIdx; i < endIdx; i++) { double val = (double)m_valArray.GetRawValue(i); int idx = (int)((val - start) / unit); if (idx >= 0 && idx < m_count.Length) { m_count.Add(idx, m_count.Get(idx) + baseCounts.Get(i)); } } } }