Sorry for the spam but the prior listing is not correct, it didn't
manage to return sorted by date, this one does though:

(de getArticles (W)
   (let Goal
      (goal
         (quote
            @Word W
            @Date (cons (- (stamp> '+Gh) (* 6 31 86400)) (stamp> '+Gh))
            (select (@Wcs)
               ((picoStamp +WordCount @Date) (word +WordCount @Word))
               (same @Word @Wcs word)
               (range @Date @Wcs picoStamp))))
      (do 25
         (NIL (prove Goal))
         (bind @
            (pr (cons (; @Wcs article) (; @Wcs picoStamp)))
            (unless (flush) (bye)))))
   (bye))



On Thu, May 13, 2010 at 9:36 PM, Henrik Sarvell <hsarv...@gmail.com> wrote:
> See my prior post for context.
>
> I've been testing a few different approaches and this is the fastest so f=
ar:
>
> (de getArticles (W)
> =A0 (let Goal
> =A0 =A0 =A0(goal
> =A0 =A0 =A0 =A0 (quote
> =A0 =A0 =A0 =A0 =A0 =...@word W
> =A0 =A0 =A0 =A0 =A0 =A0(select (@Wcs)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((word +WordCount @Word))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (same @Word @Wcs word))))
> =A0 =A0 =A0(do 25
> =A0 =A0 =A0 =A0 (NIL (prove Goal))
> =A0 =A0 =A0 =A0 (bind @
> =A0 =A0 =A0 =A0 =A0 =A0(pr (cons (; @Wcs article) (; @Wcs picoStamp)))
> =A0 =A0 =A0 =A0 =A0 =A0(unless (flush) (bye)))))
> =A0 (bye))
>
> Where the remote ER is:
>
> (class +WordCount +Entity) #
> (rel article =A0 (+Ref +Number))
> (rel word =A0 =A0 =A0(+Aux +Ref +Number) (article))
> (rel count =A0 =A0 (+Number))
> (rel picoStamp (+Ref +Number))
>
>
>
> On Thu, May 13, 2010 at 9:12 PM, Henrik Sarvell <hsarv...@gmail.com> wrot=
e:
>> 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 <a...@software-lab.de> =
wrote:
>>> 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? Yo=
u
>>> could change the second last line to (! bye) and see if it is indeed
>>> reached. I would suspect it isn't.
>>>
>>> Cheers,
>>> - Alex
>>> --
>>> UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=3dunsubscribe
>>>
>>
>
-- 
UNSUBSCRIBE: mailto:picol...@software-lab.de?subject=unsubscribe

Reply via email to