/// <summary>
 /// (non-Javadoc)
 /// see java.util.Iterator#next()
 /// </summary>
 /// <returns></returns>
 public override string Next()
 {
     if ((_index >= 0) && (_index >= _countLengthMinusOne))
     {
         throw new IndexOutOfRangeException("No more facets in this iteration");
     }
     _index++;
     _facet = _valList.GetPrimitiveValue(_index);
     count  = _count.Get(_index);
     return(_valList.Get(_index));
 }
Ejemplo n.º 2
0
 public virtual Explanation Explain(IndexReader reader, int doc, Explanation innerExplanation)
 {
     if (reader is BoboIndexReader)
     {
         BoboIndexReader boboReader = (BoboIndexReader)reader;
         object          dataObj    = boboReader.GetFacetData(_timeFacetName);
         if (dataObj is FacetDataCache)
         {
             FacetDataCache    facetDataCache = (FacetDataCache)(boboReader.GetFacetData(_timeFacetName));
             BigSegmentedArray orderArray     = facetDataCache.OrderArray;
             TermLongList      termList       = (TermLongList)facetDataCache.ValArray;
             long        now       = System.Environment.TickCount;
             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(BoboIndexReader));
     }
 }
Ejemplo n.º 3
0
            private void Aggregate()
            {
                if (_isAggregated)
                {
                    return;
                }

                _isAggregated = true;

                int startIdx = _valArray.IndexOf(_start);

                if (startIdx < 0)
                {
                    startIdx = -(startIdx + 1);
                }

                int endIdx = _valArray.IndexOf(_end);

                if (endIdx < 0)
                {
                    endIdx = -(endIdx + 1);
                }

                BigSegmentedArray baseCounts = _baseCollector.GetCountDistribution();

                if (_start is long)
                {
                    long         start    = Convert.ToInt64(_start);
                    long         unit     = Convert.ToInt64(_unit);
                    TermLongList valArray = (TermLongList)_valArray;
                    for (int i = startIdx; i < endIdx; i++)
                    {
                        long val = valArray.GetPrimitiveValue(i);
                        int  idx = (int)((val - start) / unit);
                        if (idx >= 0 && idx < _count.Size())
                        {
                            _count.Add(idx, _count.Get(idx) + baseCounts.Get(i));
                        }
                    }
                }
                else if (_start is int)
                {
                    int         start    = Convert.ToInt32(_start);
                    int         unit     = Convert.ToInt32(_unit);
                    TermIntList valArray = (TermIntList)_valArray;
                    for (int i = startIdx; i < endIdx; i++)
                    {
                        int val = valArray.GetPrimitiveValue(i);
                        int idx = ((val - start) / unit);
                        if (idx >= 0 && idx < _count.Size())
                        {
                            _count.Add(idx, _count.Get(idx) + baseCounts.Get(i));
                        }
                    }
                }
                else
                {
                    double start = Convert.ToDouble(_start);
                    double unit  = Convert.ToDouble(_unit);
                    for (int i = startIdx; i < endIdx; i++)
                    {
                        double val = (double)_valArray.GetRawValue(i);
                        int    idx = (int)((val - start) / unit);
                        if (idx >= 0 && idx < _count.Size())
                        {
                            _count.Add(idx, _count.Get(idx) + baseCounts.Get(i));
                        }
                    }
                }
            }