How Mnemosyne cursors are used ?

Massimo Cesaro massimo.cesaro@REDACTED
Wed Nov 12 10:16:05 CET 2003


On Wed, 2003-11-12 at 09:57, Sean Hinde wrote:
> Check out ets:select in all its forms which allows you to retrieve a 
> table in chunks. The match syntax would certainly allow you to 
> formulate the query you have here. Also check out ets:fun2ms which 
> allows easy generation of the match code.
> 
I used ets:select and also considered using ets:fun2ms, but what I'd
like to avoid is rewriting persistent cursors logic.
I'm doing the query from a Yaws page. It is a report where I can define
a start date, an end date and the number of lines per page.
Then the page is dynamically generated from Yaws, and each time I click
the "Next" button on the web page, the idea was to pass the cursor state
as a cookie to continue returning records. I thought of using Mnemosyne
queries as well, but the requirement of initialising the query with
mnemosyne:init_query/1 each time render useless this method as well.
My aim is to allow for a report-like functionality from a Yaws
application, hence the integration between Yaws and ets/Mnesia would
avoid the need to export the records to another dbms and and use another
web server (I'm becoming an Erlang addict!).
The number of record I expect to handle is relatively small (less than
5000), the function is just a call trace log.
> e.g
> 
> ets:fun2ms(#cdr{date = Date, result = Res}) when (Date >= StartDate) 
> and (Date =< EndDate) and (Res == Result) -> true;
>            (_) -> false
>           end).
> 
> (Untested, though based on running code in one of my systems).
> 
> Sean
> 
Thanks,
Massimo





More information about the erlang-questions mailing list