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 key order, which is capable of growing unbounded. There are two ways in which an element is sorted and located:

  • Implied key for the types str and int, where the value itself is used as the element’s key.
  • Explicit key for dict where a key named key must exist, and will be used to identify the element. A list acts as a batch of similarly-typed elements, either str, int, or dict.

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

Large Ordered List.

New in version 1.0.45.

add(element[, policy])

Add an element to the LList.

Parameters:
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!'})
add_many(elements[, policy])

Add a list of elements to the LList.

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:
  • value (one of str, int, dict) – the value identifying the element to remove from the large ordered list. If the type of the elements in the LList is an aerospike map you need to provide a dict with a key key to explicitly identify the element.
  • policy (dict) – optional Apply Policies.
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 aerospike map you need to provide a dict with a key key whose value will be used to explicitly identify the element.
  • policy (dict) – optional Apply Policies.
Return type:

one of str, int, dict.

Raises:

subclass of LDTError.

key = ('test', 'articles', 'star-trek-vs-star-wars')
comments = client.llist(key, 'comments')
parent_comment = comments.get({'key':'comment-101'})
filter() → [elements]

Scan for all elements in the LList.

Returns:a list of 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 list of 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 list of 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 the LList is an aerospike map you need to provide a dict with a key key to 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 list of elements.

Raises:

subclass of LDTError.

size([policy]) → int

Get the number of elements in the LList.

Parameters:policy (dict) – optional Apply Policies.
Return type:int
Raises:subclass of LDTError.
set_page_size(size[, policy])

Set the page size for this LList.

Parameters:
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.