aerospike_helpers.operations package

aerospike_helpers.operations.operations module

Module with helper functions to create dictionaries consumed by the aerospike.Client.operate and aerospike.Client.operate_ordered methods for the aerospike.client class.

aerospike_helpers.operations.operations.append(bin_name, append_item)

Create an append operation dictionary.

The append operation appends append_item to the value in bin_name.

Parameters:
  • bin (string) – The name of the bin to be used.
  • append_item – The value which will be appended to the item contained in the specified bin.
Returns:

A dictionary to be passed to operate or operate_ordered.

aerospike_helpers.operations.operations.delete()

Create a delete operation dictionary.

The delete operation deletes a record and all associated bins. Requires server version >= 4.7.0.8.

Returns:A dictionary to be passed to operate or operate_ordered.
aerospike_helpers.operations.operations.increment(bin_name, amount)

Create an increment operation dictionary.

The increment operation increases a value in bin_name by the specified amount, or creates a bin with the value of amount.

Parameters:
  • bin (string) – The name of the bin to be incremented.
  • amount – The amount by which to increment the item in the specified bin.
Returns:

A dictionary to be passed to operate or operate_ordered.

aerospike_helpers.operations.operations.prepend(bin_name, prepend_item)

Create a prepend operation dictionary.

The prepend operation prepends prepend_item to the value in bin_name.

Parameters:
  • bin (string) – The name of the bin to be used.
  • prepend_item – The value which will be prepended to the item contained in the specified bin.
Returns:

A dictionary to be passed to operate or operate_ordered.

aerospike_helpers.operations.operations.read(bin_name)

Create a read operation dictionary.

The read operation reads and returns the value in bin_name.

Parameters:bin – String the name of the bin from which to read.
Returns:A dictionary to be passed to operate or operate_ordered.
aerospike_helpers.operations.operations.touch(ttl=None)

Create a touch operation dictionary.

Using ttl here is deprecated. It should be set in the record metadata for the operate method.

Parameters:ttl (int) – Deprecated. The ttl that should be set for the record. This should be set in the metadata passed to the operate or operate_ordered methods.
Returns:A dictionary to be passed to operate or operate_ordered.
aerospike_helpers.operations.operations.write(bin_name, write_item)

Create a write operation dictionary.

The write operation writes write_item into the bin specified by bin_name.

Parameters:
  • bin (string) – The name of the bin into which write_item will be stored.
  • write_item – The value which will be written into the bin.
Returns:

A dictionary to be passed to operate or operate_ordered.

aerospike_helpers.operations.list_operations module

This module provides helper functions to produce dictionaries to be used with the aerospike.Client.operate and aerospike.Client.operate_ordered methods of the aerospike module.

List operations support nested CDTs through an optional ctx context argument.
The ctx argument is a list of cdt_ctx objects. See aerospike_helpers.cdt_ctx.

Note

Nested CDT (ctx) requires server version >= 4.6.0

aerospike_helpers.operations.list_operations.list_append(bin_name, value, policy=None, ctx=None)

Creates a list append operation to be used with operate, or operate_ordered

The list append operation instructs the aerospike server to append an item to the end of a list bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • value – The value to be appended to the end of the list.
  • policy (dict) – An optional dictionary of list write options.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_append_items(bin_name, values, policy=None, ctx=None)

Creates a list append items operation to be used with operate, or operate_ordered

The list append items operation instructs the aerospike server to append multiple items to the end of a list bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • values – (list): A sequence of items to be appended to the end of the list.
  • policy (dict) – An optional dictionary of list write options.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_clear(bin_name, ctx=None)

Create list clear operation.

The list clear operation removes all items from the list specified by bin_name

Parameters:
  • bin_name (str) – The name of the bin containing the list to be cleared
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get(bin_name, index, ctx=None)

Create a list get operation.

The list get operation gets the value of the item at index and returns the value

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • index (int) – The index of the item to be returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_index(bin_name, index, return_type, ctx=None)

Create a list get index operation.

The list get operation gets the item at index and returns a value specified by return_type

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • index (int) – The index of the item to be returned.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_index_range(bin_name, index, return_type, count=None, inverted=False, ctx=None)

Create a list get index range operation.

The list get by index range operation gets count items starting at index and returns a value specified by return_type

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • index (int) – The index of the first item to be returned.
  • count (int) – The number of list items to be selected.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values.
  • inverted (bool) – Optional bool specifying whether to invert the return type. If set to True, all items outside of the specified range will be returned. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_rank(bin_name, rank, return_type, ctx=None)

Create a list get by rank operation.

Server selects list item identified by rank and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch a value from.
  • rank (int) – The rank of the item to be fetched.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_rank_range(bin_name, rank, return_type, count=None, inverted=False, ctx=None)

Create a list get by rank range operation.

Server selects count items starting at the specified rank and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • rank (int) – The rank of the first items to be returned.
  • count (int) – A positive number indicating number of items to be returned.
  • return_type (int) – Value specifying what should be returned from the operation.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the return type. If set to True, all items outside of the specified rank range will be returned. Default: False
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_value(bin_name, value, return_type, inverted=False, ctx=None)

Create a list get by value operation.

Server selects list items with a value equal to value and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • value – The server returns all items matching this value
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the return type. If set to True, all items not equal to value will be selected. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_value_list(bin_name, value_list, return_type, inverted=False, ctx=None)

Create a list get by value list operation.

Server selects list items with a value contained in value_list and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • value_list (list) – Return items from the list matching an item in this list.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the return type. If set to True, all items not matching an entry in value_list will be selected. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_value_range(bin_name, return_type, value_begin, value_end, inverted=False, ctx=None)

Create a list get by value list operation.

Server selects list items with a value greater than or equal to value_begin and less than value_end. Server returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • value_begin – The start of the value range.
  • value_end – The end of the value range.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the return type. If set to True, all items not included in the specified range will be returned. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_by_value_rank_range_relative(bin_name, value, offset, return_type, count=None, inverted=False, ctx=None)

Create a list get by value rank range relative operation

