예제 #1
0
  private GeoSegmentInfo buildGeoSegmentInfo(Set<String> fieldNames, String segmentName)
      throws IOException {
    // write version
    GeoSegmentInfo info = new GeoSegmentInfo();
    info.setGeoVersion(GeoVersion.CURRENT_VERSION);

    info.setSegmentName(segmentName);

    // now write field -> filterByte mapping info
    IFieldNameFilterConverter fieldNameFilterConverter =
        geoConverter.makeFieldNameFilterConverter();
    if (fieldNameFilterConverter != null) {
      info.setFieldNameFilterConverter(fieldNameFilterConverter);
    }

    return info;
  }
예제 #2
0
  private GeoSegmentInfo buildGeoSegmentInfo(String segmentName) throws IOException {
    IGeoConverter converter = config.getGeoConverter();

    // write version
    GeoSegmentInfo info = new GeoSegmentInfo();
    info.setGeoVersion(GeoVersion.CURRENT_GEOONLY_VERSION);

    info.setSegmentName(segmentName);

    info.setBytesPerRecord(IDGeoRecordSerializer.INTERLACE_BYTES + config.getBytesForId());

    // now write field -> filterByte mapping info
    IFieldNameFilterConverter fieldNameFilterConverter = converter.makeFieldNameFilterConverter();
    if (fieldNameFilterConverter != null) {
      info.setFieldNameFilterConverter(fieldNameFilterConverter);
    }

    return info;
  }
예제 #3
0
  @Override
  public void index(int docID, GeoCoordinateField field) {
    String fieldName = field.name();
    GeoCoordinate coordinate = field.getGeoCoordinate();

    LatitudeLongitudeDocId longLatDocId =
        new LatitudeLongitudeDocId(coordinate.getLatitude(), coordinate.getLongitude(), docID);

    IFieldNameFilterConverter fieldNameFilterConverter =
        geoConverter.makeFieldNameFilterConverter();
    CartesianGeoRecord geoRecord =
        geoConverter.toCartesianGeoRecord(fieldNameFilterConverter, fieldName, longLatDocId);

    // For now, we need to synchronize this since we can only safely have one thread at a
    // time adding an item to a treeset.  One alternative strategy is to add geoRecords to
    // an object with better concurrency while indexing and then sort using the TreeSet on
    // flush
    synchronized (treeLock) {
      fieldTree.add(geoRecord);
      fieldNames.add(fieldName);
    }

    return;
  }