[elephant-devel] strange bug related to psets

Ian Eslick eslick at media.mit.edu
Sat May 10 22:41:02 UTC 2008


On May 10, 2008, at 2:46 PM, Clinton Ebadi wrote:

> Ian Eslick <eslick at media.mit.edu> writes:
>
>> Also which version of the elephant tree?  This may be fixed on
>> unstable - there was quite a bit of general cleanup as I made the
>> schema changes.  Today, psets are just a wrapper around btrees -
>> anyone tried to reproduce this using straight btrees instead of  
>> psets?
>
> This is with stable. I tried to use unstable for the program at first,
> but ran into weird issues with objects of different types ending up in
> each others class indices.

Were you using inheritance?  In unstable, a subclass can now be a  
member of it's parent's index.  This is a different behavior than in  
the old branch.  Actually I realized this isn't a good idea.

I've added an :inherit keyword to association, index and derived-index  
slots that enables hierarchical indexing for all subclasses of that  
base class.  You can override the default behavior by shadowing the  
slot in a subclass.  This defaults to nil, so maintains the original  
behavior but allows this new feature.

Default is that each named class has its own index.


ELEPHANT-USER> (defpclass base ()
		 ((inherit :accessor inherit :index t :inherit t :initarg :inherit)
		  (none :accessor none :index t :inherit nil :initarg :none)
		  (num :accessor num :initarg :num)))
#<PERSISTENT-METACLASS BASE>
ELEPHANT-USER> (defpclass sub (base)
		 ())
#<PERSISTENT-METACLASS SUB>

Create some simple test cases

ELEPHANT-USER> (make-instance 'base :inherit 1 :none 1 :num 1)
#<BASE oid:210>
ELEPHANT-USER> (make-instance 'base :inherit 2 :none 2 :num 2)
#<BASE oid:213>
ELEPHANT-USER> (make-instance 'sub :inherit 2 :none 2 :num 2)
#<SUB oid:216>
ELEPHANT-USER> (make-instance 'sub :inherit 3 :none 3 :num 3)
#<SUB oid:214>

Our base class index picks up the subclass instances as well.

ELEPHANT-USER> (get-instances-by-value 'base 'inherit 1)
(#<BASE oid:210>)
ELEPHANT-USER> (get-instances-by-value 'base 'inherit 2)
(#<BASE oid:213> #<SUB oid:216>)
ELEPHANT-USER> (get-instances-by-value 'base 'inherit 3)
(#<SUB oid:214>)

Inherited indexes look the same from all subclasses, we could add an  
option to filter superclasses if you use a subclass classname to  
access an inherited index.

ELEPHANT-USER> (get-instances-by-value 'sub 'inherit 2)
(#<BASE oid:213> #<SUB oid:216>)
ELEPHANT-USER> (get-instances-by-value 'sub 'inherit 3)
(#<SUB oid:214>)

Non-inherited slots create a separate index for each class:

ELEPHANT-USER> (get-instances-by-value 'base 'none 1)
(#<BASE oid:210>)
ELEPHANT-USER> (get-instances-by-value 'base 'none 2)
(#<BASE oid:213>)
ELEPHANT-USER> (get-instances-by-value 'base 'none 3)
NIL
ELEPHANT-USER> (get-instances-by-value 'sub 'none 1)
NIL
ELEPHANT-USER> (get-instances-by-value 'sub 'none 2)
(#<SUB oid:216>)
ELEPHANT-USER> (get-instances-by-value 'sub 'none 3)
(#<SUB oid:214>)


> After switching to derived indices and some manual index generation
> the problems went away. I tried tracking down the problem for an
> hourish but gave up.
>
> I'm just using BDB.
>
> -- 
> <captain_krunk> ntk is currently using "telnet fyodor 25" to send  
> email
> _______________________________________________
> 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