Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.BoboIndexReader$WorkArea


    {
      @Override
      public SenseiDocIdSet getSenseiDocIdSet(final IndexReader reader) throws IOException {
        if (reader instanceof BoboIndexReader)
        {
          BoboIndexReader boboReader = (BoboIndexReader)reader;
          FacetHandler facetHandler = boboReader.getFacetHandler(field);
          if (facetHandler != null && facetHandler instanceof PathFacetHandler)
          {
            BrowseSelection sel = new BrowseSelection(field);
            sel.setValues(new String[]{path});
            sel.setSelectionProperty(PathFacetHandler.SEL_PROP_NAME_DEPTH, String.valueOf(depth));
View Full Code Here


  protected SenseiFilter doConstructFilter(Object json) throws Exception {
    final String fieldName =  json instanceof String ? (String) json : ((JSONObject) json).getString("field");
    return new SenseiFilter() {
      @Override
      public SenseiDocIdSet getSenseiDocIdSet(IndexReader reader) throws IOException {
        BoboIndexReader boboReader = (BoboIndexReader) reader;
        FacetHandler facetHandler = boboReader.getFacetHandler(fieldName);
        Object facetData = facetHandler.getFacetData(boboReader);

        String plan = EMPTY_STRING;

        if(facetData instanceof MultiValueFacetDataCache)
        {
          final MultiValueFacetDataCache facetDataCache = (MultiValueFacetDataCache) facetData;

          DocIdSet docIdSet = new DocIdSet() {
            @Override
            public DocIdSetIterator iterator() throws IOException {
              return new MultiValueFacetDocIdSetIterator(facetDataCache, 0);
            }
          };

          if(log.isDebugEnabled()) {
            plan = fieldName + " IS MULTIVALUE NULL";
          }

          return new SenseiDocIdSet(docIdSet, DocIdSetCardinality.exact(facetDataCache.freqs[0], boboReader.maxDoc() + 1), plan);
        }
        else if (facetData instanceof FacetDataCache)
        {
          final FacetDataCache facetDataCache = (FacetDataCache) facetData;

          DocIdSet docIdSet = new DocIdSet() {
            @Override
            public DocIdSetIterator iterator() throws IOException {
              return new FacetFilter.FacetDocIdSetIterator(facetDataCache, 0);
            }
          };

          if(log.isDebugEnabled()) {
            plan = fieldName + " IS NULL";
          }
          return new SenseiDocIdSet(docIdSet, DocIdSetCardinality.exact(facetDataCache.freqs[0], boboReader.maxDoc() + 1), plan);
        }
        throw new UnsupportedOperationException("The null filter is supported only for the bobo facetHandlers that use FacetDataCache");
      }
    };
  }
View Full Code Here

    public List<RuntimeFacetHandlerFactory<?, ?>> getFacetHandlerFactories() {
        return _facetHandlerFactories;
    }

    public BoboIndexReader decorate(ZoieIndexReader<BoboIndexReader> zoieReader) throws IOException {
        BoboIndexReader boboReader = null;
        if (zoieReader != null) {
            boboReader = BoboIndexReader.getInstanceAsSubReader(zoieReader, _facetHandlers, _facetHandlerFactories);
        }
        applyListeners(boboReader);
        return boboReader;
View Full Code Here


  @Override
  public SenseiDocIdSet getSenseiDocIdSet(IndexReader reader) throws IOException {
    if (reader instanceof BoboIndexReader) {
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      FacetHandler facetHandler = (FacetHandler)boboReader.getFacetHandler(_name);
      Object obj = null;

      String[] vals = _vals;
      String[] nots = _not;
      List<String> optimizedVals = new ArrayList<String>(vals.length);
View Full Code Here

    req.setFacetSpec("industry", fspec);
    req.setFacetSpec("proposal_accepts", fspec);
    req.setFacetSpec("num_endorsers", fspec);
    req.setFacetSpec("group_id", fspec);
   
    BoboIndexReader reader = BoboIndexReader.getInstance(IndexReader.open(idxDir));
    BoboBrowser browser = new BoboBrowser(reader);
   
    BrowseResult res = browser.browse(req);
   
    Map<String,FacetAccessible> facetMap = res.getFacetMap();
    Collection<FacetAccessible> facetCountCollectors = facetMap.values();
    Iterator<FacetAccessible> iter = facetCountCollectors.iterator();
    while (iter.hasNext())
    {
      FacetAccessible f = iter.next();
      if (f instanceof FacetCountCollector)
      {
        System.out.println("====================================");
        FacetCountCollector fc = (FacetCountCollector)f;
        int[] dist = fc.getCountDistribution();
        if (dist!=null)
        {
          ChiSquaredFacetCountStatisticsGenerator gen = new ChiSquaredFacetCountStatisticsGenerator();
          gen.setMinCount(0);
          FacetCountStatistics stats = gen.generateStatistic(dist, 0);
          System.out.println("stat for field "+fc.getName()+": "+stats);
          System.out.println("Centered distribution score: " + (stats.getDistribution()-(double)(stats.getNumSamplesCollected()-1))/Math.sqrt((2.0*(double)(stats.getNumSamplesCollected()-1))));
          System.out.println("........................");
          List<BrowseFacet> facetList = fc.getFacets();
          System.out.println(facetList);
          System.out.println("........................");
        }
        System.out.println("====================================");
      }
    }
    reader.close();
  }
View Full Code Here

    @Override
    public DocComparator getComparator(IndexReader reader, int docbase) throws IOException {
      if (!(reader instanceof BoboIndexReader))
        throw new IllegalStateException("reader not instance of " + BoboIndexReader.class);
      BoboIndexReader boboReader = (BoboIndexReader) reader;
      final FacetDataCache dataCache = _facetHandler.getFacetData(boboReader);
      final BigSegmentedArray orderArray = dataCache.orderArray;
      return new DocComparator() {
       
        @Override
View Full Code Here

    BrowseHit[] hits = new BrowseHit[scoreDocs.length];
    Collection<FacetHandler<?>> facetHandlers= facetHandlerMap.values();
    for (int i =scoreDocs.length-1; i >=0 ; i--)
    {
      MyScoreDoc fdoc = scoreDocs[i];
      BoboIndexReader reader = fdoc.reader;
      BrowseHit hit=new BrowseHit();
      if (fetchStoredFields)
      {
        hit.setStoredFields(reader.document(fdoc.doc));
      }
      if (termVectorsToFetch!=null && termVectorsToFetch.size()>0){
        Map<String,TermFrequencyVector> tvMap = new HashMap<String,TermFrequencyVector>();
        hit.setTermFreqMap(tvMap);
        for (String field : termVectorsToFetch){
          TermFreqVector tv = reader.getTermFreqVector(fdoc.doc, field);
          if (tv!=null){
            int[] freqs = tv.getTermFrequencies();
            String[] terms = tv.getTerms();
            tvMap.put(field, new TermFrequencyVector(terms, freqs));
          }
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.api.BoboIndexReader$WorkArea

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.