Create list get by value relative to rank range operation. Server selects list items nearest to value and greater by relative rank. Server returns selected data specified by return_type.

Note

This operation requires server version 4.3.0 or greater.

Examples

These examples show what would be returned for specific arguments when dealing with an ordered list: [0,4,5,9,11,15]

(value, offset, count) = [selected items]
(5, 0, None) = [5,9,11,15]
(5, 0, 2) = [5, 9]
(5, -1, None) = [4, 5, 9, 11, 15]
(5, -1, 3) = [4, 5, 9]
(3,3, None) = [11, 15]
(3,-3, None) = [0, 4,5,9,11,15]
(3, 0, None) = [4,5,9,11,15]
Parameters:
  • bin_name (str) – The name of the bin containing the list.
  • value (str) – The value of the item in the list for which to search
  • offset (int) – Begin returning items with rank == rank(found_item) + offset
  • count (int) – If specified, the number of items to return. If None, all items until end of list are returned.
  • inverted (bool) – If True, the operation is inverted, and items outside of the specified range are returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_get_range(bin_name, index, count, ctx=None)

Create a list get range operation.

The list get range operation gets count items starting index and returns the values.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • index (int) – The index of the item to be returned.
  • count (int) – A positive number of items to be returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_increment(bin_name, index, value, policy=None, ctx=None)

Creates a list increment operation to be used with operate, or operate_ordered

The list insert operation inserts an item at index: index into the list contained in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index (int) – The index of the list item to increment.
  • value (int, float) – The value to be added to the list item.
  • policy (dict) – An optional dictionary of list write options.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_insert(bin_name, index, value, policy=None, ctx=None)

Creates a list insert operation to be used with operate, or operate_ordered

The list insert operation inserts an item at index: index into the list contained in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index (int) – The index at which to insert an item. The value may be positive to use zero based indexing or negative to index from the end of the list.
  • value – The value to be inserted into the list.
  • policy (dict) – An optional dictionary of list write options.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_insert_items(bin_name, index, values, policy=None, ctx=None)

Creates a list insert items operation to be used with operate, or operate_ordered

The list insert items operation inserts items at index: index into the list contained in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index (int) – The index at which to insert the items. The value may be positive to use zero based indexing or negative to index from the end of the list.
  • values (list) – The values to be inserted into the list.
  • policy (dict) – An optional dictionary of list write options.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_pop(bin_name, index, ctx=None)

Creates a list pop operation to be used with operate, or operate_ordered

The list pop operation removes and returns an item index: index from list contained in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index (int) – The index of the item to be removed.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_pop_range(bin_name, index, count, ctx=None)

Creates a list pop range operation to be used with operate, or operate_ordered

The list insert range operation removes and returns count items starting from index: index from the list contained in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index (int) – The index of the first item to be removed.
  • count (int) – A positive number indicating how many items, including the first,
  • be removed and returned (to) –
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove(bin_name, index, ctx=None)

Create list remove operation.

The list remove operation removes an item located at index in the list specified by bin_name

Parameters:
  • bin_name (str) – The name of the bin containing the item to be removed.
  • index (int) – The index at which to remove the item.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_index(bin_name, index, return_type, ctx=None)

Create a list remove by index operation.

The list_remove_by_index operation removes the value of the item at index and returns a value specified by return_type

Parameters:
  • bin_name (str) – The name of the bin containing the list to remove an item from.
  • index (int) – The index of the item to be removed.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_index_range(bin_name, index, return_type, count=None, inverted=False, ctx=None)

Create a list remove by index range operation.

The list remove by index range operation removes count starting at index and returns a value specified by return_type

Parameters:
  • bin_name (str) – The name of the bin containing the list to remove items from.
  • index (int) – The index of the first item to be removed.
  • count (int) – The number of items to be removed
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values.
  • inverted (bool) – Optional bool specifying whether to invert the operation. If set to True, all items outside of the specified range will be removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_rank(bin_name, rank, return_type, ctx=None)

Create a list remove by rank operation.

Server removes a list item identified by rank and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch a value from.
  • rank (int) – The rank of the item to be removed.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_rank_range(bin_name, rank, return_type, count=None, inverted=False, ctx=None)

Create a list remove by rank range operation.

Server removes count items starting at the specified rank and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • rank (int) – The rank of the first item to removed.
  • count (int) – A positive number indicating number of items to be removed.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the operation. If set to True, all items outside of the specified rank range will be removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_value(bin_name, value, return_type, inverted=False, ctx=None)

Create a list remove by value operation.

Server removes list items with a value equal to value and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to remove items from.
  • value – The server removes all list items matching this value.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the operation. If set to True, all items not equal to value will be removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_value_list(bin_name, value_list, return_type, inverted=False, ctx=None)

Create a list remove by value list operation.

Server removes list items with a value matching one contained in value_list and returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to remove items from.
  • value_list (list) – The server removes all list items matching one of these values.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the operation. If set to True, all items not equal to a value contained in value_list will be removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_value_range(bin_name, return_type, value_begin=None, value_end=None, inverted=False, ctx=None)

Create a list remove by value range operation.

Server removes list items with a value greater than or equal to value_begin and less than value_end. Server returns selected data specified by return_type.

Parameters:
  • bin_name (str) – The name of the bin containing the list to fetch items from.
  • value_begin – The start of the value range.
  • value_end – The end of the value range.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the List Return Types values
  • inverted (bool) – Optional bool specifying whether to invert the operation. If set to True, all items not included in the specified range will be removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_by_value_rank_range_relative(bin_name, value, offset, return_type, count=None, inverted=False, ctx=None)

Create a list get by value rank range relative operation

Create list remove by value relative to rank range operation. Server removes and returns list items nearest to value and greater by relative rank. Server returns selected data specified by return_type.

Note

This operation requires server version 4.3.0 or greater.

These examples show what would be removed and returned for specific arguments when dealing with an ordered list: [0,4,5,9,11,15]

