Package com.browseengine.bobo.api

Examples of com.browseengine.bobo.api.MultiBoboBrowser$BrowseFacetValueComparator


  }

  public static Browsable buildBrowsableFromBoboReaders(
      List<BoboIndexReader> readerList) throws IOException {
    Browsable[] subBrowsers = BoboBrowser.createBrowsables(readerList);
    return new MultiBoboBrowser(subBrowsers);
  }
View Full Code Here


      for (BoboIndexReader boboReader : boboReaders){
        subBrowsableList.add(new BoboBrowser(boboReader));
      }
    }
   
    MultiBoboBrowser multiBrowser = new MultiBoboBrowser(subBrowsableList.toArray(new Browsable[subBrowsableList.size()]));
   
    return multiBrowser;
  }
View Full Code Here

   
    return multiBrowser;
  }
 
  public BrowseResult browse(BrowseRequest req) throws BrowseException {
    MultiBoboBrowser browsable = null;
    List<ZoieIndexReader<BoboIndexReader>> readerList = null;
    try
    {
      readerList = _indexReaderFactory.getIndexReaders();
      browsable = new MultiBoboBrowser(BoboBrowser.createBrowsables(ZoieIndexReader.extractDecoratedReaders(readerList)));
     
      BrowseResult res = browsable.browse(req);
     
      BrowseResult serializableResult = new BrowseResult();
      serializableResult.setHits(res.getHits());
      serializableResult.setNumHits(res.getNumHits());
      serializableResult.setTotalDocs(res.getTotalDocs());
      serializableResult.setTime(res.getTime());
     
      Map<String,FacetAccessible> facetMap = res.getFacetMap();
      Set<Entry<String,FacetAccessible>> entries = facetMap.entrySet();
      for (Entry<String,FacetAccessible> entry : entries)
      {
        List<BrowseFacet> facets = entry.getValue().getFacets();
        SerializedFacetAccessible facetAccessible = new SerializedFacetAccessible(facets);
        serializableResult.addFacets(entry.getKey(), facetAccessible);
      }
      return serializableResult;
    }
    catch(IOException ioe)
    {
      throw new BrowseException(ioe.getMessage(),ioe);
    }
    finally{
      try{
        if (browsable!=null){
        browsable.close();
        }
      }
      catch(Exception e){
        log.error(e.getMessage(),e);
      }
View Full Code Here

     
      BoboBrowser boboBrowser = newBrowser();
     
      browseRequest.setSort(new SortField[]{new SortField("compactnum",SortField.CUSTOM,true)});
     
      MultiBoboBrowser multiBoboBrowser = new MultiBoboBrowser(new Browsable[] {boboBrowser, boboBrowser});
      BrowseResult mergedResult = multiBoboBrowser.browse(browseRequest);
     
      HashMap<String,List<BrowseFacet>> answer=new HashMap<String,List<BrowseFacet>>();
      answer.put("color", Arrays.asList(new BrowseFacet[]{new BrowseFacet("red",4),new BrowseFacet("green",2)}));
      answer.put("tag", Arrays.asList(new BrowseFacet[]{new BrowseFacet("animal",2),new BrowseFacet("dog",2),new BrowseFacet("humane",2),new BrowseFacet("pet",2),new BrowseFacet("rabbit",4)}));
      answer.put("shape", Arrays.asList(new BrowseFacet[]{new BrowseFacet("square",4)}));
      answer.put("date",  Arrays.asList(new BrowseFacet[]{new BrowseFacet("[2000/01/01 TO 2003/05/05]", 2)}));
     
      doTest(mergedResult, browseRequest, 4, answer, new String[]{"7","7","1","1"});
     
      browseRequest.setSort(new SortField[]{new SortField("multinum",SortField.CUSTOM,true)});
      mergedResult = multiBoboBrowser.browse(browseRequest);
      doTest(mergedResult, browseRequest, 4, answer, new String[]{"7","7","1","1"});
      mergedResult.close();
      multiBoboBrowser.close();
  }
View Full Code Here

    BoboBrowser boboBrowser = newBrowser();

    browseRequest
        .setSort(new SortField[] { new SortField("compactnum", SortField.Type.CUSTOM, true) });

    MultiBoboBrowser multiBoboBrowser = new MultiBoboBrowser(new Browsable[] { boboBrowser,
        boboBrowser });
    BrowseResult mergedResult = multiBoboBrowser.browse(browseRequest);

    HashMap<String, List<BrowseFacet>> answer = new HashMap<String, List<BrowseFacet>>();
    answer.put("color",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("red", 4), new BrowseFacet("green", 2) }));
    answer.put(
      "tag",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("animal", 2), new BrowseFacet("dog", 2),
          new BrowseFacet("humane", 2), new BrowseFacet("pet", 2), new BrowseFacet("rabbit", 4) }));
    answer.put("shape", Arrays.asList(new BrowseFacet[] { new BrowseFacet("square", 4) }));
    answer.put("date",
      Arrays.asList(new BrowseFacet[] { new BrowseFacet("[2000/01/01 TO 2003/05/05]", 2) }));

    doTest(mergedResult, browseRequest, 4, answer, new String[] { "7", "7", "1", "1" });

    browseRequest
        .setSort(new SortField[] { new SortField("multinum", SortField.Type.CUSTOM, true) });
    mergedResult = multiBoboBrowser.browse(browseRequest);
    doTest(mergedResult, browseRequest, 4, answer, new String[] { "7", "7", "1", "1" });
    mergedResult.close();
    multiBoboBrowser.close();
  }
