[elephant-devel] difference between get-instances-by-class and cursors

Robert L. Read read at robertlread.net
Mon Apr 10 02:38:31 UTC 2006


Dear Aycan,

    I will try to answer this more carefully tomorrow morning.
    
    For now just let me say that I have heard there is a bug about keys
not being actually 
removed; I will try to think about this when I have time tomorrow
morning.

    I am not sure what the problem is with the timestamps; but I have
done things very similar
to what you are trying, so I assume we will be able to get it to work.



On Sat, 2006-04-08 at 11:26 +0300, Aycan iRiCAN wrote:

> Hi,
> 
> Firstly, I want to thank you again for this great project.
> 
> Let me ask some questions. What is the difference between using
> get-instances-by-class and using cursors?
> 
> When I use get-instances-by-class I get every instance (including
> deleted keys) of the class. But when I use cursors, I only get
> existing keys.
> 
> HEDEE> (get-instances-by-class 'user)
> (#<USER "test" 3353473039> #<USER "aycan" 3353182543>)
> HEDEE> (remove-kv 5 *hedee-users*)
> T
> HEDEE> (get-instances-by-class 'user)
> (#<USER "test" 3353473039> #<USER "aycan" 3353182543>)
> HEDEE> (with-transaction ()
> 	 (with-btree-cursor (c *hedee-users*)
> 	   (loop
> 	    for (m k v) = (multiple-value-list
> 		           (cursor-first c))
> 	    then (multiple-value-list (cursor-next c))
> 	    while m      
> 	    collect v into users
> 	    finally (return (nreverse users)))))
> (#<USER "aycan" 3353182543>)
> 
> Is it possible to completely remove a key from a btree?
> 
> Say I have a class named user (used above):
> 
> (defclass user ()
>   ((id :accessor id :initarg :id :type integer
>        :initform (next-id)
>        :index t)
>    (name :accessor name :initarg :name
> 	 :initform nil :index t)
>    (epitaph :accessor epitaph :initarg :epitaph
> 	    :initform nil)
>    (image-type :accessor image-type :initarg :image-type :type string
> 	       :initform nil)
>    (timestamp :accessor timestamp :initarg :timestamp :type integer :index t
> 	      :initform (get-universal-time)))
>   (:metaclass persistent-metaclass))
> 
> and I created secondary indices via:
> 
> (defun add-indices ()
>   (with-transaction ()
>     (add-index *hedee-users*
> 	       :index-name 'id :key-form '(lambda (s key value)
> 					   (declare (ignore s key))
> 					   (values t (id value))))
>     (add-index *hedee-users*
> 	       :index-name 'name :key-form '(lambda (s key value)
> 					     (declare (ignore s key))
> 					     (values t (name value))))
>     (add-index *hedee-users*
> 	       :index-name 'timestamp :key-form '(lambda (s key value)
> 						  (declare (ignore s key))
> 						  (values t (timestamp value))))))
> 
> I tried to get users with a timestamp around some delta (320000 in
> below) via:
> 
> (get-instances-by-range 'user
>                         (get-index *hedee-users* 'timestamp) 
>                         (get-universal-time) 
>                         (- (get-universal-time) 320000))
> 
> But I'm getting:
> 
> The value 3353473355 is not of type FIXNUM.
> 
> How can I query by range using a timestamp?
> 
> Best Regards,
> 
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20060409/b744eb02/attachment.html>


More information about the elephant-devel mailing list