(value, offset, count) = [selected items]
(5,0,None) = [5,9,11,15]
(5,0,2) = [5, 9]
(5,-1, None) = [4,5,9,11,15]
(5, -1, 3) = [4,5,9]
(3,3, None) = [11,15]
(3,-3, None) = [0,4,5,9,11,15]
(3, 0, None) = [4,5,9,11,15]
Parameters:
  • bin_name (str) – The name of the bin containing the list.
  • value (str) – The value of the item in the list for which to search
  • offset (int) – Begin removing and returning items with rank == rank(found_item) + offset
  • count (int) – If specified, the number of items to remove and return. If None, all items until end of list are returned.
  • inverted (bool) – If True, the operation is inverted, and items outside of the specified range are removed and returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_remove_range(bin_name, index, count, ctx=None)

Create list remove range operation.

The list remove range operation removes count items starting at index in the list specified by bin_name

Parameters:
  • bin_name (str) – The name of the bin containing the items to be removed.
  • index (int) – The index of the first item to remove.
  • count (int) – A positive number representing the number of items to be removed.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_set(bin_name, index, value, policy=None, ctx=None)

Create a list set operation.

The list set operations sets the value of the item at index to value

Parameters:
  • bin_name (str) – The name of the bin containing the list to be operated on.
  • index (int) – The index of the item to be set.
  • value – The value to be assigned to the list item.
  • policy (dict) – An optional dictionary of list write options.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_set_order(bin_name, list_order, ctx=None)

Create a list set order operation.

The list_set_order operation sets an order on a specified list bin.

Parameters:
  • bin_name (str) – The name of the list bin.
  • list_order – The ordering to apply to the list. Should be aerospike.LIST_ORDERED or aerospike.LIST_UNORDERED .
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_size(bin_name, ctx=None)

Create a list size operation.

Server returns the size of the list in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the list.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_sort(bin_name, sort_flags=<MagicMock id='140318862128184'>, ctx=None)

Create a list sort operation

The list sort operation will sort the specified list bin.

Parameters:
  • bin_name (str) – The name of the bin to sort.
  • sort_flags – Optional flags modifiying the behavior of list_sort. This should be constructed by bitwise or’ing together values from List Sort Flags.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.list_operations.list_trim(bin_name, index, count, ctx=None)

Create a list trim operation.

Server removes items in list bin that do not fall into range specified by index and count range.

Parameters:
  • bin_name (str) – The name of the bin containing the list to be trimmed.
  • index (int) – The index of the items to be kept.
  • count (int) – A positive number of items to be kept.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations module

Helper functions to create map operation dictionaries arguments for. the aerospike.Client.operate and aerospike.Client.operate_ordered methods of the aerospike client.

Map operations support nested CDTs through an optional ctx context argument.
The ctx argument is a list of cdt_ctx objects. See aerospike_helpers.cdt_ctx.

Note

Nested CDT (ctx) requires server version >= 4.6.0

aerospike_helpers.operations.map_operations.map_clear(bin_name, ctx=None)

Creates a map_clear operation to be used with operate or operate_ordered

The operation removes all items from the map stored in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_decrement(bin_name, key, amount, map_policy=None, ctx=None)

Creates a map_decrement operation to be used with operate or operate_ordered

The operation allows a user to decrement the value of a value stored in the map on the server.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key – The key for the value to be decremented.
  • amount – The amount by which to decrement the value stored in map[key]
  • map_policy (list, optional) – Optional map_policy dictionary dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map. Defaults to None.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_index(bin_name, index, return_type, ctx=None)

Creates a map_get_by_index operation to be used with operate or operate_ordered

The operation returns the entry at index from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • index (int) – The index of the entry to return.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_index_range(bin_name, index_start, get_amt, return_type, inverted=False, ctx=None)

Creates a map_get_by_index_range operation to be used with operate or operate_ordered

The operation returns get_amt entries starting at index_start from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • index_start (int) – The index of the first entry to return.
  • get_amt (int) – The number of entries to return from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If true, entries in the specified index range should be ignored, and all other entries returned. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_key(bin_name, key, return_type, ctx=None)

Creates a map_get_by_key operation to be used with operate or operate_ordered

The operation returns an item, specified by the key from the map stored in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key – The key of the item to be returned from the map
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_key_index_range_relative(bin_name, value, offset, return_type, count=None, inverted=False, ctx=None)

Create a map get by value rank range relative operation

Create map get by key relative to index range operation. Server removes and returns map items with key nearest to value and greater by relative index. Server returns selected data specified by return_type.

Note

This operation requires server version 4.3.0 or greater.

Examples

Examples for a key ordered map {0: 6, 6: 12, 10: 18, 15: 24} and return type of aerospike.MAP_RETURN_KEY

(value, offset, count) = [returned keys]
(5, 0, None) = [6, 10, 15]
(5, 0, 2) = [6, 10]
(5,-1, None) = [0, 6, 10, 15]
(5, -1, 3) = [0, 6, 10]
(3, 2, None) = [15]
(3, 5, None) = []
Parameters:
  • bin_name (str) – The name of the bin containing the list.
  • value (str) – The value of the item in the list for which to search
  • offset (int) – Begin removing and returning items with rank == rank(fount_item) + offset
  • count (int) – If specified, the number of items to remove and return. If None, all items until end of list are returned.
  • inverted (bool) – If True, the operation is inverted and items outside of the specified range are returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_key_list(bin_name, key_list, return_type, inverted=False, ctx=None)

Creates a map_get_by_key_list operation to be used with operate or operate_ordered

The operation returns items, specified by the keys in key_list from the map stored in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key_list (list) – A list of keys to be returned from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If true, keys with values not specified in the key_list will be returned, and those keys specified in the key_list will be ignored. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_key_range(bin_name, key_range_start, key_range_end, return_type, inverted=False, ctx=None)

Creates a map_get_by_key_range operation to be used with operate or operate_ordered

The operation returns items with keys between key_range_start(inclusive) and key_range_end(exclusive) from the map

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key_range_start – The start of the range of keys to be returned. (Inclusive)
  • key_range_end – The end of the range of keys to be returned. (Exclusive)
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, values outside of the specified range will be returned, and values inside of the range will be ignored. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_rank(bin_name, rank, return_type, ctx=None)

