[elephant-devel] inherited indices

Vassilis Radis radisb at gmail.com
Wed Apr 27 12:36:45 UTC 2011


Currently, I do something along the lines of the following on the results on
get-instance[s]-by-XXX functions:

(remove-if #'(lambda (x) (not (member ',class-name (mapcar #'class-name
(sb-mop:class-precedence-list x))))) lst :key #'class-of)
if I want results on the whole inheritance chain, or

(remove-if #'(lambda (x) (not (equal ',class-name x)))) lst :key #'class-of)
if I want result on the specific class.

Now I know that efficiency is the issue here, but my (naive , since I havent
had performance problems yet) response to that is that since the the search
is indexed anyway, does it really matter?
I mean since the complexity of the search is logarithmic wont the separate
hierachical index implementation you propose have diminishing returns? This
is just off the top of my head, dont throw stuff at me if I am saying
something odviously stupid.

Thanks, Vassilis.


On Wed, Apr 27, 2011 at 12:12 AM, Alex Mizrahi <killerstorm at newmail.ru>wrote:

> Index inheritance is a nice feature for the case when you have several
> sub-classes inheriting from a common base class and you want to lookup
> instances by a slot value regadless of the sub-class.
> E.g. if super-from and mega-frob inherit from frob base class you can look
> up any kind of frob by frob-id if it is inherited.
>
> But what's about the case where you want to be able to do queries both
> among
> all subclasses and for a specific sub-class?
>
> id slot is probably a bad example since it is likely to be unique, so let's
> say we have frob-style slot.
>
> Sometimes I want get any kind of frob with a specific style:
>
>  (ele:get-instances-by-value 'frob 'frob-style "vanilla")
>
> Sometimes I want to get instances of a specific class with a certain
> property:
>
>  (ele:get-instances-by-value 'super-frob 'frob-style "vanilla")
>
> But if slot frob-style has inherited index it doesn't matter what specific
> class is passed to get-instances-by-value, it can return frobs and
> mega-frobs even if you're asking for super-frobs.
>
> I think ideally this would be resolved with a new type of 'hierarchical'
> slot indices where instances will be indexed in many indices at once --
> when
> you make super-frob instance it will be indexed by frob-style both in
> super-frob and frob index (and, generally, in all super-classes). In this
> case get-instances-by-... semantics will be cleaner.
>
> But perhaps that would be rather hard to implement.
>
> As a quick fix, maybe we can filter instances on get-instances-by-... or
> map-inverted-index level?
> These functions have information about actual class so filtering instances
> using type-of should be trivial.
>
> Of course that will have sub-optimal performance as more instances will be
> pulled from database.
> But it is better than nothing and it fixes non-intuitive behaviour
> (instances of wrong type are returned if you look at it from API point of
> view).
>
> Users might achieve this functionality using derived indices -- say, normal
> frob-style slot won't have inherited index but derived slot frob-style*
> will
> be inherited and will just mirror frob-style. Thus when you want to lookup
> among all sub-classes you should use frob-style* instead of frob-style.
> But this looks a bit cumbersome in class definitions.
>
>
>
> _______________________________________________
> 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/20110427/3e806e61/attachment.html>


More information about the elephant-devel mailing list