Skip to content

Commit

Permalink
Merge pull request #215 from aerospike/3.2.0-in-progress
Browse files Browse the repository at this point in the history
3.2.0 in progress
  • Loading branch information
aerospikerobertmarks committed May 1, 2018
2 parents 27ecf26 + e6ea8cd commit c7b4793
Show file tree
Hide file tree
Showing 24 changed files with 520 additions and 218 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
3.2.0
7 changes: 7 additions & 0 deletions api-changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# API Changes


## Version 3.2.0
### Additional Features
* Updated to C client `4.3.11`
* Added `client.map_get_by_value_list` and `client.map_get_by_key_list` These methods require Aerospike Server version >= 3.16.0.1 .


## Version 3.1.0

### Additional Features
Expand Down
19 changes: 19 additions & 0 deletions doc/aerospike.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ in an in-memory primary index.
* **scan** A dictionary containing scan policies. See :ref:`aerospike_scan_policies` for available policy fields and values.
* **batch** A dictionary containing batch policies. See :ref:`aerospike_batch_policies` for available policy fields and values.
* **total_timeout** default connection timeout in milliseconds (**Deprecated**: set this the individual policy dictionaries)
* **auth_mode** a value defining how to authenticate with the server such as :data:`aerospike.AUTH_INTERNAL` .
* **login_timeout_ms** An integer representing Node login timeout in milliseconds. Default: ``5000``.
* **key** default key policy, with values such as :data:`aerospike.POLICY_KEY_DIGEST` (**Deprecated**: set this individually in the 'read', 'write', 'apply', 'operate', 'remove' policy dictionaries)
* **exists** default exists policy, with values such as :data:`aerospike.POLICY_EXISTS_CREATE` (**Deprecated**: set in the 'write' policies dictionary)
* **max_retries** a :class:`int` representing the number of times to retry a transaction (**Deprecated**: set this the individual policy dictionaries)
Expand All @@ -86,6 +88,7 @@ in an in-memory primary index.
* **crl_check** :class:`bool` Enable CRL checking for the certificate chain leaf certificate. An error occurs if a suitable CRL cannot be found. By default CRL checking is disabled.
* **crl_check_all** :class:`bool` Enable CRL checking for the entire certificate chain. An error occurs if a suitable CRL cannot be found. By default CRL checking is disabled.
* **log_session_info** :class:`bool` Log session information for each connection.
* **for_login_only** :class:`bool` Log session information for each connection. Use TLS connections only for login authentication. All other communication with the server will be done with non-TLS connections. Default: ``False`` (Use TLS connections for all communication with server.)
* **serialization** an optional instance-level :py:func:`tuple` of (serializer, deserializer). Takes precedence over a class serializer registered with :func:`~aerospike.set_serializer`.
* **thread_pool_size** number of threads in the pool that is used in batch/scan/query commands (default: 16)
* **max_socket_idle** Maximum socket idle time in seconds. Connection pools will discard sockets that have
Expand Down Expand Up @@ -1117,6 +1120,22 @@ Specifies the behavior of failed operations.
If an operation fails, attempt the operation one more time
.. rubric:: Auth Mode Constants
Specifies the type of authentication to be used when communicating with the server
.. data:: AUTH_INTERNAL
Use internal authentication only. Hashed password is stored on the server. Do not send clear password. This is the default.
.. data:: AUTH_EXTERNAL
Use external authentication (like LDAP). Specific external authentication is configured on server. If TLS defined, send clear password on node login via TLS. Throw exception if TLS is not defined.
.. data:: AUTH_EXTERNAL_INSECURE
Use external authentication (like LDAP). Specific external authentication is configured on server. Send clear password on node login whether or not TLS is defined. This mode should only be used for testing purposes because it is not secure authentication.
.. _aerospike_scan_constants:
Scan Constants
Expand Down
37 changes: 36 additions & 1 deletion doc/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ a cluster-tending thread.
``'ttl'`` set to :class:`int` number of seconds or one of
:const:`aerospike.TTL_NAMESPACE_DEFAULT`, :const:`aerospike.TTL_NEVER_EXPIRE`,
:const:`aerospike.TTL_DONT_UPDATE`
:param dict policy: optional :ref:`aerospike_operate_policies`.
:param dict policy: optional :ref:`aerospike_operate_policies`. Note: the ``exists`` policy option may not be: ``aerospike.POLICY_EXISTS_CREATE_OR_REPLACE`` nor ``aerospike.POLICY_EXISTS_REPLACE``
:raises: a subclass of :exc:`~aerospike.exception.AerospikeError`.
.. code-block:: python
Expand Down Expand Up @@ -1172,6 +1172,24 @@ a cluster-tending thread.
.. versionadded:: 2.0.4
.. method:: map_get_by_key_list(key, bin, key_list, return_type[, meta[, policy]])
Return map entries from the map specified by *key* and *bin* having keys present in the *key_list*.
:param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record.
:param str bin: the name of the bin.
:param key_list: :py:class:`list` A list of map keys to fetch entries for
:param return_type: :py:class:`int` :ref:`map_return_types`
:param dict meta: unused for this operation
: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.16.0.1
.. versionadded:: 3.2.0
.. method:: map_get_by_value(key, bin, val, return_type[, meta[, policy]])
Return map entries from the map specified by *key* and *bin* which have a value matching *val* parameter.
Expand Down Expand Up @@ -1210,6 +1228,23 @@ a cluster-tending thread.
.. versionadded:: 2.0.4
.. method:: map_get_by_value_list(key, bin, value_list, return_type[, meta[, policy]])
Return map entries from the map specified by *key* and *bin* having values present in the *value_list*.
:param tuple key: a :ref:`aerospike_key_tuple` tuple associated with the record.
:param str bin: the name of the bin.
:param value_list: :py:class:`list` A list of map values specifying the entries to be retrieved.
:param return_type: :py:class:`int` :ref:`map_return_types`
:param dict meta: unused for this operation
: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.16.0.1
.. versionadded:: 3.2.0
.. method:: map_get_by_index(key, bin, index, return_type[, meta[, policy]])
Return the map entry from the map specified by *key* and *bin* at the given *index* location.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def run(self):
os.environ['ARCHFLAGS'] = '-arch x86_64'
AEROSPIKE_C_VERSION = os.getenv('AEROSPIKE_C_VERSION')
if not AEROSPIKE_C_VERSION:
AEROSPIKE_C_VERSION = '4.3.8'
AEROSPIKE_C_VERSION = '4.3.11'
DOWNLOAD_C_CLIENT = os.getenv('DOWNLOAD_C_CLIENT')
AEROSPIKE_C_HOME = os.getenv('AEROSPIKE_C_HOME')
PREFIX = None
Expand Down
2 changes: 2 additions & 0 deletions src/include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ PyObject * AerospikeClient_MapGetByKeyRange(AerospikeClient * self, PyObject * a

PyObject * AerospikeClient_MapGetByValue(AerospikeClient * self, PyObject * args, PyObject * kwds);
PyObject * AerospikeClient_MapGetByValueRange(AerospikeClient * self, PyObject * args, PyObject * kwds);
PyObject* AerospikeClient_MapGetByValueList(AerospikeClient* self, PyObject* args, PyObject* kwds);
PyObject* AerospikeClient_MapGetByKeyList(AerospikeClient* self, PyObject* args, PyObject* kwds);

PyObject * AerospikeClient_MapGetByIndex(AerospikeClient * self, PyObject * args, PyObject * kwds);
PyObject * AerospikeClient_MapGetByIndexRange(AerospikeClient * self, PyObject * args, PyObject * kwds);
Expand Down
2 changes: 1 addition & 1 deletion src/include/pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ typedef struct bytes_static_pool {
}

#define POOL_DESTROY(static_pool) \
for (u_int32_t iter = 0; iter < BYTES_CNT(static_pool); iter++) { \
for (uint32_t iter = 0; iter < BYTES_CNT(static_pool); iter++) { \
as_bytes_destroy(&BYTES_POOL(static_pool)[iter]); \
}
2 changes: 1 addition & 1 deletion src/main/aerospike.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ AerospikeConstants operator_constants[] = {
MOD_INIT(aerospike)
{

const char version[8] = "3.1.1";
const char version[8] = "3.2.0";
// Makes things "thread-safe"
PyEval_InitThreads();
int i = 0;
Expand Down
128 changes: 128 additions & 0 deletions src/main/client/operate_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,134 @@ PyObject * AerospikeClient_MapGetByValueRange(AerospikeClient * self, PyObject *
return py_result;
}

/*
* key = ('test', 'demo', 1)
* res = client.map_get_by_value_list(key, 'map_bin', ['val1', 'val2'], aerospike.MAP_RETURN_VALUE)
*/
PyObject* AerospikeClient_MapGetByValueList(AerospikeClient* self, PyObject* args, PyObject* kwds) {
BASE_VARIABLES

// Parameter vars
PyObject * py_meta = NULL;
PyObject * py_policy = NULL;
PyObject* py_value_list = NULL;
uint64_t returnType;

// C client function arg vars
as_policy_operate operate_policy;
as_policy_operate *operate_policy_p = NULL;
as_val* as_value_list = NULL;
as_record *rec = NULL;

// Return Vars
PyObject* py_result = NULL;

//Util Vars
as_static_pool pool;
memset(&pool, 0, sizeof(pool));

CHECK_CONNECTED();

static char* kwlist[] = {"key", "bin", "value_list", "return_type", "meta", "policy", NULL};
if (PyArg_ParseTupleAndKeywords(args, kwds, "OOOl|OO:map_get_by_value_list",
kwlist, &py_key, &py_bin, &py_value_list, &returnType, &py_meta, &py_policy) == false) {
goto CLEANUP;
}

// Initialize the variables
POLICY_KEY_META_BIN()

if (!py_value_list || !PyList_Check(py_value_list)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "type of value_list must be list");
goto CLEANUP;
}

if (pyobject_to_val(self, &err, py_value_list, &as_value_list, &pool, SERIALIZER_PYTHON) != AEROSPIKE_OK) {
goto CLEANUP;
}

if (!as_list_fromval(as_value_list)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Failed to convert Python list");
goto CLEANUP;
}

if (!as_operations_add_map_get_by_value_list(&ops, bin, as_list_fromval(as_value_list), (as_map_return_type)returnType)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Failed to add map_get_by_value_list operation");
goto CLEANUP;
}

DO_OPERATION()
SETUP_RETURN_VAL()

CLEANUP:
CLEANUP_AND_EXCEPTION_ON_ERROR(err);
return py_result;
}

/*
* key = ('test', 'demo', 1)
* res = client.map_get_by_key_list(key, 'map_bin', ['key1', 'key2'], aerospike.MAP_RETURN_VALUE)
*/
PyObject* AerospikeClient_MapGetByKeyList(AerospikeClient* self, PyObject* args, PyObject* kwds) {
BASE_VARIABLES

// Parameter vars
PyObject * py_meta = NULL;
PyObject * py_policy = NULL;
PyObject* py_key_list = NULL;
uint64_t returnType;

// C client function arg vars
as_policy_operate operate_policy;
as_policy_operate *operate_policy_p = NULL;
as_val* as_key_list = NULL;
as_record *rec = NULL;

// Return Vars
PyObject* py_result = NULL;

//Util Vars
as_static_pool pool;
memset(&pool, 0, sizeof(pool));

CHECK_CONNECTED();

static char* kwlist[] = {"key", "bin", "key_list", "return_type", "meta", "policy", NULL};
if (PyArg_ParseTupleAndKeywords(args, kwds, "OOOl|OO:map_get_by_key_list",
kwlist, &py_key, &py_bin, &py_key_list, &returnType, &py_meta, &py_policy) == false) {
goto CLEANUP;
}

// Initialize the variables
POLICY_KEY_META_BIN()

if (!py_key_list || !PyList_Check(py_key_list)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "type of key_list must be list");
goto CLEANUP;
}

if (pyobject_to_val(self, &err, py_key_list, &as_key_list, &pool, SERIALIZER_PYTHON) != AEROSPIKE_OK) {
goto CLEANUP;
}

if (!as_list_fromval(as_key_list)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Failed to convert Python list");
goto CLEANUP;
}

if (!as_operations_add_map_get_by_key_list(&ops, bin, as_list_fromval(as_key_list), (as_map_return_type)returnType)) {
as_error_update(&err, AEROSPIKE_ERR_PARAM, "Failed to add map_get_by_key_list operation");
goto CLEANUP;
}

DO_OPERATION()
SETUP_RETURN_VAL()

CLEANUP:
CLEANUP_AND_EXCEPTION_ON_ERROR(err);
return py_result;
}

PyObject * AerospikeClient_MapGetByIndex(AerospikeClient * self, PyObject * args, PyObject * kwds)
{
BASE_VARIABLES
Expand Down

0 comments on commit c7b4793

Please sign in to comment.