Creates a map_get_by_rank operation to be used with operate or operate_ordered

The operation returns the item with the specified rank from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • rank (int) – The rank of the entry to return.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_rank_range(bin_name, rank_start, get_amt, return_type, inverted=False, ctx=None)

Creates a map_get_by_rank_range operation to be used with operate or operate_ordered

The operation returns item within the specified rank range from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • rank_start (int) – The start of the rank of the entries to return.
  • get_amt (int) – The number of entries to return.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, items with ranks inside the specified range should be ignored, and all other entries returned. Default: False.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_value(bin_name, value, return_type, inverted=False, ctx=None)

Creates a map_get_by_value operation to be used with operate or operate_ordered

The operation returns entries whose value matches the specified value.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value – Entries with a value matching this argument will be returned from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, entries with a value different than the specified value will be returned. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_value_list(bin_name, key_list, return_type, inverted=False, ctx=None)

Creates a map_get_by_value_list operation to be used with operate or operate_ordered

The operation returns entries whose values are specified in the value_list.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value_list (list) – Entries with a value contained in this list will be returned from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, entries with a value contained in value_list will be ignored, and all others will be returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_value_range(bin_name, value_start, value_end, return_type, inverted=False, ctx=None)

Creates a map_get_by_value_range operation to be used with operate or operate_ordered

The operation returns items, with values between value_start(inclusive) and value_end(exclusive) from the map

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value_start – The start of the range of values to be returned. (Inclusive)
  • value_end – The end of the range of values to be returned. (Exclusive)
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, values outside of the specified range will be returned, and values inside of the range will be ignored. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_get_by_value_rank_range_relative(bin_name, value, offset, return_type, count=None, inverted=False, ctx=None)

Create a map remove by value rank range relative operation

Create list map get by value relative to rank range operation. Server returns map items with value nearest to value and greater by relative rank. Server returns selected data specified by return_type.

Note

This operation requires server version 4.3.0 or greater.

Examples

Examples for map {0: 6, 10: 18, 6: 12, 15: 24} and return type of aerospike.MAP_RETURN_KEY

(value, offset, count) = [returned keys]
(6, 0, None) = [0, 6, 10, 15]
(5, 0, 2) = [0, 6]
(7, -1, 1) = [0]
(7, -1, 3) = [0, 6, 10]
Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value (str) – The value of the item in the list for which to search
  • offset (int) – Begin removing and returning items with rank == rank(fount_item) + offset
  • count (int) – If specified, the number of items to remove and return. If None, all items until end of list are returned.
  • inverted (bool) – If True, the operation is inverted and items outside of the specified range are returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_increment(bin_name, key, amount, map_policy=None, ctx=None)

Creates a map_increment operation to be used with operate or operate_ordered

The operation allows a user to increment the value of a value stored in the map on the server.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key – The key for the value to be incremented.
  • amount – The amount by which to increment the value stored in map[key]
  • map_policy (list, optional) – Optional map_policy dictionary dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map. Defaults to None.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_put(bin_name, key, value, map_policy=None, ctx=None)

Creates a map_put operation to be used with operate or operate_ordered

The operation allows a user to set the value of an item in the map stored on the server.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key – The key for the map.
  • value – The item to store in the map with the corresponding key.
  • map_policy (list, optional) – Optional map_policy dictionary dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map. Defaults to None.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_put_items(bin_name, item_dict, map_policy=None, ctx=None)

Creates a map_put_items operation to be used with operate or operate_ordered

The operation allows a user to add or update items in the map stored on the server.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • item_dict (dict) – A dictionary of key value pairs to be added to the map on the server.
  • map_policy (list, optional) – Optional map_policy dictionary dictates the type of map to create when it does not exist. The map policy also specifies the mode used when writing items to the map. Defaults to None.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_index(bin_name, index, return_type, ctx=None)

Creates a map_remove_by_index operation to be used with operate or operate_ordered

The operation removes the entry at index from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • index (int) – The index of the entry to remove.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_index_range(bin_name, index_start, remove_amt, return_type, inverted=False, ctx=None)

Creates a map_remove_by_index_range operation to be used with operate or operate_ordered

The operation removes remove_amt entries starting at index_start from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • index_start (int) – The index of the first entry to remove.
  • remove_amt (int) – The number of entries to remove from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If true, entries in the specified index range should be kept, and all other entries removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_key(bin_name, key, return_type, ctx=None)

Creates a map_remove_by_key operation to be used with operate or operate_ordered

The operation removes an item, specified by the key from the map stored in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key – The key to be removed from the map
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_key_index_range_relative(bin_name, key, offset, return_type, count=None, inverted=False, ctx=None)

Create a map get by value rank range relative operation

Create map remove by key relative to index range operation. Server removes and returns map items with key nearest to value and greater by relative index. Server returns selected data specified by return_type.

Note

This operation requires server version 4.3.0 or greater.

Examples

Examples for a key ordered map {0: 6, 6: 12, 10: 18, 15: 24} and return type of aerospike.MAP_RETURN_KEY

(value, offset, count) = [removed keys]
(5, 0, None) = [6, 10, 15]
(5, 0, 2) = [6, 10]
(5,-1, None) = [0, 6, 10, 15]
(5, -1, 3) = [0, 6, 10]
(3, 2, None) = [15]
(3, 5, None) = []
Parameters:
  • bin_name (str) – The name of the bin containing the list.
  • key (str) – The key of the item in the list for which to search
  • offset (int) – Begin removing and returning items with rank == rank(fount_item) + offset
  • count (int) – If specified, the number of items to remove and return. If None, all items until end of list are returned.
  • inverted (bool) – If True, the operation is inverted and items outside of the specified range are returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_key_list(bin_name, key_list, return_type, inverted=False, ctx=None)

Creates a map_remove_by_key operation to be used with operate or operate_ordered

The operation removes items, specified by the keys in key_list from the map stored in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key_list (list) – A list of keys to be removed from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If true, keys with values not specified in the key_list will be removed, and those keys specified in the key_list will be kept. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_key_range(bin_name, key_range_start, key_range_end, return_type, inverted=False, ctx=None)

