When serializing tuples, is the string representation best: You suggest using (format t "~A ~A" a b) - is that efficient enough? what about doing (cons a b) = is there a way to index and search for conses? Any other ideas?<br>
<br>Yarek<br><br><div class="gmail_quote">On Tue, Jan 6, 2009 at 5:17 AM, Alex Mizrahi <span dir="ltr"><<a href="mailto:killerstorm@newmail.ru">killerstorm@newmail.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
YK> Is this a reasonable way of finding an object of type<br>
YK> 'my-class that matches on values val-a and val-b for slots a and b?<br>
<br>
yep, it is reasonable if you have relatively low number of objects<br>
in returned by (get-instances-by-value 'my-class 'slot-b val-b) query.<br>
if number of objects is significant and you get a slowdown because<br>
of this, you might want to optimize this. a trivial thing is to try it<br>
symmertrically with slot-a -- whatever returns less objects is better.<br>
less trivial optimizations would be to work on lower-level -- via<br>
map-inverted-index (to avoid allocating whole list but instead test objects<br>
one by one) or even cursor API (this way you can retrieve oids rather<br>
than objects, which should be faster, and also iterating both indices at<br>
once might be a significant benefit if values are not uniformly<br>
distributed).<br>
<br>
but the most optimal way doing this in case of high number of objects<br>
in both slot-a and slot-b queries would be building and using multi-column<br>
index. unfortunately, Elephant does not help you with it -- either you'll<br>
have<br>
to serialize slot tuples into a string (e.g (format nil "~a_~a" slot-a<br>
slot-b)),<br>
or reorganize your data to use a custom index structure (like btree of<br>
btrees).<br>
<br>
there are also backend-specific considerations. for postmodern<br>
<br>
(intersection (get-instances-by-value 'my-class 'slot-b val-b)<br>
(get-instances-by-value 'my-class 'slot-a val-a))<br>
<br>
would be much faster then testing objects one by one, for BDB -- i doubt so.<br>
<br>
LP> Use MAP-CLASS, this will considerably speed up the query.<br>
<br>
how is that? using at least one index is much better than using no index at<br>
all.<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
<br>
_______________________________________________<br>
elephant-devel site list<br>
<a href="mailto:elephant-devel@common-lisp.net">elephant-devel@common-lisp.net</a><br>
<a href="http://common-lisp.net/mailman/listinfo/elephant-devel" target="_blank">http://common-lisp.net/mailman/listinfo/elephant-devel</a><br>
</div></div></blockquote></div><br>