Ejemplo n.º 1
0
  @Override
  public void flush(Directory directory, String segmentName) throws IOException {
    Set<CartesianGeoRecord> treeToFlush;
    Set<String> fieldNamesToFlush;
    synchronized (treeLock) {
      fieldNamesToFlush = fieldNames;
      fieldNames = new HashSet<String>();

      treeToFlush = fieldTree;
      fieldTree = geoUtil.getBinaryTreeOrderedByBitMag();
    }

    GeoSegmentWriter<CartesianGeoRecord> geoRecordBTree = null;

    GeoSegmentInfo geoSegmentInfo = buildGeoSegmentInfo(fieldNamesToFlush, segmentName);

    boolean success = false;
    try {
      String fileName = config.getGeoFileName(segmentName);
      geoRecordBTree =
          new GeoSegmentWriter<CartesianGeoRecord>(
              treeToFlush, directory, fileName, geoSegmentInfo, geoRecordSerializer);

      success = true;
    } finally {
      // see https://issues.apache.org/jira/browse/LUCENE-3405
      if (success) {
        IOUtils.close(geoRecordBTree);
      } else {
        IOUtils.closeWhileHandlingException(geoRecordBTree);
      }
    }
  }
Ejemplo n.º 2
0
  public GeoIndexer(GeoSearchConfig config) {
    geoUtil = config.getGeoUtil();
    geoConverter = config.getGeoConverter();
    fieldTree = geoUtil.getBinaryTreeOrderedByBitMag();
    geoRecordSerializer = new CartesianGeoRecordSerializer();

    this.config = config;
  }