Creates a map_remove_by_key_range operation to be used with operate or operate_ordered

The operation removes items, with keys between key_range_start(inclusive) and key_range_end(exclusive) from the map

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • key_range_start – The start of the range of keys to be removed. (Inclusive)
  • key_range_end – The end of the range of keys to be removed. (Exclusive)
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, values outside of the specified range will be removed, and values inside of the range will be kept. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_rank(bin_name, rank, return_type, ctx=None)

Creates a map_remove_by_rank operation to be used with operate or operate_ordered

The operation removes the item with the specified rank from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • rank (int) – The rank of the entry to remove.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_rank_range(bin_name, rank_start, remove_amt, return_type, inverted=False, ctx=None)

Creates a map_remove_by_rank_range operation to be used with operate or operate_ordered

The operation removes remove_amt items beginning with the item with the specified rank from the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • rank_start (int) – The rank of the entry to remove.
  • remove_amt (int) – The number of entries to remove.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, items with ranks inside the specified range should be kept, and all other entries removed. Default: False.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_value(bin_name, value, return_type, inverted=False, ctx=None)

Creates a map_remove_by_value operation to be used with operate or operate_ordered

The operation removes key value pairs whose value matches the specified value.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value – Entries with a value matching this argument will be removed from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, entries with a value different than the specified value will be removed. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_value_list(bin_name, value_list, return_type, inverted=False, ctx=None)

Creates a map_remove_by_value_list operation to be used with operate or operate_ordered

The operation removes key value pairs whose values are specified in the value_list.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value_list (list) – Entries with a value contained in this list will be removed from the map.
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, entries with a value contained in value_list will be kept, and all others will be removed and returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_value_range(bin_name, value_start, value_end, return_type, inverted=False, ctx=None)

Creates a map_remove_by_value_range operation to be used with operate or operate_ordered

The operation removes items, with values between value_start(inclusive) and value_end(exclusive) from the map

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value_start – The start of the range of values to be removed. (Inclusive)
  • value_end – The end of the range of values to be removed. (Exclusive)
  • return_type (int) – Value specifying what should be returned from the operation. This should be one of the Map Return Types values.
  • inverted (bool) – If True, values outside of the specified range will be removed, and values inside of the range will be kept. Default: False
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_remove_by_value_rank_range_relative(bin_name, value, offset, return_type, count=None, inverted=False, ctx=None)

Create a map remove by value rank range relative operation

Create map remove by value relative to rank range operation. Server removes and returns map items nearest to value and greater by relative rank. Server returns selected data specified by return_type.

Note

This operation requires server version 4.3.0 or greater.

Examples

Examples for map {0: 6, 10: 18, 6: 12, 15: 24} and return type of aerospike.MAP_RETURN_KEY

(value, offset, count) = [removed keys]
(6, 0, None) = [0, 6, 10, 15]
(5, 0, 2) = [0, 6]
(7, -1, 1) = [0]
(7, -1, 3) = [0, 6, 10]
Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • value – The value of the entry in the map for which to search
  • offset (int) – Begin removing and returning items with rank == rank(found_item) + offset
  • count (int) – If specified, the number of items to remove and return. If None, all items with rank greater than found_item are returned.
  • return_type – Specifies what to return from the operation.
  • inverted (bool) – If True, the operation is inverted and items outside of the specified range are returned.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered.The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_set_policy(bin_name, policy, ctx=None)

Creates a map_set_policy_operation to be used with operate or operate_ordered

The operation allows a user to set the policy for the map.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • policy (dict) – The map_policy dictionary.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.map_operations.map_size(bin_name, ctx=None)

Creates a map_size operation to be used with operate or operate_ordered

The operation returns the size of the map stored in the specified bin.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • ctx (list) – An optional list of nested CDT context operations (cdt_cdx object) for use on nested CDTs.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bit_operations module

Helper functions to create bit operation dictionary arguments for the aerospike.Client.operate and aerospike.Client.operate_ordered methods of the aerospike client.

Note

Bitwise operations require server version >= 4.6.0

Bit offsets are oriented left to right. Negative offsets are supported and start backwards from the end of the target bitmap.

Offset examples:
  • 0: leftmost bit in the map
  • 4: fifth bit in the map
  • -1: rightmost bit in the map
  • -4: 3 bits from rightmost

Example:

from __future__ import print_function
import aerospike
from aerospike import exception as ex
from aerospike_helpers.operations import bitwise_operations
import sys

# Configure the client.
config = {"hosts": [("127.0.0.1", 3000)]}

# Create a client and connect it to the cluster.
try:
    client = aerospike.client(config).connect()
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

key = ("test", "demo", "foo")
five_ones_bin_name = "bitwise1"
five_one_blob = bytearray([1] * 5)

# Write the record.
try:
    client.put(key, {five_ones_bin_name: five_one_blob})
except ex.RecordError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))

# EXAMPLE 1: resize the five_ones bin to a bytesize of 10.
try:
    ops = [bitwise_operations.bit_resize(five_ones_bin_name, 10)]

    _, _, bins = client.get(key)
    _, _, _ = client.operate(key, ops)
    _, _, newbins = client.get(key)
    print("EXAMPLE 1: before resize: ", bins)
    print("EXAMPLE 1: is now: ", newbins)
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

# EXAMPLE 2: shrink the five_ones bin to a bytesize of 5 from the front.
try:
    ops = [
        bitwise_operations.bit_resize(
            five_ones_bin_name, 5, resize_flags=aerospike.BIT_RESIZE_FROM_FRONT
        )
    ]

    _, _, bins = client.get(key)
    _, _, _ = client.operate(key, ops)
    _, _, newbins = client.get(key)
    print("EXAMPLE 2: before resize: ", bins)
    print("EXAMPLE 2: is now: ", newbins)
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

# Cleanup and close the connection to the Aerospike cluster.
client.remove(key)
client.close()

