This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
Add support for union, binary fields, and empty structs #14
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`unions` are just loaded up as `structs` for now. In the future we might want to modify `_compat.init_func_generator` to enforce the restriction that you are only supposed to set one of the fields of a union. `binary` fields are just special cases of `string`, so when receiving `string` fields in the binary protocol, we try to decode as `utf-8` first, but if that fails we just return the bytes. There were a few places where the grammar had `OneOrMore` instead of `ZeroOrMore`, which prevented declaring empty structs. I've fixed that.
This is supposed to address #13. |
Alright, now I've added unit tests that use the Storm thrift file and make sure we can load empty structs, unions, things with semicolons, and the I'm only seeing one unit test failure and that's with |
Actually, I guess that pypy failure was just a onetime fluke. Everything passes now. |
lxyu
added a commit
that referenced
this pull request
Jun 18, 2014
Add support for union, binary fields, and empty structs
Thank you very much for your excellent PR! |
Thank you for making a nicer version of |
lxyu
added a commit
that referenced
this pull request
Jun 18, 2014
The cybinary protocol uses local cdef TTypes, which was missed in #14
FYI, I just did a v0.1.3 release. You may use pypi for convenient installation now. |
Awesome. Thanks! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for unions, binary fields, empty structs, and semicolons at the ends of lines within structs, with the goal of allowing someone to load the Apache Storm thrift file.
Some notes about implementation:
unions
are just loaded up asstructs
for now. In the future we might want to modify_compat.init_func_generator
to enforce the restriction that you are only supposed to set one of the fields of a union.binary
fields are just special cases ofstring
, so when receivingstring
fields in the binary protocol, we try to decode asutf-8
first, but if that fails we just return the bytes.OneOrMore
instead ofZeroOrMore
, which prevented declaring empty structs. I've fixed that.I'll finish adding the test data tomorrow; I just wanted to trigger a travis build to make sure everything was working so far.