Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BrowseFacet


      if(!_isAggregated) aggregate();
     
      int idx = Integer.parseInt(value);
      if(idx >= 0 && idx < _count.size())
      {
        return new BrowseFacet(value, _count.get(idx));
      }
      return null;
    }
View Full Code Here


          for (int i = 0; i < _count.size(); ++i)
          {
          int hits = _count.get(i);
            if (hits >= minCount)
            {
              BrowseFacet facet = new BrowseFacet(_formatter.format(i),hits);
              facetColl.add(facet);
            }
            if (facetColl.size() >= max) break;
          }
          return facetColl;
View Full Code Here

      int count = 0;
      for (int i = startIdx;i<startIdx+segLen;++i){
        count+=_count.get(i);
      }

      BrowseFacet f = new BrowseFacet(buf.toString(),count);
      return f;
    }
View Full Code Here

          for (int i = 1; i < _countlength;++i) // exclude zero
          {
            int hits=_count.get(i);
            if (hits>=minCount)
            {
              BrowseFacet facet=new BrowseFacet(getFacetString(i),hits);
              facetColl.add(facet);
            }
            if (facetColl.size()>=max) break;
          }
        }
        else{
          ComparatorFactory comparatorFactory;
          if (sortspec == FacetSortSpec.OrderHitsDesc){
            comparatorFactory = new FacetHitcountComparatorFactory();
          }
          else{
            comparatorFactory = _fspec.getCustomComparatorFactory();
          }

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

          IntComparator comparator = comparatorFactory.newComparator(new FieldValueAccessor(){

            public String getFormatedValue(int index) {
              return getFacetString(index);
            }

            public Object getRawValue(int index) {
              return getRawFaceValue(index);
            }

          }, _count);
          facetColl=new LinkedList<BrowseFacet>();
          final int forbidden = -1;
          IntBoundedPriorityQueue pq=new IntBoundedPriorityQueue(comparator,max, forbidden);

          for (int i=1;i<_countlength;++i) // exclude zero
          {
            int hits=_count.get(i);
            if (hits>=minCount)
            {
              if(!pq.offer(i))
              {
                // pq is full. we can safely ignore any facet with <=hits.
                minCount = hits + 1;
              }
            }
          }

          int val;
          while((val = pq.pollInt()) != forbidden)
          {
            BrowseFacet facet=new BrowseFacet(getFacetString(val),_count.get(val));
            ((LinkedList<BrowseFacet>)facetColl).addFirst(facet);
          }
        }
        return facetColl;
      }
View Full Code Here

      return _name;
  }
 
  public BrowseFacet getFacet(String value)
  {
      BrowseFacet facet = null;
      int[] range = FacetRangeFilter.parse(_dataCache,value);
      if (range!=null)
      {
          int sum=0;
          for (int i=range[0];i<=range[1];++i)
          {
              sum+=_count.get(i);
          }
          facet = new BrowseFacet(value,sum);
      }
      return facet;
  }
View Full Code Here

        List<BrowseFacet> facetColl = new ArrayList<BrowseFacet>(_predefinedRanges.size());
          for (int k=0;k<_predefinedRangeIndexes.length;++k)
          {
            if(rangeCount[k] >= minCount)
            {
              BrowseFacet choice=new BrowseFacet(_predefinedRanges.get(k), rangeCount[k]);
              facetColl.add(choice);
            }
            //if(facetColl.size() >= maxNumOfFacets) break;
          }
        return facetColl;
View Full Code Here

          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

    @Override
    public BrowseFacet getFacet(String value)
    {
      String rangeString = buildRangeString(value);
      BrowseFacet facet = super.getFacet(rangeString);
      if (facet!=null)
      {
        return new BrowseFacet(value,facet.getHitCount());
      }
      else
      {
        return null;
      }
View Full Code Here

      List<BrowseFacet> list = super.getFacets();     
      ArrayList<BrowseFacet> retList = new ArrayList<BrowseFacet>(list.size());
      Iterator<BrowseFacet> iter = list.iterator();
      while(iter.hasNext())
      {
        BrowseFacet facet = iter.next();
        String val = facet.getValue();
        String rangeString = getValueFromRangeString(val);
        if (rangeString != null)
        {
          BrowseFacet convertedFacet = new BrowseFacet(rangeString, facet.getHitCount());
          retList.add(convertedFacet);
        }
      }
      return retList;
    }
View Full Code Here

      List<BrowseFacet> facets = new ArrayList<BrowseFacet>();
      while(iter.hasNext())
      {
        Comparable facet = iter.next();
        int count = iter.count;
        facets.add(new BrowseFacet(getValueFromRangeString(String.valueOf(facet)), count));
      }
      Collections.sort(facets, ListMerger.FACET_VAL_COMPARATOR);
      return new PathFacetIterator(facets);
    }
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.api.BrowseFacet

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.