"""
EXPECTED OUTPUT:
EXAMPLE 1: before resize:  {'bitwise1': bytearray(b'\x01\x01\x01\x01\x01')}
EXAMPLE 1: is now:  {'bitwise1': bytearray(b'\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00')}
EXAMPLE 2: before resize:  {'bitwise1': bytearray(b'\x01\x01\x01\x01\x01\x00\x00\x00\x00\x00')}
EXAMPLE 2: is now:  {'bitwise1': bytearray(b'\x00\x00\x00\x00\x00')}
"""

Example:

from __future__ import print_function
import aerospike
from aerospike import exception as e
from aerospike_helpers.operations import bitwise_operations

config = {'hosts': [('127.0.0.1', 3000)]}
try:
    client = aerospike.client(config).connect()
except e.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(2)

key = ('test', 'demo', 'bit_example')
five_one_blob = bytearray([1] * 5)
five_one_bin = 'bitwise1'

try:
    if client.exists(key):
        client.remove(key)
    bit_policy = {
        'map_write_mode': aerospike.BIT_WRITE_DEFAULT,
    }
    client.put(
        key,
        {
            five_one_bin: five_one_blob
        }
    )

    # Example 1: read bits
    ops = [
        bitwise_operations.bit_get(five_one_bin, 0, 40)
    ]
    print('=====EXAMPLE1=====')
    _, _, results = client.operate(key, ops)
    print(results)

    # Example 2: modify bits using the 'or' op, then read bits
    ops = [
        bitwise_operations.bit_or(five_one_bin, 0, 8, 1, bytearray([255]), bit_policy),
        bitwise_operations.bit_get(five_one_bin, 0, 40)
    ]
    print('=====EXAMPLE2=====')
    _, _, results = client.operate(key, ops)
    print(results)

    # Example 3: modify bits using the 'remove' op, then read bits'
    ops = [
        bitwise_operations.bit_remove(five_one_bin, 0, 2, bit_policy),
        bitwise_operations.bit_get(five_one_bin, 0, 24)
    ]
    print('=====EXAMPLE3=====')
    _, _, results = client.operate(key, ops)
    print(results)

except e.AerospikeError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))

client.close()

"""
EXPECTED OUTPUT:
=====EXAMPLE1=====
{'bitwise1': bytearray(b'\x01\x01\x01\x01\x01')}
=====EXAMPLE2=====
{'bitwise1': bytearray(b'\xff\x01\x01\x01\x01')}
=====EXAMPLE3=====
{'bitwise1': bytearray(b'\x01\x01\x01')}
"""

See also

Bits (Data Types).

aerospike_helpers.operations.bitwise_operations.bit_add(bin_name, bit_offset, bit_size, value, sign, action, policy=None)

Creates a bit_add_operation to be used with operate or operate_ordered.

Creates a bit add operation. Server adds value to the bin at bit_offset for bit_size. bit_size must <= 64. If Sign is true value will be treated as a signed number. If an underflow or overflow occurs, as_bit_overflow_action is used. Server returns nothing.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will be added.
  • bit_size (int) – How many bits of value to add.
  • value (int) – The value to be added.
  • sign (bool) – True: treat value as signed, False: treat value as unsigned.
  • action (aerospike.constant) – Action taken if an overflow/underflow occurs.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_and(bin_name, bit_offset, bit_size, value_byte_size, value, policy=None)

Creates a bit_and_operation to be used with operate or operate_ordered.

Creates a bit and operation. Server performs an and op with value and bitmap in bin at bit_offset for bit_size. Server returns nothing.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will be modified.
  • bit_size (int) – How many bits of value to and.
  • value_byte_size (int) – Length of value in bytes.
  • value (bytes/byte array) – Bytes to be used in and operation.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_count(bin_name, bit_offset, bit_size)

Creates a bit_count_operation to be used with operate or operate_ordered.

Server returns an integer count of all set bits starting at bit_offset for bit_size bits.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the set bits will begin being counted.
  • bit_size (int) – How many bits will be considered for counting.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_get(bin_name, bit_offset, bit_size)

Creates a bit_get_operation to be used with operate or operate_ordered.

Server returns bits from bitmap starting at bit_offset for bit_size.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being read.
  • bit_size (int) – How many bits to get.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_get_int(bin_name, bit_offset, bit_size, sign)

Creates a bit_get_int_operation to be used with operate or operate_ordered.

Server returns an integer formed from the bits read from bitmap starting at bit_offset for bit_size.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being read.
  • bit_size (int) – How many bits to get.
  • sign (bool) – True: Treat read value as signed. False: treat read value as unsigned.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_insert(bin_name, byte_offset, value_byte_size, value, policy=None)

Creates a bit_insert_operation to be used with operate or operate_ordered.

Server inserts the bytes from value into the bitmap at byte_offset. No value is returned.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • byte_offset (int) – The offset where the bytes will be inserted.
  • value_byte_size (int) – Size of value in bytes.
  • value (bytes/byte array) –
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_lscan(bin_name, bit_offset, bit_size, value)

Creates a bit_lscan_operation to be used with operate or operate_ordered.

Server returns an integer representing the bit offset of the first occurence of the specified value bit. Starts scanning at bit_offset for bit_size. Returns -1 if value not found.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being scanned.
  • bit_size (int) – How many bits to scan.
  • value (bool) – True: look for 1, False: look for 0.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_lshift(bin_name, bit_offset, bit_size, shift, policy=None)

Creates a bit_lshift_operation to be used with operate or operate_ordered.

Server left shifts bitmap starting at bit_offset for bit_size by shift bits. No value is returned.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being shifted.
  • bit_size (int) – The number of bits that will be shifted by shift places.
  • shift (int) – How many bits to shift by.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_not(bin_name, bit_offset, bit_size, policy=None)

Creates a bit_not_operation to be used with operate or operate_ordered.

Server negates bitmap starting at bit_offset for bit_size. No value is returned.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being scanned.
  • bit_size (int) – How many bits to scan.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_or(bin_name, bit_offset, bit_size, value_byte_size, value, policy=None)

Creates a bit_or_operation to be used with operate or operate_ordered.

