pike.git / lib / modules / Search.pmod / Utils.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Utils.pmod:1: - // $Id$ +    #pike __REAL_VERSION__      #if !constant(report_error)   #define report_error werror   #define report_debug werror   #define report_warning werror   #endif      // Cannot dump this because of the #if constant(...) checks depending   // on Roxen below.
pike.git/lib/modules/Search.pmod/Utils.pmod:117:    get_database(),    get_query_value("fi_rank"));    return ranking;    }       class ADTSet {    private mapping vals = ([]);       ADTSet add (string|int|float in) {    vals[in] = 1; -  return this_object(); +  return this;    }       ADTSet sub (string|int|float out) {    m_delete(vals, out); -  return this_object(); +  return this;    }       ADTSet `+(mixed in) {    if(stringp(in)||intp(in)||floatp(in))    add(in);    else    map((array)in, add); -  return this_object(); +  return this;    }       ADTSet `-(mixed out) {    if(stringp(out)||intp(out)||floatp(out))    sub(out);    else    map((array)out, sub); -  return this_object(); +  return this;    }    -  mixed cast(string to) { +  protected mixed cast(string to) {    switch(to) { -  case "object": return this_object(); +     case "array": return indices(vals);    case "multiset": return (multiset)indices(vals);    default: -  error("Can not cast ADTSet to "+to+".\n"); +  return UNDEFINED;    }    }    }       //! Returns a cached array of stop words for the current query profile.    array(string) get_stop_words() {    if(!stop_words) {    ADTSet words = ADTSet();    foreach(get_query_value("sw_lists"), string fn) {    string file = Stdio.read_file(fn);
pike.git/lib/modules/Search.pmod/Utils.pmod:374:    int db = get_db_profile_number(db_name);    int query = get_query_profile_number(query_name);       ProfileEntry entry;    if(entry=entry_cache[query +":"+ db]) {    if(!entry->check_timeout()) return entry;    if(up_to_datep(db) &&    up_to_datep(query)) return entry;    }    -  entry = ProfileEntry( db, query, this_object() ); +  entry = ProfileEntry( db, query, this );    return entry_cache[query +":"+ db] = entry;    }       //! Flushes profile entry @[p] from the profile cache.    void flush_profile(int p) {    m_delete(value_cache, p);    foreach(db_profile_names; string name; int dbp)    if (dbp == p)    m_delete(db_profile_names, name);    foreach(query_profile_names; string name; int qp)
pike.git/lib/modules/Search.pmod/Utils.pmod:690:    }       //! @decl void create(Sql.Sql db_object, int profile, int stderr_logging)    //! @decl void create(string db_url, int profile, int stderr_logging)    void create(string|Sql.Sql _logdb, int _profile, int _stderr_logging) {    logdb = _logdb;    profile = _profile;    stderr_logging = _stderr_logging;       // create table eventlog (event int unsigned auto_increment primary key, -  // at timestamp(14) not null, code int unsigned not null, extra varchar(255)) +  // at timestamp not null, code int unsigned not null, extra varchar(255))       Sql.Sql db = get_db();       if(catch(db->query("SELECT code FROM eventlog WHERE event=0")))    db->query("CREATE TABLE eventlog ("    "event int unsigned auto_increment primary key," -  "at timestamp(14) not null," +  "at timestamp not null,"    "profile int unsigned not null,"    "code int unsigned not null,"    "type enum('error','warning','notice') not null,"    "extra varchar(255))");    }       void werror_event( int code, string type, void|string extra, void|int log_profile )    {    mapping types = ([ "error" : "Error",    "warning" : "Warning",
pike.git/lib/modules/Search.pmod/Utils.pmod:739:    int t2 = time();    if (t2 - t1 > 10) // More than 10 s is somewhat slow, report warning.    report_warning("Search log purge took %d s.\n", t2-t1);    }       //!    void log_event( int code, string type, void|string extra, void|int log_profile ) {    Sql.Sql db = get_db();    if(!db) return;    -  if(zero_type(log_profile)) +  if(undefinedp(log_profile))    log_profile = profile;       if(stderr_logging)    werror_event(code, type, extra, log_profile);       if(extra)    db->query("INSERT INTO eventlog (profile,code,type,extra) VALUES (%d,%d,%s,%s)",    log_profile, code, type, extra);    else    db->query("INSERT INTO eventlog (profile, code,type) VALUES (%d,%d,%s)",