mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Refactor GeoPoint and GeoShape with generics (#89388)
* Refactor GeoPoint and GeoShape with generics
In preparation for supporting CartesianPoint and CartesianShape
in aggregations, this PR adds a common interface between GeoPoint
and CartesianPoint, and then uses that to split out some key common
code that will be used in CartesianPoint and CartesianShape aggregations
* Simplify generics (by Ignacio)
Co-authored-by: Ignacio Vera <ivera@apache.org>
* Refactor ElasticPoint to SpatialPoint
* Rename ShapeValuesProvider to ShapeValuesSource
It extends ValuesSource, and is extended by GeoShapeValuesSource.
There is no reason for the suffix `Provider`.
* Code review, mostly AbstractShapeIndexFieldData
* Reverted trivial refactoring
* Removed unused Writable interface implementation
* Further generics refinements
Based on Ignacio's work in 050df953df
,
we fix the BoundingBox generics, and also add a little more specificity
to the previous generics (replace <?> with <? extends SpatialPoint>).
* Removed some geo-specific code from BoundingBox
Co-authored-by: Ignacio Vera <ivera@apache.org>
This commit is contained in:
parent
97f0e98c3a
commit
b68d62ba1e
83 changed files with 2148 additions and 1496 deletions
|
@ -11,8 +11,8 @@ package org.elasticsearch.script.expression;
|
|||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.DoubleValues;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.LeafGeoPointFieldData;
|
||||
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
|
||||
import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -28,7 +28,7 @@ final class GeoEmptyValueSource extends FieldDataBasedDoubleValuesSource {
|
|||
@Override
|
||||
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
|
||||
LeafGeoPointFieldData leafData = (LeafGeoPointFieldData) fieldData.load(leaf);
|
||||
final MultiGeoPointValues values = leafData.getGeoPointValues();
|
||||
final MultiGeoPointValues values = leafData.getPointValues(); // shade
|
||||
return new DoubleValues() {
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
|
|
|
@ -11,8 +11,8 @@ package org.elasticsearch.script.expression;
|
|||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.DoubleValues;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.LeafGeoPointFieldData;
|
||||
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
|
||||
import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -28,7 +28,7 @@ final class GeoLatitudeValueSource extends FieldDataBasedDoubleValuesSource {
|
|||
@Override
|
||||
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
|
||||
LeafGeoPointFieldData leafData = (LeafGeoPointFieldData) fieldData.load(leaf);
|
||||
final MultiGeoPointValues values = leafData.getGeoPointValues();
|
||||
final MultiGeoPointValues values = leafData.getPointValues();
|
||||
return new DoubleValues() {
|
||||
@Override
|
||||
public double doubleValue() throws IOException {
|
||||
|
|
|
@ -11,8 +11,8 @@ package org.elasticsearch.script.expression;
|
|||
import org.apache.lucene.index.LeafReaderContext;
|
||||
import org.apache.lucene.search.DoubleValues;
|
||||
import org.elasticsearch.index.fielddata.IndexFieldData;
|
||||
import org.elasticsearch.index.fielddata.LeafGeoPointFieldData;
|
||||
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
|
||||
import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -28,7 +28,7 @@ final class GeoLongitudeValueSource extends FieldDataBasedDoubleValuesSource {
|
|||
@Override
|
||||
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
|
||||
LeafGeoPointFieldData leafData = (LeafGeoPointFieldData) fieldData.load(leaf);
|
||||
final MultiGeoPointValues values = leafData.getGeoPointValues();
|
||||
final MultiGeoPointValues values = leafData.getPointValues();
|
||||
return new DoubleValues() {
|
||||
@Override
|
||||
public double doubleValue() throws IOException {
|
||||
|
@ -53,8 +53,7 @@ final class GeoLongitudeValueSource extends FieldDataBasedDoubleValuesSource {
|
|||
if (obj == null) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
GeoLongitudeValueSource other = (GeoLongitudeValueSource) obj;
|
||||
if (fieldData.equals(other.fieldData) == false) return false;
|
||||
return true;
|
||||
return fieldData.equals(other.fieldData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue