• efficient searchs

    From Ragnarok@VERT/DOCKSUD to DOVE-Net.Sync_JavaScript on Friday, November 25, 2005 17:29:00
    hi !
    i begin to play with js
    i try to search in message base, but search one to one is poor performance
    do you have another code that search in the base with more speed?
    maybe some method more optimized?
    a global menssage base index?
    a gift from google? :)

    for (grp in msg_area.grp_list) {
    for (sub in msg_area.grp_list[grp].sub_list) {
    msg = new MsgBase(msg_area.grp_list[grp].sub_list[sub].code);
    if (msg.open()) {
    for (i=0;i< msg.total_msgs;i++) {
    mensaje = msg.get_msg_header(true,i);
    if (mensaje != null) {
    if (mensaje.subject.indexOf("hola") >= 0) {
    writeln(mensaje.from);
    writeln("<br />");
    writeln(mensaje.subject);
    writeln("<br />");
    }
    }
    else
    writeln ("error getting message");
    }
    msg.close();
    }
    else {
    writeln ("Error al abrir la base de mensajes: " + msg_base.grp_list[grp].
    }
    }
    }

    ---
    þ Synchronet þ Dock Sud BBS TLD 24 HS - www.docksud.com.ar
  • From Digital Man@VERT to Ragnarok on Sunday, November 27, 2005 01:19:13
    Re: efficient searchs
    By: Ragnarok to DOVE-Net.Sync_JavaScript on Fri Nov 25 2005 05:29 pm

    hi !
    i begin to play with js
    i try to search in message base, but search one to one is poor performance do you have another code that search in the base with more speed?
    maybe some method more optimized?
    a global menssage base index?
    a gift from google? :)

    for (grp in msg_area.grp_list) {
    for (sub in msg_area.grp_list[grp].sub_list) {
    msg = new MsgBase(msg_area.grp_list[grp].sub_list[sub].code);
    if (msg.open()) {
    for (i=0;i< msg.total_msgs;i++) {
    mensaje = msg.get_msg_header(true,i);
    if (mensaje != null) {
    if (mensaje.subject.indexOf("hola") >= 0) {
    writeln(mensaje.from);
    writeln("<br />");
    writeln(mensaje.subject);
    writeln("<br />");
    }
    }
    else
    writeln ("error getting message");
    }
    msg.close();
    }
    else {
    writeln ("Error al abrir la base de mensajes: " + msg_base.grp_list[grp].
    }
    }
    }

    Your script seems to just search the message subjects. This is slow?

    digital man

    Snapple "Real Fact" #176:
    The first bike was called a hobbyhorse.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Ragnarok@VERT/DOCKSUD to Digital Man on Sunday, November 27, 2005 19:55:00
    Digital Man wrote:

    Re: efficient searchs
    By: Ragnarok to DOVE-Net.Sync_JavaScript on Fri Nov 25 2005 05:29 pm

    msg.close();
    }
    else {
    writeln ("Error al abrir la base de mensajes: " + msg_base.grp_list[grp].
    }
    }
    }

    Your script seems to just search the message subjects. This is slow?

    digital man
    my idea is search in to body of messages too(in future), to put it into a
    web page, but i think to this will be more slow
    i can export the msgbase in timed events to mysql engine or make a cgi in
    c++ usign the msgbase api, but i dont know. i searching for ideas =?

    ---
    þ Synchronet þ Dock Sud BBS TLD 24 HS - www.docksud.com.ar
  • From Digital Man@VERT to Ragnarok on Sunday, November 27, 2005 15:19:14
    Re: Re: efficient searchs
    By: Ragnarok to Digital Man on Sun Nov 27 2005 07:55 pm

    Digital Man wrote:

    Re: efficient searchs
    By: Ragnarok to DOVE-Net.Sync_JavaScript on Fri Nov 25 2005 05:29 pm

    msg.close();
    }
    else {
    writeln ("Error al abrir la base de mensajes: " + msg_base.grp_list[grp].
    }
    }
    }

    Your script seems to just search the message subjects. This is slow?

    digital man
    my idea is search in to body of messages too(in future), to put it into a web page, but i think to this will be more slow
    i can export the msgbase in timed events to mysql engine or make a cgi in c++ usign the msgbase api, but i dont know. i searching for ideas =?

    I don't think any of that will be necessary.

    Here's a variation on your script:

    // search.js
    // usage: jsexec search.js <msgbase_code> <search_string>

    var msgbase_code = argv[0];
    var search_string = argv[1];
    var msgbase = new MsgBase(msgbase_code);
    if(!msgbase.open()) {
    alert("Error " + msgbase.error + " opening msgbase: " + msgbase_code);
    exit();
    }

    var total_msgs = msgbase.total_msgs;
    for(var i=0; i<total_msgs; i++) {
    var hdr = msgbase.get_msg_header(true,i);
    if(hdr.subject.indexOf(search_string)>=0)
    print(hdr.subject);
    }
    print("Searched " + total_msgs + " messages.");
    msgbase.close();

    Run with jsexec on a a message base with 5000+ messages:

    Searched 5007 messages.
    s:\sbbs\exec\search.js executed in 14.34 seconds

    That's about 350 message headers a second. Is that considered slow?

    digital man

    Snapple "Real Fact" #5:
    Camels have 3 eyelids.

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net