Package com.browseengine.bobo.util

Examples of com.browseengine.bobo.util.BigSegmentedArray


  private BigSegmentedArray getCollapsedCounts(){
  if (_collapsedCounts==null){
    _collapsedCounts = new LazyBigIntArray(_bucketValues.size());
    FacetDataCache dataCache = _subCollector._dataCache;
    TermValueList<?> subList = dataCache.valArray;
    BigSegmentedArray subcounts = _subCollector._count;
    BitVector indexSet = new BitVector(subcounts.size());
    int c = 0;
    int i = 0;
    for (String val : _bucketValues){
      if (val.length()>0){
        String[] subVals = _predefinedBuckets.get(val);
        int count = 0;
        for (String subVal : subVals){
          int index = subList.indexOf(subVal);
          if (index>0){
            int subcount = subcounts.get(index);
            count+=subcount;
            if (!indexSet.get(index)){
              indexSet.set(index);
              c+=dataCache.freqs[index];
            }
View Full Code Here


      int index = _bucketValues.indexOf(bucketValue);
      if (index<0){
        return new BrowseFacet(bucketValue,0);
      }
     
      BigSegmentedArray counts = getCollapsedCounts();
   
      return new BrowseFacet(bucketValue,counts.get(index));
  }
View Full Code Here

    int index = _bucketValues.indexOf(value);
    if (index<0){
      return 0;
    }
   
    BigSegmentedArray counts = getCollapsedCounts();
 
    return counts.get(index);
  }
View Full Code Here

 
  // get facets for all predefined buckets
  public List<BrowseFacet> getFacets()
  {

  BigSegmentedArray counts = getCollapsedCounts();
    return DefaultFacetCountCollector.getFacets(_ospec, counts, counts.size(), _bucketValues);

  }
View Full Code Here

    _subCollector.close();
  }   

  public FacetIterator iterator()
  {
  BigSegmentedArray counts = getCollapsedCounts();
  return new DefaultFacetIterator(_bucketValues, counts, counts.size(), true);
 
View Full Code Here

  /**
   * @return Count distribution for all the user specified range values
   */
  public BigSegmentedArray getCountDistribution() {
    BigSegmentedArray dist = null;
    if(_predefinedRanges != null) {
      dist = new LazyBigIntArray(_predefinedRanges.size());
      int distIdx = 0;
      for (int i = 0; i < _count.size(); i++) {
        int count = _count.get(i);
        dist.add(distIdx++, count);
      }
    }
    return dist;
  }
View Full Code Here

      if (startIdx < 0) startIdx = -(startIdx + 1);
     
      int endIdx = _valArray.indexOf(_end);
      if (endIdx < 0) endIdx = -(endIdx + 1);
     
      BigSegmentedArray baseCounts = _baseCollector.getCountDistribution();
      if(_start instanceof Long)
      {
        long start = _start.longValue();
        long unit = _unit.longValue();
        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 instanceof Integer)
      {
        int start = _start.intValue();
        int unit = _unit.intValue();
        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 = _start.doubleValue();
        double unit = _unit.doubleValue();
        for(int i = startIdx; i < endIdx; i++)
        {
          Number val = (Number)_valArray.getRawValue(i);
          int idx = (int)((val.doubleValue() - start) / unit);
          if(idx >= 0 && idx < _count.size())
          {
            _count.add(idx, _count.get(idx) + baseCounts.get(i));
          }
        }
      }
    }
View Full Code Here

  /**
   * gets distribution of the value arrays. When predefined ranges are available, this returns distribution by predefined ranges.
   */
  public BigSegmentedArray getCountDistribution()
  {
    BigSegmentedArray dist;
    if (_predefinedRangeIndexes!=null)
    {
      dist = new LazyBigIntArray(_predefinedRangeIndexes.length);
      int n=0;
      for (int[] range : _predefinedRangeIndexes)
      {
        int start = range[0];
        int end = range[1];
       
        int sum = 0;
        for (int i=start;i<end;++i)
        {
          sum += _count.get(i);
        }
        dist.add(n++, sum);
      }
    }
    else
    {
      dist = _count;
View Full Code Here

      {
        int minCount=_ospec.getMinHitCount();
        int maxNumOfFacets = _ospec.getMaxCount();
        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;
        FacetSortSpec sortspec = _ospec.getOrderBy();
        if (sortspec == FacetSortSpec.OrderValueAsc)
        {
          facetColl = new ArrayList<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.size() >= maxNumOfFacets) break;
          }
        }
        else //if (sortspec == FacetSortSpec.OrderHitsDesc)
        {
          ComparatorFactory comparatorFactory;
          if (sortspec == FacetSortSpec.OrderHitsDesc)
          {
            comparatorFactory = new FacetHitcountComparatorFactory();
          }
          else
          {
            comparatorFactory = _ospec.getCustomComparatorFactory();
          }

          if (comparatorFactory == null){
            throw new IllegalArgumentException("facet comparator factory not specified");
          }

          final IntComparator comparator = comparatorFactory.newComparator(new FieldValueAccessor(){
              public String getFormatedValue(int index)
              {
                return _predefinedRanges.get(index);
              }

              public Object getRawValue(int index) {
                return _predefinedRanges.getRawValue(index);
              }
            }, rangeCount);
         
          final 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 LinkedList<BrowseFacet>();
          while((val = pq.pollInt()) != forbidden)
          {
            BrowseFacet facet=new BrowseFacet(_predefinedRanges.get(val),rangeCount.get(val));
            ((LinkedList<BrowseFacet>)facetColl).addFirst(facet);
          }
        }
        return facetColl;
      }
View Full Code Here

    // TODO Auto-generated method stub
  }   

  public FacetIterator iterator() {
    if(_predefinedRanges != null) {
      BigSegmentedArray rangeCounts = 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++);
            }
            rangeCounts.add(k, rangeCounts.get(k) + count);
          }
      return new DefaultFacetIterator(_predefinedRanges, rangeCounts, rangeCounts.size(), true);
    }
    return null;
 
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.util.BigSegmentedArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.