Skip to content

Conversation

@craigtaverner
Copy link
Contributor

@craigtaverner craigtaverner commented Jul 12, 2022

Also refactoring testing infrastructure to make testing easier to share across different test classes.

Also refactoring testing infrastructure to make testing easier to share
across different test classes.
@craigtaverner craigtaverner added >enhancement :Analytics/Geo Indexing, search aggregations of geo points and shapes labels Jul 12, 2022
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 12, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @craigtaverner, I've created a changelog YAML for you.

Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not necessary in this PR? can we revert it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I can revert it. I wonder though, in what kind of PR would a tiny simplification like this be appropriate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just open a PR for it. If this optimization introduces a bug, it would be strange to be associated to this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public interface CoordinateEncoder {

CoordinateEncoder GEO = new GeoShapeCoordinateEncoder();
CoordinateEncoder Cartesian = new CartesianShapeCoordinateEncoder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Cartesian/CARTESIAN

for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e52ba26


protected abstract Component2D create(GEOMETRY geometry);

protected abstract Component2D create(GEOMETRY[] geometries);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is nice, do we need two methods? would not be enough with something like:

protected abstract Component2D create(GEOMETRY... geometry);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to extend ToXContentFragment here? I think we don't need any method from that interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some java docs?

});
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 1066e01

@Override
protected boolean supportsSearchLookup() {
// TODO: is this really true? We have failing tests, but they look like test issues not core issues
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this class in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

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.
Copy link
Contributor

@iverase iverase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iverase iverase merged commit 6797d44 into elastic:master Jul 14, 2022
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Jul 15, 2022
* 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
@craigtaverner craigtaverner deleted the cartesian_doc_values branch October 20, 2023 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Geo Indexing, search aggregations of geo points and shapes >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants