Skip to content
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

java api - multiple dimension arrays of shorts are casted to multiple dimension arrays of floats #7845

Closed
maximenay opened this issue Sep 23, 2014 · 3 comments

Comments

@maximenay
Copy link

commented Sep 23, 2014

Hi,

I believe there is a typo in org.elasticsearch.common.xcontent.XContentBuilder.java
https://github.com/elasticsearch/elasticsearch/blob/v1.3.2/src/main/java/org/elasticsearch/common/xcontent/XContentBuilder.java#L1224

I think
for (float v : (short[]) value) {
should be
for (short v : (short[]) value) {

For example, right now, if you try to insert a 2D array of shorts you end up with a 2D array of floats.

Thanks!

@maximenay maximenay changed the title java api - multiple dimension arrays of shorts are casted to multiple dimension arrays of float java api - multiple dimension arrays of shorts are casted to multiple dimension arrays of floats Sep 23, 2014

@clintongormley

This comment has been minimized.

Copy link
Member

commented Sep 29, 2014

@jpountz could you take a look please?

jpountz added a commit to jpountz/elasticsearch that referenced this issue Oct 8, 2014
Fix serialization of short[] arays.
short[] were mistakenly encoded as a float[]. This is not an issue for the
text-based xcontents that we have (yaml, json) since floats can represent any
short value and are serialized as strings. However, this will make the binary
xcontents serialize shorts as int instead of floats.

Close elastic#7845
@jpountz

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2014

I don't think this caused bugs since all short values can be represented as a float, but it's indeed wrong. I just opened a pull request: #8025

@maximenay

This comment has been minimized.

Copy link
Author

commented Oct 8, 2014

This is problematic when you get your data expecting a short and actually get a float. At least with the java API.

@jpountz jpountz closed this in ede60df Oct 9, 2014

jpountz added a commit that referenced this issue Oct 9, 2014
Fix serialization of short[] arays.
short[] were mistakenly encoded as a float[]. This is not an issue for the
text-based xcontents that we have (yaml, json) since floats can represent any
short value and are serialized as strings. However, this will make the binary
xcontents serialize shorts as int instead of floats.

Close #7845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.