-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from aerospike/data_conversion_documentation
Make documentation of python type to as_type more prominent
- Loading branch information
Showing
5 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.. _Data_Mapping: | ||
|
||
************************************************* | ||
:mod:`Data_Mapping` --- Python Data Mappings | ||
************************************************* | ||
|
||
.. rubric:: How Python types map to server types | ||
|
||
.. note:: | ||
|
||
By default, the :py:class:`aerospike.Client` maps the supported types \ | ||
:py:class:`int`, :py:class:`str`, :py:class:`float`, :py:class:`bytearray`, \ | ||
:py:class:`list`, :py:class:`dict` to matching aerospike server \ | ||
`types <http://www.aerospike.com/docs/guide/data-types.html>`_ \ | ||
(int, string, double, blob, list, map). When an unsupported type is \ | ||
encountered, the module uses \ | ||
`cPickle <https://docs.python.org/2/library/pickle.html?highlight=cpickle#module-cPickle>`_ \ | ||
to serialize and deserialize the data, storing it into a blob of type \ | ||
`'Python' <https://www.aerospike.com/docs/udf/api/bytes.html#encoding-type>`_ \ | ||
(`AS_BYTES_PYTHON <http://www.aerospike.com/apidocs/c/d0/dd4/as__bytes_8h.html#a0cf2a6a1f39668f606b19711b3a98bf3>`_). | ||
|
||
The functions :func:`~aerospike.set_serializer` and :func:`~aerospike.set_deserializer` \ | ||
allow for user-defined functions to handle serialization, instead. The user provided function will be run instead of cPickle. \ | ||
The serialized data is stored as \ | ||
type (\ | ||
`AS_BYTES_BLOB <http://www.aerospike.com/apidocs/c/d0/dd4/as__bytes_8h.html#a0cf2a6a1f39668f606b19711b3a98bf3>`_). \ | ||
This type allows the storage of binary data readable by Aerospike Clients in other languages. \ | ||
The *serialization* config param of :func:`aerospike.client` registers an \ | ||
instance-level pair of functions that handle serialization. | ||
|
||
Unless a user specified serializer has been provided, all other types will be stored as Python specific bytes. Python specific bytes may not be readable by Aerospike Clients for other languages. | ||
|
||
The following table shows which Python types map directly to Aerospike server types. | ||
|
||
+--------------------------+--------------+ | ||
| Python Type | server type | | ||
+==========================+==============+ | ||
|int |integer | | ||
+--------------------------+--------------+ | ||
|long |integer | | ||
+--------------------------+--------------+ | ||
|str |string | | ||
+--------------------------+--------------+ | ||
|unicode |string | | ||
+--------------------------+--------------+ | ||
|float |double | | ||
+--------------------------+--------------+ | ||
|dict |map | | ||
+--------------------------+--------------+ | ||
|list |list | | ||
+--------------------------+--------------+ | ||
|bytearray |blob | | ||
+--------------------------+--------------+ | ||
|aerospike.GeoJSON |GeoJSON | | ||
+--------------------------+--------------+ | ||
|
||
It is possible to nest these datatypes. For example a list may contain a dictionary, or a dictionary may contain a list as a value. | ||
|
||
.. note:: | ||
|
||
Unless a user specified serializer has been provided, all other types will be stored as Python specific bytes. Python specific bytes may not be readable by Aerospike Clients for other languages. | ||
|
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
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
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