Creates a bit or operation. Server performs bitwise or with value and bitmap in bin at bit_offset for bit_size. Server returns nothing.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being compared.
  • bit_size (int) – How many bits of value to or.
  • value_byte_size (int) – Length of value in bytes.
  • value (bytes/byte array) – Value to be used in or operation.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_remove(bin_name, byte_offset, byte_size, policy=None)

Creates a bit_remove_operation to be used with operate or operate_ordered.

Remove bytes from bitmap at byte_offset for byte_size.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • byte_offset (int) – Position of bytes to be removed.
  • byte_size (int) – How many bytes to remove.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_resize(bin_name, byte_size, policy=None, resize_flags=<MagicMock id='140318858235128'>)

Creates a bit_resize_operation to be used with operate or operate_ordered.

Change the size of a bytes bin stored in a record on the Aerospike Server.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • byte_size (int) – The new size of the bytes.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
  • resize_flags (int, optional) – Flags modifying the behavior of the resize. This should be constructed by bitwise or’ing together any of the values: Bitwise Resize Flags . e.g. aerospike.BIT_RESIZE_GROW_ONLY | aerospike.BIT_RESIZE_FROM_FRONT default: aerospike.BIT_RESIZE_DEFAULT
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_rscan(bin_name, bit_offset, bit_size, value)

Creates a bit_rscan_operation to be used with operate or operate_ordered.

Server returns an integer representing the bit offset of the last occurence of the specified value bit. Starts scanning at bit_offset for bit_size. Returns -1 if value not found.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being scanned.
  • bit_size (int) – How many bits to scan.
  • value (bool) – True: Look for 1, False: look for 0.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_rshift(bin_name, bit_offset, bit_size, shift, policy=None)

Creates a bit_rshift_operation to be used with operate or operate_ordered.

Server right shifts bitmap starting at bit_offset for bit_size by shift bits. No value is returned.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being shifted.
  • bit_size (int) – The number of bits that will be shifted by shift places.
  • shift (int) – How many bits to shift by.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_set(bin_name, bit_offset, bit_size, value_byte_size, value, policy=None)

Creates a bit_set_operation to be used with operate or operate_ordered.

Set the value on a bitmap at bit_offset for bit_size in a record on the Aerospike Server.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will be set.
  • bit_size (int) – How many bits of value to write.
  • value_byte_size (int) – Size of value in bytes.
  • value (bytes/byte array) – The value to be set.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_subtract(bin_name, bit_offset, bit_size, value, sign, action, policy=None)

Creates a bit_subtract_operation to be used with operate or operate_ordered.

Creates a bit add operation. Server subtracts value from the bits at bit_offset for bit_size. bit_size must <= 64. If sign is true value will be treated as a signed number. If an underflow or overflow occurs, as_bit_overflow_action is used. Server returns nothing.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will be subtracted.
  • bit_size (int) – How many bits of value to subtract.
  • value (int) – The value to be subtracted.
  • sign (bool) – True: treat value as signed, False: treat value as unsigned.
  • action (aerospike.constant) – Action taken if an overflow/underflow occurs.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.bitwise_operations.bit_xor(bin_name, bit_offset, bit_size, value_byte_size, value, policy=None)

Creates a bit_xor_operation to be used with operate or operate_ordered.

Creates a bit and operation. Server performs bitwise xor with value and bitmap in bin at bit_offset for bit_size. Server returns nothing.

Parameters:
  • bin_name (str) – The name of the bin containing the map.
  • bit_offset (int) – The offset where the bits will start being compared.
  • bit_size (int) – How many bits of value to xor.
  • value_byte_size (int) – Length of value in bytes.
  • value (bytes/byte array) – Value to be used in xor operation.
  • policy (dict, optional) – The bit_policy policy dictionary. default: None.
Returns:

A dictionary usable in operate or operate_ordered. The format of the dictionary should be considered an internal detail, and subject to change.

aerospike_helpers.operations.hll_operations module

Helper functions to create HyperLogLog operation dictionary arguments for the aerospike.Client.operate and aerospike.Client.operate_ordered methods of the aerospike client. HyperLogLog bins and operations allow for your application to form fast, reasonable approximations of members in the union or intersection between multiple HyperLogLog bins. HyperLogLog’s estimates are a balance between complete accuracy and efficient savings in space and speed in dealing with extremely large datasets.

Note

HyperLogLog operations require server version >= 4.9.0

Example:

from __future__ import print_function
import sys

import aerospike
from aerospike import exception as ex
from aerospike_helpers.operations import hll_operations as hll_ops
from aerospike_helpers.operations import operations


TEST_NS = "test"
TEST_SET = "demo"
NUM_INDEX_BITS = 12
NUM_MH_BITS = 24

# Configure the client.
config = {"hosts": [("127.0.0.1", 3000)]}

# Create a client and connect it to the cluster.
try:
    client = aerospike.client(config).connect()
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

# Add HLL bins.
customers = ["Amy", "Farnsworth", "Scruffy"]
customer_record_keys = [
    (TEST_NS, TEST_SET, "Amy"),
    (TEST_NS, TEST_SET, "Farnsworth"),
    (TEST_NS, TEST_SET, "Scruffy"),
]
items_viewed = [
    ("item%s" % str(i) for i in range(0, 500)),
    ("item%s" % str(i) for i in range(0, 750)),
    ("item%s" % str(i) for i in range(250, 1000)),
]

for customer, key, items in zip(customers, customer_record_keys, items_viewed):
    ops = [
        operations.write("name", customer),
        hll_ops.hll_add("viewed", list(items), NUM_INDEX_BITS, NUM_MH_BITS),
    ]

    try:
        client.operate(key, ops)
    except ex.ClientError as e:
        print("Error: {0} [{1}]".format(e.msg, e.code))
        sys.exit(1)

# Find out how many items viewed Amy, Farnsworth, and Scruffy have in common.
Farnsworth_viewed = client.get(customer_record_keys[1])[2]["viewed"]
Scruffy_viewed = client.get(customer_record_keys[2])[2]["viewed"]
viewed = [Farnsworth_viewed, Scruffy_viewed]
ops = [hll_ops.hll_get_intersect_count("viewed", viewed)]

