[elephant-devel] Collection paging

Mariano Montone marianomontone at gmail.com
Wed Oct 3 22:57:32 UTC 2007


Hello, it's me again :S.

I would like to know how I can access persistent collection pages
efficiently.

What I'm trying to do is making work a web list component with elephant. The
list component is supposed to support well known navigation commands, like
look at the collection in pages, support for first, last, next, previous
buttons, and display of collection size.

The collection size problem was treated here:
http://common-lisp.net/pipermail/elephant-devel/2007-October/001162.html.

But now I have a problem with building the pages.

My first try was:
  (let*
      ((start (* (current-page self) (page-size self)))
       (end (+ start (page-size self)))
       )
        (<:ul
         (elephant:map-btree #'(lambda (key elem) (declare (ignore key))
                       (let ((elem-text (make-elem-text self elem)))
                         (<:li
                          (if (slot-value self 'selectable)
                          (<ucw:a :action (answer elem)  (<:as-html
elem-text))
                          (<:a (<:as-html elem-text))))))
                 (model self) :start start :end end)
         )

with start and end previously fixed based in the current page number and
size.

But I realized indexes were not sequential when I created new objects, as
this shows:

ASKIT> (with-btree-cursor (cursor (find-class-index 'user))
  (iter
    (for (values exists? k v) = (cursor-next cursor))
    (while exists?)
    (format *standard-output* "~A -> ~A ~%" k v)))
2 -> #<USER name: dssdf {B043379}>
3 -> #<USER name: ttttt {B045C69}>
5 -> #<USER name: ff {B048179}>
6 -> #<USER name: other {B04A451}>
7 -> #<USER name: guest {AD61271}>
100 -> #<USER name: qqq {B053001}>
101 -> #<USER name:  {B055721}>
102 -> #<USER name:  {B057E01}>
103 -> #<USER name:  {B05A529}>
104 -> #<USER name:  {B05CCF1}>
105 -> #<USER name:  {B05F579}>
106 -> #<USER name:  {B063E91}>
107 -> #<USER name: qqq {B066851}>
200 -> #<USER name:  {B069519}>
201 -> #<USER name:  {B06C009}>
300 -> #<USER name:  {B06EBA1}>
301 -> #<USER name: aaa {B0717D1}>
NIL

I don't think this is a bug, it must have to do with how Elephant manages
btrees; but then how am I supposed to access through pages?
I would like to have to access all the objects from the beggining just to
discard them instantly (imagine a large collection and the user wanting to
see the last page).

Thank you again :)

Mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20071003/aed3d231/attachment.html>


More information about the elephant-devel mailing list