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

version» Context lines:

pike.git/lib/modules/Search.pmod/Query.pmod:1:   #pike __REAL_VERSION__       - static string debug_blob(string b) + protected string debug_blob(string b)   {    if (!b)    return "Blob(empty)";    string res = "Blob(";    while (sizeof(b) >= 5) {    array hits = ({ });    sscanf(b, "%4c%c%s", int docid, int nhits, b);    int iter = nhits;    while (iter-- && sizeof(b) >= 2) {    sscanf(b, "%2c%s", int hit, b);    hits += ({ (string) hit });    }    res += sprintf("[docid:%O hits:%s]", docid, hits * ",");    }    res += ")";    return res;   }       - static function(string,int,int:string) blobfeeder(Search.Database.Base db, + protected function(string,int,int:string) blobfeeder(Search.Database.Base db,    array words)   {    // Create state per word and stream so multiple occurrences of the same    // word are kept apart.    mapping state = mkmapping(words, allocate(sizeof(words), ([ ]) ));    mapping(string:mapping(int:string)) blobcache = ([ ]);    return lambda( string word, int foo, int blob_stream_id )    {    return db->get_blob(word, state[word][blob_stream_id]++, blobcache);    };   }    - static array(string) uniq_preserve_order(array(string) a) { + protected array(string) uniq_preserve_order(array(string) a) {    array(string) result = ({});    foreach (a, string s)    if (search(result, s) < 0)    result += ({ s });    return result;   }      Search.ResultSet do_query_or(Search.Database.Base db,    array(string) words,    Search.RankingProfile ranking)
pike.git/lib/modules/Search.pmod/Query.pmod:78:    // ranking->cutoff,    blobfeeder(db, words));    return result;   }      enum search_order   {    RELEVANCE=1, DATE_ASC, DATE_DESC, NONE, PUBL_DATE_ASC, PUBL_DATE_DESC   };    - static Search.ResultSet sort_resultset(Search.ResultSet resultset, + protected Search.ResultSet sort_resultset(Search.ResultSet resultset,    search_order order,    Search.Database.Base db)   {      }         //! @param query   //! The query string entered by user.   //! @param db
pike.git/lib/modules/Search.pmod/Query.pmod:127:    q = Search.Grammar.optimize(q);       if (!q) // The query was a null query    return ({ Search.ResultSet(), ({}), ({}) }); // so return an empty resultset       string error = Search.Grammar.validate(q);    if (error)    throw (error);       array(Search.ResultSet|array(string)) res = class { -  static Search.RankingProfile defaultRanking; -  static Search.Database.Base db; +  protected Search.RankingProfile defaultRanking; +  protected Search.Database.Base db;       // Used when search is limited to another field than "any:". -  static Search.RankingProfile specialRanking; +  protected Search.RankingProfile specialRanking;    -  static void create(Search.Database.Base _db, Search.RankingProfile _defaultRanking) { +  protected void create(Search.Database.Base _db, Search.RankingProfile _defaultRanking) {    db = _db;    defaultRanking = _defaultRanking;    specialRanking = defaultRanking->copy();    pop = stack->pop;    push = stack->push;    }    -  static array(array(string)) split_words(array(string) words) +  protected array(array(string)) split_words(array(string) words)    {    array a=({}),b=({});    foreach(words, string word)    if(has_value(word, "*") || has_value(word, "?"))    b+=({ word });    else    a+=({ word });    return ({ a, b });    }    -  static constant ParseNode = Search.Grammar.ParseNode; +  protected constant ParseNode = Search.Grammar.ParseNode;    -  static array(array(string)|string) words = ({ }); -  static array(array(string)|string) glob_words = ({ }); -  static ADT.Stack stack = ADT.Stack(); -  static function(Search.ResultSet:void) push; -  static function(void:Search.ResultSet) pop; +  protected array(array(string)|string) words = ({ }); +  protected array(array(string)|string) glob_words = ({ }); +  protected ADT.Stack stack = ADT.Stack(); +  protected function(Search.ResultSet:void) push; +  protected function(void:Search.ResultSet) pop;       array(Search.ResultSet|array(string)) execute(ParseNode q) {    exec(q);    if (sizeof(stack) != 1)    error("Stack should have exactly one item!");    return ({ pop(), words, glob_words });    }          void exec(ParseNode q, void|int use_AND_optimization) {
pike.git/lib/modules/Search.pmod/Query.pmod:286:    if (!fieldID && q->field != "body")    {    // There was no such field, so we push an empty ResultSet !    push(Search.ResultSet());    break;    }    ranking->field_ranking = allocate(65);    ranking->field_ranking[fieldID] = 1;    }    +  // Note that words can become globs automatically if auto-globbing +  // is enabled. If true then this has already happened in the +  // parsing step so we don't need to do anything here. +     [array plusWords, array plusWordGlobs] = split_words(q->plusWords);    [array ordinaryWords, array ordinaryWordGlobs] = split_words(q->words);    [array minusWords, array minusWordGlobs] = split_words(q->minusWords);         // werror("[%-10s] plus: %-15s ordinary: %-15s minus: %-15s\n", q->field, q>plusWords*", ", q->words*", ", q->minusWords*", ");       // Subtracting "*" gives empty result    if (has_value(minusWordGlobs, "*")) {    push(Search.ResultSet());