Support cartesian shape with doc values#88487
Conversation
Also refactoring testing infrastructure to make testing easier to share across different test classes.
|
Pinging @elastic/es-analytics-geo (Team:Analytics) |
|
Hi @craigtaverner, I've created a changelog YAML for you. |
iverase
left a comment
There was a problem hiding this comment.
This is looking pretty solid, just left some small comments.
The most important thing to improve is the test coverage of the doc_value flag in ShapeFieldMapperTests, in particular making sure that set the flag to true, it generates doc_values and that the default value changes depending on the versions.
| boolean first = true; | ||
| for (E e : enums) { | ||
| if (first == false) buf.append(", "); | ||
| first = false; |
There was a problem hiding this comment.
I think this is not necessary in this PR? can we revert it?
There was a problem hiding this comment.
Sure I can revert it. I wonder though, in what kind of PR would a tiny simplification like this be appropriate?
There was a problem hiding this comment.
Just open a PR for it. If this optimization introduces a bug, it would be strange to be associated to this PR.
| public interface CoordinateEncoder { | ||
|
|
||
| CoordinateEncoder GEO = new GeoShapeCoordinateEncoder(); | ||
| CoordinateEncoder Cartesian = new CartesianShapeCoordinateEncoder(); |
There was a problem hiding this comment.
s/Cartesian/CARTESIAN
for consistency?
|
|
||
| protected abstract Component2D create(GEOMETRY geometry); | ||
|
|
||
| protected abstract Component2D create(GEOMETRY[] geometries); |
There was a problem hiding this comment.
this is nice, do we need two methods? would not be enough with something like:
protected abstract Component2D create(GEOMETRY... geometry);
There was a problem hiding this comment.
That is what I did originally, but it turns out varargs does not play with generics, so in the generic class you have to use the two methods to get the same effect.
There was a problem hiding this comment.
I think it is because with type erasure we cannot tell the difference between Object[] and Object (since Object[] is also an Object).
|
|
||
| /** Override if special cases, like dateline support, should be considered */ | ||
| protected boolean addSpecialCase(List<Component2D> components2D, GEOMETRY geometry) { | ||
| return false; |
There was a problem hiding this comment.
Not strong opinion but I wonder if we should change the API to somethng like:
protected abstract Component2D create(GEOMETRY... geometry);
protected abstract void add(List<Component2D> components2D, GEOMETRY geometry);
So we don't need this special case.
There was a problem hiding this comment.
Interesting approach. Is easier to read and reason about, so I've changed it to that, sort-of.
| * TODO: We could instead choose the point closer to the centroid which improves unbalanced trees | ||
| */ | ||
| public class LabelPositionVisitor implements TriangleTreeReader.Visitor { | ||
| public class LabelPositionVisitor<T extends ToXContentFragment> implements TriangleTreeReader.Visitor { |
There was a problem hiding this comment.
Do we need to extend ToXContentFragment here? I think we don't need any method from that interface.
There was a problem hiding this comment.
Agreed. I was just using a pattern I had used all over the place in the prototype, before moving to the common interface between GeoPoint and CartesianPoint. But in reality, many places (like this) don't care about the type at all, so I'll remove it.
|
|
||
| import java.util.List; | ||
|
|
||
| public interface ShapeIndexer { |
| }); | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
I am missing here explicit test for doc_values, like that they are generated when set the flag to true or that the default value is true in current version but. false in previous versions.
| @Override | ||
| protected boolean supportsSearchLookup() { | ||
| // TODO: is this really true? We have failing tests, but they look like test issues not core issues | ||
| return false; |
There was a problem hiding this comment.
It seems that this was not needed before because we did not have doc values so it was equivalent to set this to false. Now we need to do it explicitly.
| * | ||
| * There is just one value for one document. | ||
| */ | ||
| public abstract class ShapeValues<T extends ToXContentFragment> { |
There was a problem hiding this comment.
Do we need this class in this PR?
There was a problem hiding this comment.
Good catch, indeed. I originally pulled in some of the other generic refactoring from the prototype, realised I did not need it and reverted the classes that extend this class, but forgot to remove this class itself!
Because we plan to support points separately.
…icsearch into cartesian_doc_values
I originally pulled in some of the other generic refactoring from the prototype, realised I did not need it and reverted the classes that extend this class, but forgot to remove this class itself!
No longer relevant
There were 16 tests shared between the geo and cartesian tests. These are moved into a base class. The reordering of dependencies required that we move 3 common dateline tests into a utility class.
* upstream/master: (2974 commits) Reserved cluster state service (elastic#88527) Add transport action immutable state checks (elastic#88491) Remove suggest flag from index stats docs (elastic#85479) Polling cluster formation state for master-is-stable health indicator (elastic#88397) Add test execution guide in yamlRestTest asciidoc (elastic#88490) Add troubleshooting guide for corrupt repository (elastic#88391) [Transform] Finetune Schedule to be less noisy on retry and retry slower (elastic#88531) Updatable API keys - auto-update legacy RDs (elastic#88514) Fix typo in TransportForceMergeAction and TransportClearIndicesCacheA… (elastic#88064) Fixed NullPointerException on bulk request (elastic#88358) Avoid needless index metadata builders during reroute (elastic#88506) Set metadata on request in API key noop test (elastic#88507) Fix passing positional args to ES in Docker (elastic#88502) Improve description for task api detailed param (elastic#88493) Support cartesian shape with doc values (elastic#88487) Promote usage of Subjects in Authentication class (elastic#88494) Add CCx 2.0 feature flag (elastic#88451) Reword the watcher 'always' and 'never' condition docs (elastic#86105) Simplify azure discovery installation docs (elastic#88404) Breakup FIPS CI testing jobs ... # Conflicts: # server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java # x-pack/plugin/mapper-aggregate-metric/src/main/java/org/elasticsearch/xpack/aggregatemetric/mapper/AggregateDoubleMetricFieldMapper.java
Also refactoring testing infrastructure to make testing easier to share across different test classes.