Large Ordered List Class — LList¶
Warning
LDT Functionality is deprecated as of version 2.1.2 and will be removed in a future release of the Python Client
LList¶
-
class
aerospike.LList¶ Deprecated since version 2.1.2: See Blog about LDT Removal for more information.
Large Ordered List (LList) is a collection of elements sorted by
keyorder, which is capable of growing unbounded. There are two ways in which an element is sorted and located:Example:
from __future__ import print_function import aerospike from aerospike.exception import * import sys config = { 'hosts': [ ('127.0.0.1', 3000) ] } try: client = aerospike.client(config).connect() except ClientError as e: print("Error: {0} [{1}]".format(e.msg, e.code)) sys.exit(1) key = ('test', 'articles', 'The Number One Soft Drink') tags = client.llist(key, 'tags') try: tags.add("soda") tags.add_many(["slurm","addictive","prizes"]) except LDTError as e: print("Error: {0} [{1}]".format(e.msg, e.code)) print(tags.find_first(2)) print(tags.find_last(3)) print(tags.find_from("addictive", 2)) try: tags.remove("prizes") except: pass client.close()
See also
New in version 1.0.45.
-
add(element[, policy])¶ Add an element to the
LList.Parameters: - element (one of
str,int,list,dict) – the element to add to the large ordered list. - policy (dict) – optional Apply Policies.
Raises: subclass of
LDTError.Note
All elements in a specific large list must be of the same type, subsequent to the first element which sets the key type of the LList.
key = ('test', 'articles', 'star-trek-vs-star-wars') comments = client.llist(key, 'comments') comments.add({'key':'comment-134', 'user':'vulcano', 'parent':'comment-101', 'body': 'wrong!'})
- element (one of
-
add_many(elements[, policy])¶ Add a
listof elements to theLList.Parameters: - elements (list) – a list of elements to add to the large ordered list.
- policy (dict) – optional Apply Policies.
Raises: subclass of
LDTError.Note
All elements in a specific large list must be of the same type, subsequent to the first element which sets the key type of the LList.
-
remove(value[, policy])¶ Remove an element from the
LList.Parameters: Raises: subclass of
LDTError.key = ('test', 'articles', 'star-trek-vs-star-wars') comments = client.llist(key, 'comments') comments.remove({'key':'comment-134'}) tags = client.llist(key, 'tags') tags.remove("tlhIngan Hol")
-
get(value[, policy]) → element¶ Get an element from the
LList.Parameters: - value (one of
str,int,dict) – the value identifying the element to get from the large ordered list. If the type of the elements in the LList is an aerospikemapyou need to provide adictwith a keykeywhose value will be used to explicitly identify the element. - policy (dict) – optional Apply Policies.
Return type: Raises: subclass of
LDTError.key = ('test', 'articles', 'star-trek-vs-star-wars') comments = client.llist(key, 'comments') parent_comment = comments.get({'key':'comment-101'})
- value (one of
-
filter() → [elements]¶ Scan for all elements in the
LList.Returns: a listof elements.Raises: subclass of LDTError.
-
find_first(count[, policy]) → [elements]¶ Get the first count elements in the
LList.Parameters: - count (int) – the number of elements to return from the beginning of the list.
- policy (dict) – optional Apply Policies.
Returns: a
listof elements.Raises: subclass of
LDTError.
-
find_last(count[, policy]) → [elements]¶ Get the last count elements in the
LList.Parameters: - count (int) – the number of elements to return from the end of the list.
- policy (dict) – optional Apply Policies.
Returns: a
listof elements.Raises: subclass of
LDTError.
-
find_from(value, count[, policy]) → [elements]¶ Get count elements from the
LList, starting with the element that matches the specified value.Parameters: - value (one of
str,int,dict) – the value identifying the element from which to start retrieving count elements. If the type of the elements in theLListis an aerospikemapyou need to provide adictwith a keykeyto explicitly identify this element. - count (int) – the number of elements to return from the end of the list.
- policy (dict) – optional Apply Policies.
Returns: a
listof elements.Raises: subclass of
LDTError.- value (one of
-
size([policy]) → int¶ Get the number of elements in the
LList.Parameters: policy (dict) – optional Apply Policies. Return type: intRaises: subclass of LDTError.
-
set_page_size(size[, policy])¶ Set the page size for this
LList.Parameters: - size (int) –
- policy (dict) – optional Apply Policies.
Raises: subclass of
LDTError.Warning
Requires server version >= 3.5.8
-
destroy([policy])¶ Destroy the entire
LList.Parameters: policy (dict) – optional Apply Policies. Raises: subclass of LDTError.
-