Next: BTree Cursor API, Previous: Persistent Set API, Up: User API Reference
Persistent collections inherit from Class elephant:persistent-collection and consist of the Class elephant:btree, Class elephant:indexed-btree and Class elephant:btree-index classes. The following operations are defined on most of these classes. More information can be found in Persistent BTrees and BTree Indexing.
Constructs a new BTree instance for use by the user. Each backend returns its own internal type as appropriate and ensures that the btree is associated with the store-controller that created it.
Values are written to a btree using the setf
method on get-value
.
Remove a key / value from the
primary
by a secondary lookup, updatingall
other secondary indices.
Delete all key-value pairs from the btree and render it an invalid object in the data store
Map btree maps over a btree from the value start to the value of end. If values are not provided, then it maps over all values. BTrees do not have duplicates, but map-btree can also be used with indices in the case where you don't want access to the primary key so we require a value argument as well for mapping duplicate value sets. The collect keyword will accumulate the results from each call of fn in a fresh list and return that list in the same order the calls were made (first to last).
These functions are only defined on indexed btrees.
Constructs a new indexed BTree instance for use by the user. Each backend returns its own internal type as appropriate and ensures that the btree is associated with the store-controller that created it.
Add a secondary index. The indices are stored in an eq hash-table, so the index-name should be a symbol. key-form should be a symbol naming a function, or a list which defines a lambda
--
actual functions aren't supported. The function should take 3 arguments: the secondarydb
, primary key and value, and return two values: a boolean indicating whether to index this key / value, and the secondary key if so. If populate = t it will fill in secondary keys for existing primary entries (may be expensive!)
This function is only valid for indexes.
Map-index is like map-btree but for secondary indices, it takes a function of three arguments: key, value and primary key. As with map-btree the keyword arguments start and end determine the starting element and ending element, inclusive. Also, start = nil implies the first element, end = nil implies the last element in the index. If you want to traverse only a set of identical key values, for example all nil values, then use the value keyword which will override any values of start and end. The collect keyword will accumulate the results from each call of fn in a fresh list and return that list in the same order the calls were made (first to last)