[elephant-devel] Re: traversing btree using multiple indices

Sean Ross rosssd at gmail.com
Fri Apr 4 11:56:03 UTC 2008


>  I'm really just curious about using
>  2 btree indices together without requiring the creation of a 3rd.

Of course I could be working against elephant while trying to do all of this.
So here is what I am trying to achieve, any pointers would be great.

Given the following code.

>>
(defpackage :test (:use :cl :elephant :alexandria))

(in-package :test)

(open-store '(:bdb "/tmp/new"))

(defclass event ()
  ((date :initarg :date :initform (get-universal-time))
   (tags :initarg :tags :initform ()))
  (:metaclass persistent-metaclass))

(defvar *events* (make-indexed-btree))

(defun random-tag ()
  (random-elt '("lisp" "humour" "business" "friends" "family")))

(defun random-date ()
  (funcall (if (zerop (random 2)) '+ '-) (get-universal-time) (random 100000)))

(defun populate ()
  (dotimes (x 1000)
    (setf (get-value x *events*)
          (make-instance 'event
                         :date (random-date)
                         :tags (list (format nil "~R" x) (random-tag))))))

<<

What is the best/easiest/most-elephantish way to retrieve all events
in the btree which have the 'lisp' tag and whose date falls on today?


sean.



More information about the elephant-devel mailing list