예제 #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
  @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;
  }