Пример #1
0
  /**
   * Adds a record to the geo only index
   *
   * @param uuid
   * @param field
   */
  public void index(byte[] uuid, GeoCoordinateField field) {
    if (uuid.length != config.getBytesForId()) {
      throw new IllegalArgumentException(
          "invalid uuid length: "
              + uuid.length
              + ".  Expected uuid to be of length "
              + config.getBytesForId()
              + ".");
    }

    IGeoConverter converter = config.getGeoConverter();

    GeoCoordinate geoCoordinate = field.getGeoCoordinate();
    IDGeoRecord geoRecord =
        converter.toIDGeoRecord(geoCoordinate.getLatitude(), geoCoordinate.getLongitude(), uuid);
    newRecords.add(geoRecord);
  }
Пример #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;
  }
Пример #4
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;
  }