Skip to content

Latest commit

 

History

History
215 lines (144 loc) · 7.77 KB

llist.rst

File metadata and controls

215 lines (144 loc) · 7.77 KB

aerospike

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

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()

1.0.45

add(element[, policy])

Add an element to the LList.

param element

the element to add to the large ordered list.

type element

one of str, int, list, dict

param dict policy

optional aerospike_apply_policies.

raises

subclass of ~aerospike.exception.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.

param list elements

a list of elements to add to the large ordered list.

param dict policy

optional aerospike_apply_policies.

raises

subclass of ~aerospike.exception.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.

param value

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.

type value

one of str, int, dict

param dict policy

optional aerospike_apply_policies.

raises

subclass of ~aerospike.exception.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.

param value

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.

type value

one of str, int, dict

param dict policy

optional aerospike_apply_policies.

rtype

one of str, int, dict.

raises

subclass of ~aerospike.exception.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.

return

a list of elements.

raises

subclass of ~aerospike.exception.LDTError.

find_first(count[, policy]) -> [elements]

Get the first count elements in the LList.

param int count

the number of elements to return from the beginning of the list.

param dict policy

optional aerospike_apply_policies.

return

a list of elements.

raises

subclass of ~aerospike.exception.LDTError.

find_last(count[, policy]) -> [elements]

Get the last count elements in the LList.

param int count

the number of elements to return from the end of the list.

param dict policy

optional aerospike_apply_policies.

return

a list of elements.

raises

subclass of ~aerospike.exception.LDTError.

find_from(value, count[, policy]) -> [elements]

Get count elements from the LList, starting with the element that matches the specified value.

param value

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.

type value

one of str, int, dict

param int count

the number of elements to return from the end of the list.

param dict policy

optional aerospike_apply_policies.

return

a list of elements.

raises

subclass of ~aerospike.exception.LDTError.

size([policy]) -> int

Get the number of elements in the LList.

param dict policy

optional aerospike_apply_policies.

rtype

int

raises

subclass of ~aerospike.exception.LDTError.

set_page_size(size, [policy])

Set the page size for this LList.

param int size
param dict policy

optional aerospike_apply_policies.

raises

subclass of ~aerospike.exception.LDTError.

Warning

Requires server version >= 3.5.8

destroy([policy])

Destroy the entire LList.

param dict policy

optional aerospike_apply_policies.

raises

subclass of ~aerospike.exception.LDTError.