[elephant-devel] get-instances-by-range oddity
Ian Eslick
eslick at media.mit.edu
Sat Nov 8 05:55:42 UTC 2008
I can reproduce this, the serializer is treating this value as a
bignum but the range value as a fixnum so the berkeley-db comparison
function doesn't compare them properly. I'm not sure yet if what is
happening has to do with the lisp type system or the innards of
Elephant...
Turns out your timing was excellent as I'm depending on this
capability for a feature I'm rolling out this weekend, actually.
Ian
On Nov 6, 2008, at 11:14 PM, Kevin Raison wrote:
> 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
>
> _______________________________________________
> elephant-devel site list
> elephant-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/elephant-devel
More information about the elephant-devel
mailing list