Next: , Previous: Persistent Object API, Up: User API Reference


5.3 Persistent Object Indexing

5.3.1 Indexed Object Accessors

— Function: elephant:map-class fn class &key collect

Perform a map operation over all instances of class. Takes a function of one argument, a class instance. Setting the collect keyword to true will return a list of the values returned from calls to fn on successive instances of the class.

— Function: elephant:map-inverted-index fn class index &rest args &key start end value from-end collect

map-inverted-index maps a function of two variables, taking key and instance, over a subset of class instances in the order defined by the index. Specify the class and index by quoted name. The index may be a slot index or a derived index.

Read the docstring for map-index for details on what the various keywords do.

— Generic Function: elephant:get-instances-by-class class

Retrieve all instances from the class index as a list of objects

— Generic Function: elephant:get-instance-by-value class slot-name value

Retrieve instances from a slot index by value. Will return only the first instance if there are duplicates.

— Generic Function: elephant:get-instances-by-value class slot-name value

Returns a list of all instances where the slot value is equal to value.

— Generic Function: elephant:get-instances-by-range class idx-name start end

Returns a list of all instances that match values between start and end. An argument of nil to start or end indicates, respectively, the lowest or highest value in the index

— Function: elephant:drop-instances instances &key sc

Removes a list of persistent objects from all class indices and unbinds any slot values

5.3.2 Direct Class Index Manipulation

— Generic Function: elephant:find-class-index class &key errorp sc

This method is the way to access the class index via the class object. We can always fetch it or we can cache it in the class itself. It returns an indexed-btree.

— Generic Function: elephant:find-inverted-index class slot &key null-on-fail

This method finds an inverted index defined on the class described by an instance of persistent-metaclass.

— Generic Function: elephant:make-class-cursor class

Define a cursor over all class instances

— Macro: elephant:with-class-cursor var &body body

Bind the var argument in the body to a class cursor on the index specified the provided class or class name

— Generic Function: elephant:make-inverted-cursor class name

Define a cursor on the inverted (slot or derived) index

— Macro: elephant:with-inverted-cursor var &body body

Bind the var argument to an inverted cursor on the index specified the provided class and index name

5.3.3 Dynamic Indexing API

— Generic Function: elephant:enable-class-indexing class indexed-slot-names &key sc

Enable a class instance index for this object. It's an expensive thing to support on writes so know that you need it before you do it.

— Generic Function: elephant:disable-class-indexing class &key errorp sc

Delete and remove class instance indexing and any secondary indices defined against it

— Method: elephant:disable-class-indexing (class persistent-metaclass) &key (sc *store-controller*) (errorp nil)

Disable any class indices from the database, even if the current class object is not officially indexed. This ensures there is no persistent trace of a class index. Storage is reclaimed also

— Generic Function: elephant:add-class-slot-index class slot-name &key update-class populate sc

Add a per-slot class index option to the class index based on the class accessor method

— Generic Function: elephant:remove-class-slot-index class slot-name &key update-class sc

Remove the per-slot index from the db

— Generic Function: elephant:add-class-derived-index class name derived-defun &key update-class sc populate

Add a simple secondary index to this class based on a function that computes a derived parameter. warning: derived parameters are only valid on persistent slots. An arbitrary function here will fail to provide consistency on transient slots or global data that is not stored in the persistent store. Derived indexes are deleted and rebuilt when a class is redefined

— Generic Function: elephant:remove-class-derived-index class name &key update-class sc

Remove a derived index by providing the derived name used to name the derived index