Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  
  package com.browseengine.bobo.geosearch.index.impl;
  
  import java.util.List;
 
 

Author(s):
Shane Detsch
Ken McCracken
Geoff Cooney
 
 public class GeoIndexReader extends FilterIndexReader {
     
     private static final int DEFAULT_BUFFER_SIZE_PER_SEGMENT = 16*1024;
     
     
     private List<GeoIndexReadersubGeoReaders;
     
     
     public GeoIndexReader(Directory directoryGeoSearchConfig geoSearchConfigthrows IOException {
         super(initReader(directorygeoSearchConfig));
 
         
         if ( == null) {
              = buildSubReaders();
         }
         
         for (GeoIndexReader subGeoReader) {
             subGeoReader.setGeoSearchConfig(geoSearchConfig);
         }
         
          = buildGeoSegmentReaders(geoSearchConfig);
         
     }
     
     private GeoIndexReader(IndexReader reader) {
         super(reader);
         
         
         if ( == null) {
              = buildSubReaders();
         }
     }
     
     private void setGeoSearchConfig(GeoSearchConfig geoSearchConfigthrows IOException {
         for (GeoIndexReader subGeoReader) {
             subGeoReader.setGeoSearchConfig(geoSearchConfig);
         }
         
         buildGeoSegmentReaders(geoSearchConfig);
     }
     
         IndexReader[] baseReaders = super.getSequentialSubReaders();
         
         int numReaders = baseReaders == null ? 0 : baseReaders.length;
         
         List<GeoIndexReadersubGeoReaders = new ArrayList<GeoIndexReader>(numReaders);
         for (int i = 0; i < numReadersi++) {
             GeoIndexReader subReader = new GeoIndexReader(baseReaders[i]);
             subGeoReaders.add(subReader);
         }
         
         return subGeoReaders;
     }
     
         if ( == null || .size() == 0) {
             if ( instanceof SegmentReader) {
                 SegmentReader segmentReader = (SegmentReader;
                 int maxDoc = segmentReader.maxDoc();
                 String segmentName = segmentReader.getSegmentName();
                 String geoSegmentName = geoSearchConfig.getGeoFileName(segmentName);
                 GeoSegmentReader<CartesianGeoRecordgeoSegmentReader = new GeoSegmentReader<CartesianGeoRecord>(
                         directory(), geoSegmentNamemaxDoc,
                        );
                .add(geoSegmentReader);
            } 
        } else {
            for (GeoIndexReader subReader : ) {
                for (GeoSegmentReader<CartesianGeoRecordgeoSegmentReader : subReader.getGeoSegmentReaders()) {
                    .add(geoSegmentReader);
                }
            }
        }
        
        return ;
    }
    
    private static IndexReader initReader(Directory directoryGeoSearchConfig geoSearchConfigthrows IOException {
        if (null == directory) {
            return null;
        }
        directory = GeoIndexWriter.buildGeoDirectory(directorygeoSearchConfig);
        IndexReader indexReader = IndexReader.open(directorytrue);
        return indexReader;
        
    }
    
        return ;
    }
    
    @Override
    public IndexReader[] getSequentialSubReaders() {
        
        if ( == null) {
             = buildSubReaders();
        }
        if (.size() == 0) {
            return null;
        }
        
        IndexReader[] subReaders = new IndexReader[.size()];
        for (int i = 0; i < subReaders.lengthi++) {
            subReaders[i] = .get(i);
        }
        
        return subReaders;
    }
    public List<GeoIndexReadergetSubGeoReaders() {
        return ;
    }
    public void setSubGeoReaders(List<GeoIndexReadersubGeoReaders) {
        this. = subGeoReaders;
    }
    public void setGeoSegmentReaders(List<GeoSegmentReader<CartesianGeoRecord>> geoSegmentReaders) {
        this. = geoSegmentReaders;
    }
New to GrepCode? Check out our FAQ X