Package com.browseengine.bobo.api

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


   
    @Override
    public DocComparator getComparator(final IndexReader reader, int docbase)
        throws IOException {
      if (!(reader instanceof BoboIndexReader)) throw new IllegalStateException("reader must be instance of "+BoboIndexReader.class);
      BoboIndexReader boboReader = (BoboIndexReader)reader;
      final MultiValueFacetDataCache dataCache = _facetHandler.getFacetData(boboReader);
      return new DocComparator(){
       
        @Override
        public int compare(ScoreDoc doc1, ScoreDoc doc2) {
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

    {

      SolrIndexSearcher searcher=rb.req.getSearcher();
     
      SolrIndexReader solrReader = searcher.getReader();
      BoboIndexReader reader = (BoboIndexReader)solrReader.getWrappedReader();
     
      if (reader instanceof BoboIndexReader){
          try {
            List<Query> filters = rb.getFilters();
            if (filters!=null){
              final ArrayList<DocIdSet> docsets = new ArrayList<DocIdSet>(filters.size());
                for (Query filter : filters){
                  Weight weight = filter.createWeight(rb.req.getSearcher());
                  final Scorer scorer = weight.scorer(reader, false, true);
                  docsets.add(new DocIdSet(){
                @Override
                public DocIdSetIterator iterator() throws IOException {
                  return scorer;
                }
                   
                  });
                }
               
                if (docsets.size()>0){
                  br.setFilter(
                    new Filter(){
                @Override
                public DocIdSet getDocIdSet(IndexReader reader)
                    throws IOException {
                  return new AndDocIdSet(docsets);
                }
                  });
                }
            }
             
            Set<String> facetNames = reader.getFacetNames();
            Set<String> returnFields = rb.rsp.getReturnFields();
            Set<String> storedFields = new HashSet<String>();
            if (returnFields!=null){
              for (String fld : returnFields){
              if (!facetNames.contains(fld)){
View Full Code Here

  @Override
  public IndexReader newReader(Directory indexDir, boolean readOnly)
      throws IOException {
    IndexReader reader=IndexReader.open(indexDir,null,readOnly,termInfosIndexDivisor);
    BoboIndexReader boboReader=null;
    try{
      WorkArea workArea = new WorkArea();
      workArea.put(getClass().getClassLoader());
      boboReader=BoboIndexReader.getInstance(reader,workArea);
      return boboReader;
View Full Code Here

    if (mapper == null) return;
    int docId = mapper.getDocID(uid);
    if (docId < 0) {
      return ;
    }
    BoboIndexReader decoratedReader = (BoboIndexReader) zoieSegmentReader.getDecoratedReader();
    for (String facet : facets) {
      Object facetData = decoratedReader.getFacetData(facet);
      if (!(facetData instanceof int[])) {
        logger.warn("The facet " + facet + " should have a facet data of type int[] but not " + facetData.getClass().toString());
        continue;
      }
      int[] indexes = (int[]) facetData;
View Full Code Here

    return new SenseiFilter(){

      @Override
      public SenseiDocIdSet getSenseiDocIdSet(IndexReader reader) throws IOException {
        if (reader instanceof BoboIndexReader){
          BoboIndexReader boboReader = (BoboIndexReader)reader;
          Iterator<String> iter = json.keys();
          List<SenseiFilter> senseiFilters = new ArrayList<SenseiFilter>();
          while(iter.hasNext()){
            String key = iter.next();
            FacetHandler facetHandler = boboReader.getFacetHandler(key);
            if (facetHandler!=null){
              try{
                JSONObject jsonObj = json.getJSONObject(key);
                BrowseSelection sel = buildFacetSelection(key, jsonObj);
                senseiFilters.add(SenseiFilter.build(facetHandler.buildFilter(sel), "FACET " + key));
View Full Code Here

        String fromPadded = from, toPadded = to;
        if (!noOptimize)
        {
          if (reader instanceof BoboIndexReader)
          {
            final BoboIndexReader boboReader = (BoboIndexReader)reader;
            FacetHandler facetHandler = boboReader.getFacetHandler(field);
            if (facetHandler != null)
            {
              StringBuilder sb = new StringBuilder();
              if (include_lower && from != null && from.length() != 0)
                sb.append("[");
View Full Code Here

    return new SenseiFilter(){

      @Override
      public SenseiDocIdSet getSenseiDocIdSet(IndexReader reader) throws IOException {
        if (reader instanceof BoboIndexReader) {
          BoboIndexReader boboReader = (BoboIndexReader)reader;
          FacetHandler uidHandler = boboReader.getFacetHandler(SenseiFacetHandlerBuilder.UID_FACET_NAME);
          if (uidHandler!=null && uidHandler instanceof UIDFacetHandler){
            UIDFacetHandler uidFacet = (UIDFacetHandler)uidHandler;
            try{
              String[] vals = RequestConverter2.getStrings(json.optJSONArray(VALUES_PARAM));
              String[] nots = RequestConverter2.getStrings(json.optJSONArray(EXCLUDES_PARAM));
View Full Code Here

      @Override
      public DocComparator getComparator(IndexReader reader, int docbase)
          throws IOException {
        final UIDFacetHandler uidFacetHandler = UIDFacetHandler.this;
        if (reader instanceof BoboIndexReader){
          BoboIndexReader boboReader = (BoboIndexReader)reader;
          final long[] uidArray = uidFacetHandler.getFacetData(boboReader);
          return new DocComparator() {
           
            @Override
            public Comparable value(ScoreDoc doc) {
View Full Code Here

  @Test
  public void testSenseiTermFilter() throws IOException {
    SenseiTermFilter orTermFilter =
        new SenseiTermFilter("column", vals, null, false, false);

    BoboIndexReader indexReader = createMock(BoboIndexReader.class);

    MultiValueFacetDataCache facetDataCache =
        new MultiValueFacetDataCache();
    facetDataCache.valArray = dictionary;
    facetDataCache.freqs = freqs;

    FacetHandler facetHandler =
        new MultiValueFacetHandler("column", 32);

    expect(indexReader.maxDoc()).andReturn(1000).anyTimes();
    expect(indexReader.getFacetHandler("column")).andReturn(facetHandler);
    expect(indexReader.getFacetData("column")).andReturn(facetDataCache).anyTimes();
    replay(indexReader);

    SenseiDocIdSet orDocIdSet = orTermFilter.getSenseiDocIdSet(indexReader);
    DocSetAssertions.assertRange(26, 72, 1000, orDocIdSet.getCardinalityEstimate());

    SenseiTermFilter andTermFilter =
        new SenseiTermFilter("column", vals, null, true, false);

    reset(indexReader);
    expect(indexReader.maxDoc()).andReturn(1000).anyTimes();
    expect(indexReader.getFacetHandler("column")).andReturn(facetHandler);
    expect(indexReader.getFacetData("column")).andReturn(facetDataCache).anyTimes();
    replay(indexReader);

    SenseiDocIdSet andDocIdSet = andTermFilter.getSenseiDocIdSet(indexReader);
    DocSetAssertions.assertRange(0, 22, 1000, andDocIdSet.getCardinalityEstimate());
  }
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.