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

Support all number types when decoding a point #3828

Merged
merged 5 commits into from
Aug 25, 2015

Conversation

corylanou
Copy link
Contributor

Fixes #3824

Also removes the legacy need to append a .0 to float types. This will improve performance and storage.

@corylanou
Copy link
Contributor Author

cc @jwilder

b = append(b, 'i')
case int64:
b = append(b, []byte(strconv.FormatInt(t, 10))...)
b = append(b, 'i')
case uint:
b = append(b, []byte(strconv.FormatUint(uint64(t), 10))...)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if there is a good way to handle this but when we parse things back, we use strconv.ParseInt. I believe we could parse back the wrong value if the uint is beyond the max int range. A good test to try would be to have a field type as a uint64 with a value of math.MaxUint64 and format as string and parse back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we check when we parse back if it starts with a -? If it does, it's ParseInt, if not, it's ParseUint. Would that work?

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 that would just cause a panic when the shard tries to write: https://github.com/influxdb/influxdb/blob/master/tsdb/shard.go#L509

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, so I think the right fix is to not support uint64. At this point that using the Go client library if you send a uint64 in, that it is going to get converted to a string. If you are using straight line protocol, this won't be an issue, as anything over int64 will fail one of our checks and error out.

/cc @jwilder @beckettsean

@jwilder
Copy link
Contributor

jwilder commented Aug 25, 2015

Since we don't store uints, should the signature for MarshalBinary be updated to return an error instead so we prevent some silent errors from happening? May have some rippling effects in the code though.

@jwilder
Copy link
Contributor

jwilder commented Aug 25, 2015

👍 On green build.

corylanou added a commit that referenced this pull request Aug 25, 2015
Support all number types when decoding a point
@corylanou corylanou merged commit afafe1d into master Aug 25, 2015
@corylanou corylanou deleted the support-all-numbers-in-points branch August 25, 2015 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants