/// <summary> /// (non-Javadoc) /// see com.browseengine.bobo.api.FacetAccessible#getFacets() /// </summary> /// <returns></returns> public virtual IEnumerable <BrowseFacet> GetFacets() { if (_spec != null) { if (_latPredefinedRangeIndexes != null) { int minCount = _spec.MinHitCount; int[] rangeCounts = new int[_latPredefinedRangeIndexes.Length]; for (int i = 0; i < _latCount.Length; ++i) { if (_latCount[i] > 0) { for (int k = 0; k < _latPredefinedRangeIndexes.Length; ++k) { if (i >= _latPredefinedRangeIndexes[k][0] && i <= _latPredefinedRangeIndexes[k][1]) { rangeCounts[k] += _latCount[i]; } } } } List <BrowseFacet> list = new List <BrowseFacet>(rangeCounts.Length); for (int i = 0; i < rangeCounts.Length; ++i) { if (rangeCounts[i] >= minCount) { BrowseFacet choice = new BrowseFacet(); choice.FacetValueHitCount = rangeCounts[i]; choice.Value = _predefinedRanges.Get(i); list.Add(choice); } } return(list); } else { return(FacetCountCollector_Fields.EMPTY_FACET_LIST); } } else { return(FacetCountCollector_Fields.EMPTY_FACET_LIST); } }
public string GetFormatedValue(int index) { return(_predefinedRanges.Get(index)); }
public virtual List <BrowseFacet> GetFacetsNew() { if (_ospec != null) { if (_predefinedRangeIndexes != null) { int minCount = _ospec.MinHitCount; int maxNumOfFacets = _ospec.MaxCount; if (maxNumOfFacets <= 0 || maxNumOfFacets > _predefinedRangeIndexes.Length) { maxNumOfFacets = _predefinedRangeIndexes.Length; } BigSegmentedArray rangeCount = new LazyBigIntArray(_predefinedRangeIndexes.Length); for (int k = 0; k < _predefinedRangeIndexes.Length; ++k) { int count = 0; int idx = _predefinedRangeIndexes[k][0]; int end = _predefinedRangeIndexes[k][1]; while (idx <= end) { count += _count.Get(idx++); } rangeCount.Add(k, count); } List <BrowseFacet> facetColl; FacetSpec.FacetSortSpec sortspec = _ospec.OrderBy; if (sortspec == FacetSpec.FacetSortSpec.OrderValueAsc) { facetColl = new List <BrowseFacet>(maxNumOfFacets); for (int k = 0; k < _predefinedRangeIndexes.Length; ++k) { if (rangeCount.Get(k) >= minCount) { BrowseFacet choice = new BrowseFacet(_predefinedRanges.Get(k), rangeCount.Get(k)); facetColl.Add(choice); } if (facetColl.Count >= maxNumOfFacets) { break; } } } else //if (sortspec == FacetSortSpec.OrderHitsDesc) { IComparatorFactory comparatorFactory; if (sortspec == FacetSpec.FacetSortSpec.OrderHitsDesc) { comparatorFactory = new FacetHitcountComparatorFactory(); } else { comparatorFactory = _ospec.CustomComparatorFactory; } if (comparatorFactory == null) { throw new ArgumentException("facet comparator factory not specified"); } IComparer <int> comparator = comparatorFactory.NewComparator(new RangeFacetCountCollectorFieldAccessor(_predefinedRanges), rangeCount); int forbidden = -1; IntBoundedPriorityQueue pq = new IntBoundedPriorityQueue(comparator, maxNumOfFacets, forbidden); for (int i = 0; i < _predefinedRangeIndexes.Length; ++i) { if (rangeCount.Get(i) >= minCount) { pq.Offer(i); } } int val; facetColl = new List <BrowseFacet>(); while ((val = pq.Poll()) != forbidden) { BrowseFacet facet = new BrowseFacet(_predefinedRanges.ElementAt(val), rangeCount.Get(val)); facetColl.Insert(0, facet); } } return(facetColl); } else { return(FacetCountCollector_Fields.EMPTY_FACET_LIST); } } else { return(FacetCountCollector_Fields.EMPTY_FACET_LIST); } }