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

version» Context lines:

pike.git/lib/modules/Search.pmod/Query.pmod:1:   // $Id$   #pike __REAL_VERSION__    - static function(string,int:string) blobfeeder(Search.Database.Base db, +  + static 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,    array words)   { -  mapping state = mkmapping(words,allocate(sizeof(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 ) +  return lambda( string word, int foo, int blob_stream_id )    { -  return db->get_blob(word, state[word]++, blobcache); +  return db->get_blob(word, state[word][blob_stream_id]++, blobcache);    };   }      static array(string) uniq_preserve_order(array(string) a) {    array(string) result = ({});    foreach (a, string s)    if (search(result, s) < 0)    result += ({ s });    return result;   }