View Full Code Here

    }
 
  @Override
  public SenseiResult handlePartitionedRequest(final SenseiRequest request,
      List<BoboIndexReader> readerList,SenseiQueryBuilderFactory queryBuilderFactory) throws Exception {
      MultiBoboBrowser browser = null;

      try
      {
          final List<BoboIndexReader> segmentReaders = BoboBrowser.gatherSubReaders(readerList);
          if (segmentReaders!=null && segmentReaders.size() > 0) {
            final AtomicInteger skipDocs = new AtomicInteger(0);

            final SenseiIndexPruner pruner = _core.getIndexPruner();

            List<BoboIndexReader> validatedSegmentReaders = _timerMetric.time(new Callable<List<BoboIndexReader>>(){

               @Override
               public List<BoboIndexReader> call() throws Exception {
                  IndexReaderSelector readerSelector = pruner.getReaderSelector(request);
                  List<BoboIndexReader> validatedReaders = new ArrayList<BoboIndexReader>(segmentReaders.size());
                  for (BoboIndexReader segmentReader : segmentReaders){
                    if (readerSelector.isSelected(segmentReader)){
                      validatedReaders.add(segmentReader);
                    }
                    else{
                      skipDocs.addAndGet(segmentReader.numDocs());
                    }
                  }
                  return validatedReaders;
                }

            });

            pruner.sort(validatedSegmentReaders);

            browser = new MultiBoboBrowser(BoboBrowser.createBrowsables(validatedSegmentReaders));
            request.setSearchable(browser);
            request.setQueryBuilderFactory(queryBuilderFactory);
            BrowseRequest breq = RequestConverter.convert(request, queryBuilderFactory);
            if (request.getMapReduceFunction() != null) {
              SenseiMapFunctionWrapper mapWrapper = new SenseiMapFunctionWrapper(request.getMapReduceFunction(), _core.getSystemInfo().getFacetInfos());
              breq.setMapReduceWrapper(mapWrapper);
            }
            SubReaderAccessor<BoboIndexReader> subReaderAccessor =
                ZoieIndexReader.getSubReaderAccessor(validatedSegmentReaders);
            SenseiResult res = browse(request, browser, breq, subReaderAccessor);
            int totalDocs = res.getTotalDocs()+skipDocs.get();
            res.setTotalDocs(totalDocs);

            // For debugging serialization issues:
//            byte[] responseBytes = getSerializer().responseToBytes(res);
//            SenseiResult response2 = getSerializer().responseFromBytes(responseBytes);
//            if(!res.equals(response2)) {
//              throw new IllegalArgumentException("Cant serialize response");
//            }

            return res;
          }
          else{
            return new SenseiResult();
          }
      } catch (Exception e)
      {
        logger.error(e.getMessage(), e);
        throw e;
      } finally
      {
        if (browser != null)
        {
          try
          {
            browser.close();
          } catch (IOException ioe)
          {
            logger.error(ioe.getMessage(), ioe);
          }
        }
View Full Code Here

  @Override
  public SenseiSystemInfo handlePartitionedRequest(SenseiRequest request,
      List<BoboIndexReader> readerList,SenseiQueryBuilderFactory queryBuilderFactory) throws Exception {
    SenseiSystemInfo res = new SenseiSystemInfo();

    MultiBoboBrowser browser = null;
    try
    {
      browser = new MultiBoboBrowser(BoboBrowser.createBrowsables(readerList));
      res.setNumDocs(browser.numDocs());

      return res;
    }
    catch (Exception e)
    {
      logger.error(e.getMessage(), e);
      throw e;
    }
    finally
    {
      if (browser != null)
      {
        try
        {
          browser.close();
        } catch (IOException ioe)
        {
          logger.error(ioe.getMessage(), ioe);
        }
      }
View Full Code Here

TOP

Related Classes of com.browseengine.bobo.api.MultiBoboBrowser$BrowseFacetValueComparator

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.