-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Remove the 'array value parser' marker interface. #57571
Conversation
Pinging @elastic/es-search (:Search/Mapping) |
This PR replaces the marker interface with the method FieldMapper#parsesArrayValue. I find this cleaner and it will help with the fields retrieval work (elastic#55363). The refactor also ensures that only field mappers can declare they parse array values. Previously other types like ObjectMapper could implement the marker interface and be passed array values, which doesn't make sense.
4b2dfdb
to
2932918
Compare
@@ -562,6 +562,10 @@ private static void parseArray(ParseContext context, ObjectMapper parentMapper, | |||
} | |||
} | |||
|
|||
private static boolean parsesArrayValue(Mapper mapper) { | |||
return mapper instanceof FieldMapper && ((FieldMapper) mapper).parsesArrayValue(); |
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.
Unfortunately this refactor didn't actually cut down on the number of instanceof
checks. But I feel better about this one, because it's very common for us to check instanceof
against FieldMapper
or ObjectMapper
-- it's just part of how mappings + document parsing currently work.
I think I'd prefer the method on Mapper. Or *something* with tighter typing
to avoid the instanceof FieldMapper bit. I dunno. I feel like adding an
instanceof to remove and instanceof might be a sign of something bad.
…On Tue, Jun 2, 2020, 19:48 Julie Tibshirani ***@***.***> wrote:
@jtibshirani <https://github.com/jtibshirani> requested your review on:
#57571 <#57571> Remove the
'array value parser' marker interface..
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#57571 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABUXIUSQE7YD55G4OEQVWTRUWFTFANCNFSM4NRFM2YQ>
.
|
And our comments crossed, like ships in the night.
Is there anything we can do to cut down on the instanceof ObjectMapper vs
FieldMapper? Like, in a follow up?
…On Tue, Jun 2, 2020, 20:00 Nikolas Everett ***@***.***> wrote:
I think I'd prefer the method on Mapper. Or *something* with tighter
typing to avoid the instanceof FieldMapper bit. I dunno. I feel like adding
an instanceof to remove and instanceof might be a sign of something bad.
On Tue, Jun 2, 2020, 19:48 Julie Tibshirani ***@***.***>
wrote:
> @jtibshirani <https://github.com/jtibshirani> requested your review on:
> #57571 <#57571> Remove the
> 'array value parser' marker interface..
>
> —
> You are receiving this because your review was requested.
> Reply to this email directly, view it on GitHub
> <#57571 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABUXIUSQE7YD55G4OEQVWTRUWFTFANCNFSM4NRFM2YQ>
> .
>
|
We could put the method on
I will give this some thought -- I'll likely file an issue about it so we don't forget. I see it as a worthwhile but bigger and separate refactor from this one. |
@elasticmachine run elasticsearch-ci/1 |
👍 |
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.
Given that we have this instanceof
all the time, I'm ok with it. Its better than a marker interface!
Sometimes I have to take deep breaths and remind myself not to let the perfect be the enemy of the good.
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.
Small comment but otherwise LGTM
@@ -173,6 +172,11 @@ public DenseVectorFieldType fieldType() { | |||
return (DenseVectorFieldType) super.fieldType(); | |||
} | |||
|
|||
@Override | |||
public boolean parsesArrayValue() { |
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.
Should this be final, like AbstractGeometryFieldMapper does?
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.
To me this could be a bit confusing, because no other methods on DenseVectorFieldType
are final and it wasn't designed for extension.
I also found this refactor to be disappointing on its own. But I think we're slowly pushing the document parsing + field mapper code in a good direction. |
Thank you both for the review ! |
This PR replaces the marker interface with the method FieldMapper#parsesArrayValue. I find this cleaner and it will help with the fields retrieval work (elastic#55363). The refactor also ensures that only field mappers can declare they parse array values. Previously other types like ObjectMapper could implement the marker interface and be passed array values, which doesn't make sense.
This PR replaces the marker interface with the method FieldMapper#parsesArrayValue. I find this cleaner and it will help with the fields retrieval work (elastic#55363). The refactor also ensures that only field mappers can declare they parse array values. Previously other types like ObjectMapper could implement the marker interface and be passed array values, which doesn't make sense.
This PR replaces the marker interface with the method FieldMapper#parsesArrayValue. I find this cleaner and it will help with the fields retrieval work (#55363). The refactor also ensures that only field mappers can declare they parse array values. Previously other types like ObjectMapper could implement the marker interface and be passed array values, which doesn't make sense.
This PR replaces the marker interface with the method FieldMapper#parsesArrayValue. I find this cleaner and it will help with the fields retrieval work (#55363). The refactor also ensures that only field mappers can declare they parse array values. Previously other types like ObjectMapper could implement the marker interface and be passed array values, which doesn't make sense.
This PR replaces the marker interface with the method
FieldMapper#parsesArrayValue
. I find this cleaner and it will help cut downon
instanceof
checks in the fields retrieval work (#55363).The refactor also ensures that only field mappers can declare they parse array
values. Previously other types like
ObjectMapper
could implement the markerinterface and be passed array values, which doesn't make sense.