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

version» Context lines:

pike.git/lib/modules/Search.pmod/Utils.pmod:1:   // This file is part of Roxen Search   // Copyright © 2001 Roxen IS. All rights reserved.   // - // $Id: Utils.pmod,v 1.16 2001/07/26 04:50:08 nilsson Exp $ + // $Id: Utils.pmod,v 1.17 2001/07/26 19:16:18 nilsson Exp $      #if !constant(report_error)   #define report_error werror   #endif      public array(string) tokenize_and_normalize( string what )   //! This can be optimized quite significantly when compared to   //! tokenize( normalize( x ) ) in the future, currently it's not all   //! that much faster, but still faster.   {
pike.git/lib/modules/Search.pmod/Utils.pmod:47:    private Search.Database.MySQL db;    private Search.RankingProfile ranking;    private array(string) stop_words;       void create(int _database_profile_id,    int _search_profile_id,    ProfileCache _my_cache) {    database_profile_id = _database_profile_id;    search_profile_id = _search_profile_id;    my_cache = _my_cache; -  int last_stat = time(1); +  int last_stat = time(1)-2;    }       void refresh() { -  +  // werror("Time since check: %d\n", time(1)-last_stat);    if(time(1)-last_stat < 5*60) return;    int check = my_cache->up_to_datep(database_profile_id);    if(check == -1) destruct();    if(!check) {    database_values = 0;    ranking = 0;    db = 0;    }    check = my_cache->up_to_datep(search_profile_id);    if(check == -1) destruct();    if(!check) {    search_values = 0;    ranking = 0;    stop_words = 0;    } -  last_stat = time(1); +  last_stat = time(1)-2;    }       mixed get_database_value(string index) {    if(!database_values)    database_values = my_cache->get_value_mapping(database_profile_id);    return database_values[index];    }       mixed get_search_value(string index) {    if(!search_values)    search_values = my_cache->get_value_mapping(search_profile_id);    return search_values[index];    }       Search.Database.MySQL get_database() { -  +  refresh();    if(!db) {   #if constant(DBManager)    db = Search.Database.MySQL( DBManager.db_url( get_database_value("db_name"), 1) );   #endif    if(!db)    THROW("Could not aquire the database URL to database " +    get_database_value("db_name") + ".\n");    }    return db;    }       Search.RankingProfile get_ranking() { -  +  refresh();    if(!ranking)    ranking = Search.RankingProfile(8,    get_search_value("px_rank"),    get_database(),    get_search_value("fi_rank"));    return ranking;    }       class ADTSet {    private mapping vals = ([]);
pike.git/lib/modules/Search.pmod/Utils.pmod:143:    case "object": return this_object();    case "array": return indices(vals);    case "multiset": return (multiset)indices(vals);    default:    THROW("Can not cast ADTSet to "+to+".\n");    }    }    }       array(string) get_stop_words() { +  refresh();    if(!stop_words) {    ADTSet words = ADTSet();    foreach(get_search_value("sw_lists"), string fn) {    string file = Stdio.read_file(fn);    if(!fn)    report_error("Could not load %O.\n", fn);    else    words + (Array.flatten(map(file/"\n",    lambda(string in) {    return in/" ";
pike.git/lib/modules/Search.pmod/Utils.pmod:183:    private Sql.Sql get_db() {    Sql.Sql db;   #if constant(DBManager)    db = DBManager.cached_get(db_name);   #endif    if(!db) THROW("Could not connect to database " + db_name + ".\n");    return db;    }       int(-1..1) up_to_datep(int profile_id) { +  // werror("Called up-to-date...\n");    array(mapping(string:string)) res;    res = get_db()->query("SELECT altered, parent FROM wf_profile WHERE id=%d", profile_id);       // The profile is deleted. In such a rare event we take the    // trouble to review all our cached values.    if(!sizeof(res)) {    array(int) existing = (array(int))get_db()->query("SELECT id FROM wf_profile")->id;       foreach(indices(value_cache), int id)    if(!has_value(existing, id))
pike.git/lib/modules/Search.pmod/Utils.pmod:212:       foreach(indices(srh_profile_names), string name)    if(!has_value(existing, srh_profile_names[name]))    m_delete(srh_profile_names, name);       return -1;    }       // Not altered    if((int)res[0]->altered == profile_stat[profile_id]) return 1; +  profile_stat[profile_id] = (int)res[0]->altered;       // Search profile    if((int)res[0]->parent) {    m_delete(value_cache, profile_id);    m_delete(entry_cache, profile_id);    return 0;    }       m_delete(value_cache, profile_id);    foreach((array(int))get_db()->query("SELECT id FROM wf_profile WHERE parent=%d", profile_id)->id,
pike.git/lib/modules/Search.pmod/Utils.pmod:295:       array res = get_db()->    query("SELECT name,value FROM wf_value WHERE pid=%d", profile);       val = mkmapping( res->name, map(res->value, reacodec_decode) );    value_cache[profile] = copy_value(val);    return val;    }       ProfileEntry get_profile_entry(string db_name, void|string srh_name) { +  // werror("Entry: %O\n", indices(entry_cache)); +  // werror("Value: %O\n", indices(value_cache)); +  // werror("Stat : %O\n", profile_stat); +     int db = get_db_profile_number(db_name);    int srh = get_srh_profile_number(srh_name||"Default", db);       ProfileEntry entry;    if(entry=entry_cache[srh])    return entry;       entry = ProfileEntry( db, srh, this_object() );    return entry_cache[srh] = entry;    }