New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GEOT-7245] ReTypingFeatureIterator should't demand equality among AttributeDescriptors #4073
Conversation
…tributeDescriptors
@jodygarnett this PR seems to be up to alley, could you have a look? |
I actually wonder why the request is being made; the point of retyping feature iterator is to test for equality so that the final output matches exactly what is requested.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to understand your requirement / motivation more clearly?
I provided a small request to capture the relationship you wish to use as a method so it can be documented and tested.
if (origAttrib == null | ||
|| !attrib.getType() | ||
.getBinding() | ||
.isAssignableFrom(origAttrib.getType().getBinding())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears considerably more relaxed.
-
Q: What is AttributeDescriptor equals checking that is causing a problem?
-
Q: If you wish to establish a different relationship "covers" I would be more comfortable if you added it to the one of the utilities class (like FeatureTypes.java so it can have a clear javadoc and test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is more relaxed, but it doesn't alter the original usage. If those SimpleFeatureType's are equal. They can still use this class. My change just makes it more useful for other situations.
Q: What is AttributeDescriptor equals checking that is causing a problem?
The test I included describes this. There is an inconsistency within AttributeDescriptor, that makes AttributeType.getName() either having the name of the descriptor or the name of the type. Both being as much useful for a retyping of the values.
SimpleFeatureType schema2 = stb2.buildFeatureType(); | ||
Assert.assertEquals("Integer", schema2.getDescriptor(0).getType().getName().getLocalPart()); | ||
SimpleFeatureCollection retyped = new ReTypingFeatureCollection(source, schema2); | ||
try (SimpleFeatureIterator features = retyped.features()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you have:
- schema original with attribute descriptor "bar" / of property type "bar" with java binding Integer
- schema test with attribute descriptor "bar" / of property type "Integer" with java binding Integer
So this PR is in effect seeking to ignore the property type; and just focus on if the descriptor name match?
I think what you are proposing would be new functionality; all the ReType methods are really about sub-setting an existing schema (so we can ignore properties that the user is not interested in as part of their query).
Aside: We do have the ability to transform features on the fly here: https://github.com/geotools/geotools/tree/main/modules/extension/transform/src/main/java/org/geotools/data/transform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually - I want it ... but it is a significant change that I think we need to go through the community proposal process.
They way I am thinking it is that:
-
retype: handles the common case where Query has been used to shuffle the order of the parameters around; or only select some of the parameters; and expects the java bindings to match. This would in effect be a "fast path" ...
-
covers: (can we think of a better name) relaxes this constraint so it just is based on descriptor name; and expects the java bindings to be assignable from (or even use a converter).
Options on how to engage:
- We could make a query hint to allow "relax=true", or "covers=true", or "strict=false"
- We could try ReType relationship (as a fast path); and if it is not suitable fall back to Covers relationship...
It seems like a useful idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point when you talk about a "fast path", but looking at the current code I would argue that we're not having a "fast path" at the moment. Within the "next" function there is a usage of SimpleFeatureBuilder, that in turn will call Converters.convert for all attributes of all the features.
I believe a "fast path" would do more like setting value directly from the original attribute into the new attribute. In such a case it would make perfect sense to demand equality among the AttributeType's. At the moment, I don't see the reason to demand this.
@roarbra the way this PR is evolving is worrying me... it looks like you're trying to do something that GeoTools was not designed for. Can you give us a bit of context into what practical problem you're trying to address? So far we have seen proposed solutions, but I think it would help to understand the problem they originate from. |
@aaime I've tried to recapture my original problem, and the reason to include this PR, but without success.
It would've been easier to realize this, if there was a constructor taking propertyNames as argument. Still I think that my PR makes this class more usable. |
I am glad you are not stuck; I like the idea of making an enum / config option so let me think about how to do this cleanly. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had recent activity. Please re-submit with updates if you want to resume work on this topic. Thank you for your contributions. |
Making the ReTypingFeatrueIterator more usable by reducing the limitations on attributes.
Fixes a problem where AttributeType names are different. Therefor is the test somewhat small.
Checklist
main
branch (backports managed later; ignore for branch specific issues).For core and extension modules:
[GEOT-XYZW] Title of the Jira ticket
.