See my prior post for context.

I've been testing a few different approaches and this is the fastest so far=

(de getArticles (W)
   (let Goal
            @Word W
            (select (@Wcs)
               ((word +WordCount @Word))
               (same @Word @Wcs word))))
      (do 25
         (NIL (prove Goal))
         (bind @
            (pr (cons (; @Wcs article) (; @Wcs picoStamp)))
            (unless (flush) (bye)))))

Where the remote ER is:

(class +WordCount +Entity) #
(rel article   (+Ref +Number))
(rel word      (+Aux +Ref +Number) (article))
(rel count     (+Number))
(rel picoStamp (+Ref +Number))

On Thu, May 13, 2010 at 9:12 PM, Henrik Sarvell <> wrote:
> Everything is running smoothly now, I intend to make a write up on the
> wiki this weekend maybe on this.
> One thing first though, since articles are indexed when they're parsed
> and PL isn't doing any kind of sorting automatically on insert then
> they should be sorted by date automatically with the latest articles
> at the end of the database file since I suppose they're just appended?
> How can I simply start walking from the end of the file until I've
> found say 25 matches? This procedure should be the absolutely fastest
> way of getting what I want.
> I know about your iter example earlier and it seems like a good fit if
> it starts walking in the right end?
> On Tue, May 11, 2010 at 9:09 AM, Alexander Burger <> w=
>> On Mon, May 10, 2010 at 11:50:52PM +0200, Henrik Sarvell wrote:
>>> My code simply stops executing (as if waiting for the next entry but
>>> it never gets it) when I run out of entries to fetch, really strange
>>> and a traceAll confirms this, the last output is a call to rd1>.
>> What happens on the remote side, after all entries are sent? If the
>> remote doesn't 'close' (or 'bye'), then the receiving end doesn't know
>> it is done.
>>> This is my rd1>:
>>> (dm rd1> (Sock)
>>> =A0 =A0(or
>>> =A0 =A0 =A0 (in Sock (rd))
>>> =A0 =A0 =A0 (nil
>>> =A0 =A0 =A0 =A0 =A0(close Sock))))
>> This looks all right, but isn't obviously the problem, as it hangs in
>> 'rd'.
>>> (de getArticles (W)
>>> =A0 =A0(for Wc (sortBy> '+Gh (collect 'word '+WordCount W) 'picoStamp)
>>> =A0 =A0 =A0(pr (cons (; Wc article) (; Wc picoStamp)))
>>> =A0 =A0 =A0(unless (flush) (bye))))
>> What happens if you do (bye) after the 'for' loop is done?
>> I assume that 'getArticles' is executed in the (eval @) below
>>> =A0 =A0(task (port (+ *IdxNum 4040))
>>> =A0 =A0 =A0 (let? Sock (accept @)
>>> =A0 =A0 =A0 =A0 =A0(unless (fork)
>>> =A0 =A0 =A0 =A0 =A0 =A0 (in Sock
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(while (rd)
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (sync)
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (out Sock
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(eval @))))
>>> =A0 =A0 =A0 =A0 =A0 =A0 (bye))
>>> =A0 =A0 =A0 =A0 =A0(close Sock)))
>> This looks OK, because (bye) is called after the while loop is done.
>> Perhaps there is something in the way 'getArticles' is invoked here? You
>> could change the second last line to (! bye) and see if it is indeed
>> reached. I would suspect it isn't.
>> Cheers,
>> - Alex
>> --

Reply via email to