Skip to content

Commit

Permalink
Merge pull request #186 from aerospike/2.1.3-candidate
Browse files Browse the repository at this point in the history
2.1.3 candidate
  • Loading branch information
Jeff Boone committed Aug 10, 2017
2 parents 2eea42a + 3be3366 commit 7ecc0a5
Show file tree
Hide file tree
Showing 36 changed files with 1,575 additions and 236 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.2
2.1.3
12 changes: 6 additions & 6 deletions doc/aerospike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ in an in-memory primary index.
* **max_nodes** maximum number of nodes allowed. Pad so new nodes can be added without configuration changes (default: 16)
* **max_namespaces** similarly pad (default: 8)
* **takeover_threshold_sec** take over tending if the cluster hasn't been checked for this many seconds (default: 30)
* **shm_key** explicitly set the shm key for this client. It is otherwise implicitly evaluated per unique hostname, and can be inspected with :meth:`~aerospike.Client.shm_key` (default: 0xA5000000)
* **shm_key** explicitly set the shm key for this client. If **use_shared_connection** is not set, or set to `False`, the user must provide a value for this field in order for shared memory to work correctly. If , and only if, **use_shared_connection** is set to `True`, the key will be implicitly evaluated per unique hostname, and can be inspected with :meth:`~aerospike.Client.shm_key` . It is still possible to specify a key when using **use_shared_connection** = `True`. (default: 0xA5000000)
* **use_shared_connection** :class:`bool` indicating whether this instance should share its connection to the Aerospike cluster with other client instances in the same process. (default: ``False``)
* **tls** a :class:`dict` of optional TLS configuration parameters. **TLS usage requires Aerospike Enterprise Edition**
* **enable** a :class:`bool` indicating whether tls should be enabled or not. Default: ``False``
Expand Down Expand Up @@ -847,7 +847,7 @@ Note that if "return_type" is not specified in the parameters for a map operatio
"op" : aerospike.OP_MAP_REMOVE_BY_INDEX_RANGE,
"bin": "my_map",
"index": 0,
"range": 2,
"val": 2,
"return_type": aerospike.MAP_RETURN_KEY_VALUE
}
Expand All @@ -873,7 +873,7 @@ Note that if "return_type" is not specified in the parameters for a map operatio
"op" : aerospike.OP_MAP_REMOVE_BY_RANK_RANGE,
"bin": "my_map",
"index": 10,
"range": 2,
"val": 2,
"return_type": aerospike.MAP_RETURN_KEY_VALUE
}
Expand All @@ -900,7 +900,7 @@ Note that if "return_type" is not specified in the parameters for a map operatio
"op" : aerospike.OP_MAP_GET_BY_KEY_RANGE,
"bin": "my_map",
"key": "i",
"val": "j",
"range": "j",
"return_type": aerospike.MAP_RETURN_KEY_VALUE
}
Expand Down Expand Up @@ -954,7 +954,7 @@ Note that if "return_type" is not specified in the parameters for a map operatio
"op" : aerospike.OP_MAP_GET_BY_INDEX_RANGE,
"bin": "my_map",
"index": 0,
"range": 2,
"val": 2,
"return_type": aerospike.MAP_RETURN_KEY_VALUE
}
Expand All @@ -980,7 +980,7 @@ Note that if "return_type" is not specified in the parameters for a map operatio
"op" : aerospike.OP_MAP_GET_BY_RANK_RANGE,
"bin": "my_map",
"index": 10,
"range": 2,
"val": 2,
"return_type": aerospike.MAP_RETURN_KEY_VALUE
}
Expand Down
34 changes: 30 additions & 4 deletions doc/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ a cluster-tending thread.
:param dict policy: optional :ref:`aerospike_operate_policies`.
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
:return: depends on return_type parameter
.. note:: Requires server version >= 3.8.4
.. versionadded:: 2.0.4
Expand All @@ -1314,10 +1315,11 @@ a cluster-tending thread.
.. method:: operate(key, list[, meta[, policy]]) -> (key, meta, bins)
Perform multiple bin operations on a record with a given *key*, \
with write operations happening before read ops. In Aerospike server \
In Aerospike server \
versions prior to 3.6.0, non-existent bins being read will have a \
:py:obj:`None` value. Starting with 3.6.0 non-existent bins will not be \
present in the returned :ref:`aerospike_record_tuple`.
present in the returned :ref:`aerospike_record_tuple`. \
The returned record tuple will only contain one entry per bin, even if multiple operations were performed on the bin.
:param tuple key: a :ref:`aerospike_key_tuple` associated with the record.
:param list list: a :class:`list` of one or more bin operations, each \
Expand All @@ -1332,6 +1334,18 @@ a cluster-tending thread.
:return: a :ref:`aerospike_record_tuple`. See :ref:`unicode_handling`.
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
.. note::
In version `2.1.3` the return format of certain bin entries for this method, **only in cases when a map operation specifying a `return_type` is used**, has changed. Bin entries for map operations using "return_type" of aerospike.MAP_RETURN_KEY_VALUE will now return \
a bin value of a list of keys and corresponding values, rather than a list of key/value tuples. See the following code block for details.
.. code-block:: python
# pre 2.1.3 formatting of key/value bin value
[('key1', 'val1'), ('key2', 'val2'), ('key3', 'val3')]
# >= 2.1.3 formatting
['key1', 'val1', 'key2', 'val2', 'key3', 'val3']
.. note::
:meth:`operate` can now have multiple write operations on a single
Expand Down Expand Up @@ -1433,7 +1447,7 @@ a cluster-tending thread.
finally:
client.close()
.. versionchanged:: 1.0.57
.. versionchanged:: 2.1.3
.. method:: operate_ordered(key, list[, meta[, policy]]) -> (key, meta, bins)
Expand All @@ -1459,6 +1473,18 @@ a cluster-tending thread.
:return: a :ref:`aerospike_record_tuple`. See :ref:`unicode_handling`.
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
.. note::
In version `2.1.3` the return format of bin entries for this method, **only in cases when a map operation specifying a `return_type` is used**, has changed. Map operations using "return_type" of aerospike.MAP_RETURN_KEY_VALUE will now return \
a bin value of a list of keys and corresponding values, rather than a list of key/value tuples. See the following code block for details. In addition, some operations which did not return a value in versions <= 2.1.2 will now return a response.
.. code-block:: python
# pre 2.1.3 formatting of key/value bin value
[('key1', 'val1'), ('key2', 'val2'), ('key3', 'val3')]
# >= 2.1.3 formatting
['key1', 'val1', 'key2', 'val2', 'key3', 'val3']
.. code-block:: python
from __future__ import print_function
Expand Down Expand Up @@ -1494,7 +1520,7 @@ a cluster-tending thread.
client.close()
.. versionadded:: 2.0.2
.. versionchanged:: 2.1.3
.. index::
single: Batch Operations
Expand Down
4 changes: 3 additions & 1 deletion src/include/conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ as_status as_user_to_pyobject(as_error *err, as_user *user, PyObject **py_as_use

as_status as_user_array_to_pyobject(as_error *err, as_user **users, PyObject **py_as_users, int users_size);

as_status pyobject_to_strArray(as_error * err, PyObject * py_list, char **arr);
as_status pyobject_to_strArray(as_error * err, PyObject * py_list, char **arr, uint32_t max_len);

as_status pyobject_to_val(AerospikeClient * self, as_error * err, PyObject * py_obj, as_val ** val, as_static_pool *static_pool, int serializer_type);

Expand All @@ -65,6 +65,8 @@ as_status as_list_of_map_to_py_tuple_list(AerospikeClient * self, as_error * err

as_status record_to_pyobject(AerospikeClient * self, as_error * err, const as_record * rec, const as_key * key, PyObject ** obj);

as_status operate_bins_to_pyobject(AerospikeClient * self, as_error * err, const as_record * rec, PyObject ** py_bins);

as_status record_to_pyobject_cnvt_list_to_map(AerospikeClient * self, as_error * err, const as_record * rec, const as_key * key, PyObject ** obj);

as_status key_to_pyobject(as_error * err, const as_key * key, PyObject ** obj);
Expand Down
2 changes: 1 addition & 1 deletion src/main/aerospike.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ AerospikeConstants operator_constants[] = {
MOD_INIT(aerospike)
{

const char version[8] = "2.1.2";
const char version[8] = "2.1.3";
// Makes things "thread-safe"
PyEval_InitThreads();
int i = 0;
Expand Down
9 changes: 6 additions & 3 deletions src/main/client/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ PyObject * AerospikeClient_Admin_Create_User(AerospikeClient * self, PyObject *a
roles[i] = cf_malloc(sizeof(char) * AS_ROLE_SIZE);
memset(roles[i], 0, sizeof(char) * AS_ROLE_SIZE);
}
} else {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Roles should be a list");
goto CLEANUP;
}

pyobject_to_strArray(&err, py_roles, roles);
pyobject_to_strArray(&err, py_roles, roles, AS_ROLE_SIZE);
if (err.code != AEROSPIKE_OK) {
goto CLEANUP;
}
Expand Down Expand Up @@ -507,7 +510,7 @@ PyObject * AerospikeClient_Admin_Grant_Roles( AerospikeClient *self, PyObject *a
}
}

pyobject_to_strArray(&err, py_roles, roles);
pyobject_to_strArray(&err, py_roles, roles, AS_ROLE_SIZE);
if (err.code != AEROSPIKE_OK) {
goto CLEANUP;
}
Expand Down Expand Up @@ -615,7 +618,7 @@ PyObject * AerospikeClient_Admin_Revoke_Roles( AerospikeClient *self, PyObject *
}
}

pyobject_to_strArray(&err, py_roles, roles);
pyobject_to_strArray(&err, py_roles, roles, AS_ROLE_SIZE);
if (err.code != AEROSPIKE_OK) {
goto CLEANUP;
}
Expand Down
11 changes: 8 additions & 3 deletions src/main/client/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ PyObject * AerospikeClient_Connect(AerospikeClient * self, PyObject * args, PyOb
as_error err;
as_error_init(&err);
char *alias_to_search = NULL;

bool free_alias_to_search = false;
PyObject * py_username = NULL;
PyObject * py_password = NULL;

Expand All @@ -64,6 +64,7 @@ PyObject * AerospikeClient_Connect(AerospikeClient * self, PyObject * args, PyOb
}

alias_to_search = return_search_string(self->as);
free_alias_to_search = true;

if (self->use_shared_connection) {
PyObject * py_persistent_item = PyDict_GetItemString(py_global_hosts, alias_to_search);
Expand Down Expand Up @@ -133,11 +134,15 @@ PyObject * AerospikeClient_Connect(AerospikeClient * self, PyObject * args, PyOb
PyObject * py_newobject = (PyObject *)AerospikeGobalHosts_New(self->as);
PyDict_SetItemString(py_global_hosts, alias_to_search, py_newobject);
}
PyMem_Free(alias_to_search);
alias_to_search = NULL;



CLEANUP:
if (free_alias_to_search && alias_to_search) {
PyMem_Free(alias_to_search);
alias_to_search = NULL;
}

if (err.code != AEROSPIKE_OK) {
PyObject * py_err = NULL;
error_to_pyobject(&err, &py_err);
Expand Down
11 changes: 8 additions & 3 deletions src/main/client/exists_many.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ PyObject * AerospikeClient_Exists_Many_Invoke(
as_policy_batch policy;
as_policy_batch * batch_policy_p = NULL;
bool has_batch_index = false;

bool use_batch_direct = false;
// Initialize error
as_error_init(&err);

Expand All @@ -437,8 +437,13 @@ PyObject * AerospikeClient_Exists_Many_Invoke(

has_batch_index = aerospike_has_batch_index(self->as);

if (has_batch_index
&& !(self->as->config.policies.batch.use_batch_direct)) {
if (batch_policy_p) {
use_batch_direct = batch_policy_p->use_batch_direct;
} else {
use_batch_direct = self->as->config.policies.batch.use_batch_direct;
}

if (has_batch_index && !use_batch_direct) {
py_recs = batch_exists_aerospike_batch_read(&err, self, py_keys,
batch_policy_p);
} else {
Expand Down
10 changes: 8 additions & 2 deletions src/main/client/get_many.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ PyObject * AerospikeClient_Get_Many_Invoke(
as_policy_batch policy;
as_policy_batch * batch_policy_p = NULL;
bool has_batch_index = false;

bool use_batch_direct = false;
// Initialize error
as_error_init(&err);

Expand All @@ -488,8 +488,14 @@ PyObject * AerospikeClient_Get_Many_Invoke(
goto CLEANUP;
}

if (batch_policy_p) {
use_batch_direct = batch_policy_p->use_batch_direct;
} else {
use_batch_direct = self->as->config.policies.batch.use_batch_direct;
}

has_batch_index = aerospike_has_batch_index(self->as);
if (has_batch_index && !(self->as->config.policies.batch.use_batch_direct)) {
if (has_batch_index && !use_batch_direct) {
py_recs = batch_get_aerospike_batch_read(&err, self, py_keys, batch_policy_p);
} else {
py_recs = batch_get_aerospike_batch_get(&err, self, py_keys, batch_policy_p);
Expand Down
2 changes: 1 addition & 1 deletion src/main/client/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ PyObject * AerospikeClient_Info(AerospikeClient * self, PyObject * args, PyObjec
char * req = NULL;
if (PyUnicode_Check(py_req)) {
py_ustr = PyUnicode_AsUTF8String(py_req);
req = strdup(PyBytes_AsString(py_ustr));
req = PyBytes_AsString(py_ustr);
} else if (PyString_Check(py_req)) {
req = PyString_AsString(py_req);
} else {
Expand Down

0 comments on commit 7ecc0a5

Please sign in to comment.