Skip to content

Commit

Permalink
Merge pull request #223 from aerospike/3.4.1-in-progress
Browse files Browse the repository at this point in the history
3.4.1 in progress
  • Loading branch information
aerospikerobertmarks committed Aug 15, 2018
2 parents 09d3b0e + f1a86b1 commit c0976ce
Show file tree
Hide file tree
Showing 18 changed files with 1,489 additions and 178 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.0
3.4.1
107 changes: 107 additions & 0 deletions aerospike_helpers/operations/list_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,3 +828,110 @@ def list_sort(bin_name, sort_flags=aerospike.LIST_SORT_DEFAULT):
}

return op_dict


def list_get_by_value_rank_range_relative(bin_name, value, offset, return_type, count=None,
inverted=False):
"""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]
Args:
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.
Returns:
A dictionary usable in operate or operate_ordered.The format of the dictionary
should be considered an internal detail, and subject to change.
"""
op_dict = {
OP_KEY: aerospike.OP_LIST_GET_BY_VALUE_RANK_RANGE_REL,
BIN_KEY: bin_name,
VALUE_KEY: value,
RANK_KEY: offset,
RETURN_TYPE_KEY: return_type,
INVERTED_KEY: inverted
}
if count is not None:
op_dict[COUNT_KEY] = count

return op_dict


def list_remove_by_value_rank_range_relative(bin_name, value, offset, return_type, count=None,
inverted=False):
"""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]
Args:
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.
Returns:
A dictionary usable in operate or operate_ordered.The format of the dictionary
should be considered an internal detail, and subject to change.
"""
op_dict = {
OP_KEY: aerospike.OP_LIST_REMOVE_BY_VALUE_RANK_RANGE_REL,
BIN_KEY: bin_name,
VALUE_KEY: value,
RANK_KEY: offset,
RETURN_TYPE_KEY: return_type,
INVERTED_KEY: inverted

}
if count is not None:
op_dict[COUNT_KEY] = count

return op_dict
222 changes: 222 additions & 0 deletions aerospike_helpers/operations/map_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
RETURN_TYPE_KEY = "return_type"
INVERTED_KEY = "inverted"
RANGE_KEY = "range"
COUNT_KEY = "count"
RANK_KEY = "rank"


def map_set_policy(bin_name, policy):
Expand Down Expand Up @@ -692,3 +694,223 @@ def map_get_by_rank_range(bin_name, rank_start, get_amt, return_type, inverted=F
}

return op_dict

def map_remove_by_value_rank_range_relative(
bin_name, value, offset, return_type, count=None, inverted=False):
"""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]
Args:
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.
Returns:
A dictionary usable in operate or operate_ordered.The format of the dictionary
should be considered an internal detail, and subject to change.
"""
op_dict = {
OP_KEY: aerospike.OP_MAP_REMOVE_BY_VALUE_RANK_RANGE_REL,
BIN_KEY: bin_name,
VALUE_KEY: value,
RANK_KEY: offset,
RETURN_TYPE_KEY: return_type

}
if count is not None:
op_dict[COUNT_KEY] = count

if inverted:
op_dict[INVERTED_KEY] = True

return op_dict


def map_get_by_value_rank_range_relative(
bin_name, value, offset, return_type, count=None, inverted=False):
"""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]
Args:
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.
Returns:
A dictionary usable in operate or operate_ordered.The format of the dictionary
should be considered an internal detail, and subject to change.
"""
op_dict = {
OP_KEY: aerospike.OP_MAP_GET_BY_VALUE_RANK_RANGE_REL,
BIN_KEY: bin_name,
VALUE_KEY: value,
RANK_KEY: offset,
RETURN_TYPE_KEY: return_type

}
if count is not None:
op_dict[COUNT_KEY] = count

if inverted:
op_dict[INVERTED_KEY] = True

return op_dict


def map_remove_by_key_index_range_relative(
bin_name, value, offset, return_type, count=None, inverted=False):
"""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) = []
Args:
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.
Returns:
A dictionary usable in operate or operate_ordered.The format of the dictionary
should be considered an internal detail, and subject to change.
"""
op_dict = {
OP_KEY: aerospike.OP_MAP_REMOVE_BY_KEY_INDEX_RANGE_REL,
BIN_KEY: bin_name,
KEY_KEY: value,
INDEX_KEY: offset,
RETURN_TYPE_KEY: return_type

}
if count is not None:
op_dict[COUNT_KEY] = count

if inverted:
op_dict[INVERTED_KEY] = True

return op_dict


def map_get_by_key_index_range_relative(
bin_name, value, offset, return_type, count=None, inverted=False):
"""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) = []
Args:
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.
Returns:
A dictionary usable in operate or operate_ordered.The format of the dictionary
should be considered an internal detail, and subject to change.
"""
op_dict = {
OP_KEY: aerospike.OP_MAP_GET_BY_KEY_INDEX_RANGE_REL,
BIN_KEY: bin_name,
KEY_KEY: value,
INDEX_KEY: offset,
RETURN_TYPE_KEY: return_type

}
if count is not None:
op_dict[COUNT_KEY] = count

if inverted:
op_dict[INVERTED_KEY] = True

return op_dict

0 comments on commit c0976ce

Please sign in to comment.