Skip to content

Commit

Permalink
Nested CDT map and list operations and bitwise operations 3.9.0 (#8)
Browse files Browse the repository at this point in the history
* fixed OverflowError: Python int too large to convert to C long

* added large job id test

* fixed double linked list corruption error

* added query apply set detection tests

* updated test_query_apply

* refactored double free and python overflow fixes

* added test for non list udf arguments

* update c client

* check for illegal udf arguments in dictionaries

* added bytes udf test

* added py_to_val coversion for python3 bytes

* update illegal udf args exception, add stream udf tuple test

* iterative udf arg check

* removed unnecessary assignments, consistent string encoding in tests, added udf arg documentation to query.apply

* fail on 4XX response codes

https://curl.haxx.se/mail/archive-2006-02/0004.html the exit status of
curl on a 4XX response code is zero without the -f flag.

* Remove transaction queue and thread-per-queue config options

These config options were removed in server version 4.7.0
https://www.aerospike.com/download/server/notes.html#4.7.0.2

* Bitwise operations (#6)

* Initial bitwise file

* Start of bitwise ops

* Tests for bitwise beginning

* Basic bitwise testing

* Tests for resize

* bitwise remove and set

* set_bit tests, documentation, set_bit Byte_Offset fixed

* implemented bit_count

* bit_count tests

* implemented bit_add and bit_add tests

* implemented bit_and, bit_and tests

* implemented bit_get

* bit_get tests

* implemented bit_get_int and bit_get_int tests

* implemented bit_insert

* bit_insert tests

* implemented bit_lscan and bit_lscan tests

* implemented bit_lshift and lshift tests

* implemented bit_not and bit_not tests

* implemented bit_or and bit_or tests

* implemented bit_rscan and bit_rshift with tests

* implemented bit_subtract and tests

* implemented bit_xor and tests

* bit_wise documentation and tests

* update c client, fix travis config thread queue option, cleanup bit operate

* cleanup bitwise documentation, change isbitop to use range

* add bitwise helper get_uint32t_from_pyargs, refactor bitwise code and documentation

* Nested_cdt support for map and list ops. (#7)

* nested cdt groundwork and tests

* nested cdt constants

* added support for as_val based nested cdt ops, list_op nested cdt ops, and tests

* nested cdt for list ops

* nested cdt_ctx logic for all list ops, more tests for nested cdt list ops

* nested cdt ctx groundwork, nested cdt for map_get_by_key

* Remove transaction queue and thread-per-queue config options

These config options were removed in server version 4.7.0
https://www.aerospike.com/download/server/notes.html#4.7.0.2

* nested map cdt get by val and index, fixed nested cdt list tests and python cdt_ctx converter

* nested cdt map ops for all remove by rank, map size, map policy, increment, put, put items and tests

* nested cdt ops and tests for all map ops except relative ops

* nested cdt ops and tests for maps

* fix ctx error mem leak

* move ctx_operations out of operations

* sort nested_map by key_order
  • Loading branch information
dwelch-spike committed Oct 23, 2019
1 parent 80f1e19 commit 3c192f6
Show file tree
Hide file tree
Showing 29 changed files with 8,703 additions and 870 deletions.
2 changes: 1 addition & 1 deletion .build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: aerospike-client-python
dependency:
- url: git@github.com:citrusleaf/aerospike-client-c
dir: client-c
ref: 4.6.5
ref: 4.6.8
- url: git@github.com:citrusleaf/aerospike-lua-core
dir: lua
ref: master
Expand Down
2 changes: 0 additions & 2 deletions .travis/aerospike.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ service {
run-as-daemon
paxos-single-replica-limit 1 # Number of nodes where the replica count is automatically reduced to 1.
pidfile ${home}/var/run/aerospike.pid
transaction-queues 8
transaction-threads-per-queue 8
work-directory ${home}/var
}

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.8.0
3.9.0
140 changes: 140 additions & 0 deletions aerospike_helpers/cdt_ctx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
'''
Helper functions to generate complex data type context (cdt_ctx) objects for use with operations on nested CDTs (list, map, etc).
for example:
Note We assume 'client' is a connected aerospike client.
Example::
from aerospike_helpers import cdt_ctx
from aerospike_helpers.operations import list_operations
list_example = [['first', ['test', 'example']], 'test']
ctx = [
cdt_ctx.cdt_ctx_list_index(0),
cdt_ctx.cdt_ctx_list_value(['test', 'example'])
]
ops = [
list_operations.list_append(nested_list_example_bin, value_to_append, list_write_policy, ctx)
]
client.operate(example_key, ops)
List_example is now [['first', ['test', 'example', value_to_append]], 'test'].
List and map cdt_ctx objects can be mixed in a list to navigate large CDTs.
'''
import aerospike


class _cdt_ctx:
"""
Class used to represent a single ctx_operation.
"""
def __init__(self, id=None, value=None):
self.id = id
self.value = value


def cdt_ctx_list_index(index):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a list by index.
If the index is negative, the lookup starts backwards from the end of the list.
If it is out of bounds, a parameter error will be returned.
Args:
index (int): The index to look for in the list.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_LIST_INDEX, index)


def cdt_ctx_list_rank(rank):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a list by rank.
If the rank is negative, the lookup starts backwards from the largest rank value.
Args:
rank (int): The rank to look for in the list.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_LIST_RANK, rank)


def cdt_ctx_list_value(value):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a list by value.
Args:
value (object): The value to look for in the list.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_LIST_VALUE, value)


def cdt_ctx_map_index(index):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a map by index.
If the index is negative, the lookup starts backwards from the end of the map.
If it is out of bounds, a parameter error will be returned.
Args:
index (int): The index to look for in the map.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_MAP_INDEX, index)


def cdt_ctx_map_rank(rank):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a map by index.
If the rank is negative, the lookup starts backwards from the largest rank value.
Args:
rank (int): The rank to look for in the map.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_MAP_RANK, rank)


def cdt_ctx_map_key(key):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a map by key.
Args:
key (object): The key to look for in the map.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_MAP_KEY, key)


def cdt_ctx_map_value(value):
"""Creates a nested cdt_ctx object for use with list or map operations.
The cdt_ctx object is initialized to lookup an object in a map by value.
Args:
value (object): The value to look for in the map.
Returns:
A cdt_ctx object, a list of these is usable with list and map operations.
"""
return _cdt_ctx(aerospike.CDT_CTX_MAP_VALUE, value)

0 comments on commit 3c192f6

Please sign in to comment.