[elephant-devel] get-instances-by-range oddity

Kevin Raison raison at chatsubo.net
Fri Nov 7 04:14:20 UTC 2008


Given this class defined with elephant-unstable in sbcl 10.22 using 
berkeleydb 4.6:

(defpclass test-class ()
   ((host :accessor host :initarg :host :type string :initform "" :index t)
    (timestamp :accessor timestamp :initarg :timestamp :initform 
(get-universal-time)
               :type integer :index t))
   (:index t))

Can someone help me understand why this works:

CL-USER> (make-instance 'test-class :host "test1" :timestamp 10000000000)
#<TEST-CLASS oid:791>
CL-USER> (get-instances-by-range 'test-class 'timestamp 0 10000000001)
(#<TEST-CLASS oid:791>)

But this does not:
CL-USER> (make-instance 'test-class :host "test1" :timestamp 
(get-universal-time))
#<TEST-CLASS oid:795>
CL-USER> (get-instances-by-range 'test-class 'timestamp 0 
(get-universal-time))
NIL
CL-USER> (get-instances-by-range 'test-class 'timestamp 0 10000000001)
NIL

When (type-of (get-universal-time)) is (INTEGER 0 1152921504606846975)


If I do not drop all instances between the above two command sets, I get 
this:
CL-USER> (make-instance 'test-class :host "test1" :timestamp 10000000000)
#<TEST-CLASS oid:798>
CL-USER> (get-instances-by-range 'test-class 'timestamp 0 10000000001)
(#<TEST-CLASS oid:798>)
CL-USER> (make-instance 'test-class :host "test1" :timestamp 
(get-universal-time))
#<TEST-CLASS oid:799>
CL-USER> (get-instances-by-range 'test-class 'timestamp 0 
(get-universal-time))
(#<TEST-CLASS oid:798>)
CL-USER> (get-instances-by-range 'test-class 'timestamp 0 10000000001)
(#<TEST-CLASS oid:798>)


I have tried a number of variations, including not specifying types in 
the class definition, specifying "number" as the type of timestamp, 
coercing (get-universal-time) to an integer.  Nothing has worked.  Can 
anyone shed light on this for me?  Am I missing something obvious?  The 
hyperspec specifies that universal time "is an absolute time represented 
as a single non-negative integer."  So why would it not be indexed like 
any other integer?

Thanks in advance.

Kevin Raison




More information about the elephant-devel mailing list