try:
    _, _, res = client.operate(customer_record_keys[0], ops)
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

print(
    "Estimated items viewed intersection: %d."
    % res["viewed"]
)
print("Actual intersection: 250.\n")

# Find out how many unique products Amy, Farnsworth, and Scruffy have viewed.
Farnsworth_viewed = client.get(customer_record_keys[1])[2]["viewed"]
Scruffy_viewed = client.get(customer_record_keys[2])[2]["viewed"]
viewed = [Farnsworth_viewed, Scruffy_viewed]
ops = [hll_ops.hll_get_union_count("viewed", viewed)]

try:
    _, _, res = client.operate(customer_record_keys[0], ops)
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

print(
    "Estimated items viewed union: %d."
    % res["viewed"]
)
print("Actual union: 1000.\n")

# Find the similarity of Amy, Farnsworth, and Scruffy's product views.
Farnsworth_viewed = client.get(customer_record_keys[1])[2]["viewed"]
Scruffy_viewed = client.get(customer_record_keys[2])[2]["viewed"]
viewed = [Farnsworth_viewed, Scruffy_viewed]
ops = [hll_ops.hll_get_similarity("viewed", viewed)]

try:
    _, _, res = client.operate(customer_record_keys[0], ops)
except ex.ClientError as e:
    print("Error: {0} [{1}]".format(e.msg, e.code))
    sys.exit(1)

print(
    "Estimated items viewed similarity: %f%%."
    % (res["viewed"] * 100)
)
print("Actual similarity: 25%.")

"""
Expected output:
Estimated items viewed intersection: 235.
Actual intersection: 250.

Estimated items viewed union: 922.
Actual union: 1000.

Estimated items viewed similarity: 25.488069%.
Actual similarity: 25%.
"""
aerospike_helpers.operations.hll_operations.hll_add(bin_name, values, index_bit_count=None, mh_bit_count=None, policy=None)

Creates a hll_add operation to be used with operate, or operate_ordered.

Server will add the values to the hll bin. If the HLL bin does not exist, it will be created with index_bit_count and/or mh_bit_count if they have been supplied.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • values – The values to be added to the HLL set.
  • index_bit_count – An optional number of index bits. Must be bewtween 4 and 16 inclusive.
  • mh_bit_count – An optional number of min hash bits. Must be bewtween 4 and 58 inclusive.
  • policy (dict) – An optional dictionary of hll policy options.
aerospike_helpers.operations.hll_operations.hll_describe(bin_name)

Creates a hll_describe operation to be used with operate, or operate_ordered.

Server returns index and minhash bit counts used to create HLL bin in a list of integers. The list size is 2.

Parameters:bin_name (str) – The name of the bin to be operated on.
aerospike_helpers.operations.hll_operations.hll_fold(bin_name, index_bit_count)

Creates a hll_fold operation to be used with operate, or operate_ordered.

Servers folds index_bit_count to the specified value. This can only be applied when minhash bit count on the HLL bin is 0. Server does not return a value.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index_bit_count – number of index bits. Must be bewtween 4 and 16 inclusive.
aerospike_helpers.operations.hll_operations.hll_get_count(bin_name)

Creates a hll_get_count operation to be used with operate, or operate_ordered.

Server returns estimated count of elements in the HLL bin.

Parameters:bin_name (str) – The name of the bin to be operated on.
aerospike_helpers.operations.hll_operations.hll_get_intersect_count(bin_name, hll_list)

Creates a hll_get_intersect_count operation to be used with operate, or operate_ordered.

Server returns estimate of elements that would be contained by the intersection of these HLL objects.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • hll_list (list) – The HLLs to be intersected.
aerospike_helpers.operations.hll_operations.hll_get_similarity(bin_name, hll_list)

Creates a hll_get_similarity operation to be used with operate, or operate_ordered.

Server returns estimated similarity of the HLL objects. Server returns a float.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • hll_list (list) – The HLLs used for similarity estimation.
aerospike_helpers.operations.hll_operations.hll_get_union(bin_name, hll_list)

Creates a hll_get_union operation to be used with operate, or operate_ordered.

Server returns an HLL object that is the union of all specified HLL objects in hll_list with the HLL bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • hll_list (list) – The HLLs to be unioned.
aerospike_helpers.operations.hll_operations.hll_get_union_count(bin_name, hll_list)

Creates a hll_get_union_count operation to be used with operate, or operate_ordered.

Server returns the estimated count of elements that would be contained by the union of all specified HLL objects in the list with the HLL bin.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • hll_list (list) – The HLLs to be unioned.
aerospike_helpers.operations.hll_operations.hll_init(bin_name, index_bit_count=None, mh_bit_count=None, policy=None)

Creates a hll_init operation to be used with operate, or operate_ordered.

Server creates a new HLL or resets an existing HLL. If index_bit_count and mh_bit_count are None, an existing HLL bin will be reset but retain its configuration. If 1 of index_bit_count or mh_bit_count are set, an existing HLL bin will set that config and retain its current value for the unset config. If the HLL bin does not exist, index_bit_count is required to create it, mh_bit_count is optional. Server does not return a value.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • index_bit_count – An optional number of index bits. Must be bewtween 4 and 16 inclusive.
  • mh_bit_count – An optional number of min hash bits. Must be bewtween 4 and 58 inclusive.
  • policy (dict) – An optional dictionary of hll policy options.
aerospike_helpers.operations.hll_operations.hll_refresh_count(bin_name)

Creates a hll_refresh_count operation to be used with operate, or operate_ordered.

Server updates the cached count if it is stale. Server returns the count.

Parameters:bin_name (str) – The name of the bin to be operated on.
aerospike_helpers.operations.hll_operations.hll_set_union(bin_name, hll_list, policy=None)

Creates a hll_set_union operation to be used with operate, or operate_ordered.

Server sets the union of all specified HLL objects with the HLL bin. Server returns nothing.

Parameters:
  • bin_name (str) – The name of the bin to be operated on.
  • hll_list (list) – The HLLs who’s union will be set.
  • policy (dict) – An optional dictionary of hll policy options.