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

Fix endianness in array of float/double #11

Merged
merged 2 commits into from
Sep 15, 2014
Merged

Conversation

davies
Copy link
Contributor

@davies davies commented Sep 11, 2014

PickleUtils.bytes_to_double() and PickleUtils.bytes_to_float() assume that the bytes is in big endian order, so it should reverse the bytes only when machine code is little endian order.

The serialized result of array of float/double used in unit tests is reversed, they had been corrected in this patch.

@davies
Copy link
Contributor Author

davies commented Sep 13, 2014

@irmen Is it possible to have an bugfix release soon?

@irmen
Copy link
Owner

irmen commented Sep 14, 2014

Haven't had the ability yet to verify this issue. What platform are you running on that gave you problems?

@davies
Copy link
Contributor Author

davies commented Sep 15, 2014

In Mac OS X 10.9, Python 3.4, The array('f', [16711938.0]) is pickled with little endian, it cannot be unpickled by Pyrolite.

>>> struct.pack('<f', 16711938.0)
b'\x02\x01\x7fK'
>>> struct.pack('f', 16711938.0)
b'\x02\x01\x7fK'
>>> struct.pack('f', 16711938.0) in pickle.dumps(array.array('f',[16711938.0]))
True

irmen added a commit that referenced this pull request Sep 15, 2014
Fix endianness in array of float/double
@irmen irmen merged commit 36a5530 into irmen:master Sep 15, 2014
@irmen
Copy link
Owner

irmen commented Sep 15, 2014

Thanks for the pull request

guavuslabs-builder pushed a commit to ThalesGroup/spark that referenced this pull request Sep 16, 2014
Pyrolite can not unpickle array.array which pickled by Python 2.6, this patch fix it by extend Pyrolite.

There is a bug in Pyrolite when unpickle array of float/double, this patch workaround it by reverse the endianness for float/double. This workaround should be removed after Pyrolite have a new release to fix this issue.

I had send an PR to Pyrolite to fix it:  irmen/Pyrolite#11

Author: Davies Liu <davies.liu@gmail.com>

Closes apache#2365 from davies/pickle and squashes the following commits:

f44f771 [Davies Liu] enable tests about array
3908f5c [Davies Liu] Merge branch 'master' into pickle
c77c87b [Davies Liu] cleanup debugging code
60e4e2f [Davies Liu] support unpickle array.array for Python 2.6
davies added a commit to davies/spark that referenced this pull request Dec 10, 2014
Pyrolite can not unpickle array.array which pickled by Python 2.6, this patch fix it by extend Pyrolite.

There is a bug in Pyrolite when unpickle array of float/double, this patch workaround it by reverse the endianness for float/double. This workaround should be removed after Pyrolite have a new release to fix this issue.

I had send an PR to Pyrolite to fix it:  irmen/Pyrolite#11

Author: Davies Liu <davies.liu@gmail.com>

Closes apache#2365 from davies/pickle and squashes the following commits:

f44f771 [Davies Liu] enable tests about array
3908f5c [Davies Liu] Merge branch 'master' into pickle
c77c87b [Davies Liu] cleanup debugging code
60e4e2f [Davies Liu] support unpickle array.array for Python 2.6

Conflicts:
	core/src/main/scala/org/apache/spark/api/python/SerDeUtil.scala
	python/pyspark/tests.py
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