if (*opt_maxrecs)
ZOOM_connection_option_set(link, "count", opt_maxrecs);
else
- {
- char n[128];
- sprintf(n, "%d", global_parameters.toget);
- ZOOM_connection_option_set(link, "count", n);
- }
+ ZOOM_connection_option_set(link, "count", "100");
+
if (databaseName)
ZOOM_connection_option_set(link, "databaseName", databaseName);
extract_terms(se->nmem, cn, p);
se->relevance = relevance_create(
se->service->relevance_pct,
- se->nmem, (const char **) p,
- se->expected_maxrecs);
+ se->nmem, (const char **) p);
}
ccl_rpn_delete(cn);
struct parameters global_parameters =
{
0, // dump_records
- 0, // debug_mode
- 100,
+ 0 // debug_mode
};
static void log_xml_doc(xmlDoc *doc)
s->termlists[i].name = nmem_strdup(s->nmem, type);
s->termlists[i].termlist
- = termlist_create(s->nmem, s->expected_maxrecs,
- TERMLIST_HIGH_SCORE);
+ = termlist_create(s->nmem, TERMLIST_HIGH_SCORE);
s->num_termlists = i + 1;
}
termlist_insert(s->termlists[i].termlist, value);
live_channels = select_targets(se, criteria);
if (live_channels)
{
- int maxrecs = live_channels * global_parameters.toget; // This is buggy!!!
- se->reclist = reclist_create(se->nmem, maxrecs);
- se->expected_maxrecs = maxrecs;
+ se->reclist = reclist_create(se->nmem);
}
else
return PAZPAR2_NO_TARGETS;
session->num_termlists = 0;
session->reclist = 0;
session->clients = 0;
- session->expected_maxrecs = 0;
session->session_nmem = nmem;
session->nmem = nmem_create();
session->wrbuf = wrbuf_alloc();
struct parameters {
int dump_records;
int debug_mode;
- int toget;
};
extern struct parameters global_parameters;
struct relevance *relevance;
struct reclist *reclist;
struct session_watchentry watchlist[SESSION_WATCH_MAX + 1];
- int expected_maxrecs;
int total_hits;
int total_records;
int total_merged;
struct reclist
{
struct reclist_bucket **hashtable;
- int hashtable_size;
- int hashmask;
+ unsigned hash_size;
int num_records;
struct reclist_bucket *sorted_list;
l->sorted_ptr = l->sorted_list;
}
-struct reclist *reclist_create(NMEM nmem, int numrecs)
+struct reclist *reclist_create(NMEM nmem)
{
- int hashsize = 1;
- struct reclist *res;
-
- assert(numrecs);
- while (hashsize < numrecs)
- hashsize <<= 1;
- res = nmem_malloc(nmem, sizeof(struct reclist));
+ struct reclist *res = nmem_malloc(nmem, sizeof(struct reclist));
+ res->hash_size = 399;
res->hashtable
- = nmem_malloc(nmem, hashsize * sizeof(struct reclist_bucket*));
- memset(res->hashtable, 0, hashsize * sizeof(struct reclist_bucket*));
- res->hashtable_size = hashsize;
+ = nmem_malloc(nmem, res->hash_size * sizeof(struct reclist_bucket*));
+ memset(res->hashtable, 0, res->hash_size * sizeof(struct reclist_bucket*));
res->nmem = nmem;
- res->hashmask = hashsize - 1; // Creates a bitmask
res->sorted_ptr = 0;
res->sorted_list = 0;
assert(merge_key);
assert(total);
- bucket = jenkins_hash((unsigned char*) merge_key) & l->hashmask;
+ bucket = jenkins_hash((unsigned char*) merge_key) % l->hash_size;
for (p = &l->hashtable[bucket]; *p; p = &(*p)->hnext)
{
struct reclist_sortparms *next;
};
-struct reclist *reclist_create(NMEM, int numrecs);
+struct reclist *reclist_create(NMEM);
struct record_cluster *reclist_insert( struct reclist *tl,
struct conf_service *service,
struct record *record,
struct relevance *relevance_create(pp2_charset_t pct,
- NMEM nmem, const char **terms, int numrecs)
+ NMEM nmem, const char **terms)
{
struct relevance *res = nmem_malloc(nmem, sizeof(struct relevance));
const char **p;
struct reclist;
struct relevance *relevance_create(pp2_charset_t pct,
- NMEM nmem, const char **terms, int numrecs);
+ NMEM nmem, const char **terms);
void relevance_newrec(struct relevance *r, struct record_cluster *cluster);
void relevance_countwords(struct relevance *r, struct record_cluster *cluster,
const char *words, int multiplier);
struct termlist
{
struct termlist_bucket **hashtable;
- int hashtable_size;
- int hashmask;
+ unsigned hash_size;
struct termlist_score **highscore;
int highscore_size;
NMEM nmem;
};
-struct termlist *termlist_create(NMEM nmem, int numterms, int highscore_size)
+struct termlist *termlist_create(NMEM nmem, int highscore_size)
{
- int hashsize = 1;
- int halfnumterms;
- struct termlist *res;
-
- // Calculate a hash size smallest power of 2 larger than 50% of expected numterms
- halfnumterms = numterms >> 1;
- if (halfnumterms < 0)
- halfnumterms = 1;
- while (hashsize < halfnumterms)
- hashsize <<= 1;
- res = nmem_malloc(nmem, sizeof(struct termlist));
- res->hashtable = nmem_malloc(nmem, hashsize * sizeof(struct termlist_bucket*));
- memset(res->hashtable, 0, hashsize * sizeof(struct termlist_bucket*));
- res->hashtable_size = hashsize;
+ struct termlist *res = nmem_malloc(nmem, sizeof(struct termlist));
+ res->hash_size = 399;
+ res->hashtable =
+ nmem_malloc(nmem, res->hash_size * sizeof(struct termlist_bucket*));
+ memset(res->hashtable, 0, res->hash_size * sizeof(struct termlist_bucket*));
res->nmem = nmem;
- res->hashmask = hashsize - 1; // Creates a bitmask
res->highscore = nmem_malloc(nmem, highscore_size * sizeof(struct termlist_score *));
res->highscore_size = highscore_size;
for (cp = buf + strlen(buf); cp != buf && strchr(",. -", cp[-1]); cp--)
cp[-1] = '\0';
- bucket = jenkins_hash((unsigned char *)buf) & tl->hashmask;
+ bucket = jenkins_hash((unsigned char *)buf) % tl->hash_size;
for (p = &tl->hashtable[bucket]; *p; p = &(*p)->next)
{
if (!strcmp(buf, (*p)->term.term))
struct termlist;
-struct termlist *termlist_create(NMEM nmem, int numterms, int highscore_size);
+struct termlist *termlist_create(NMEM nmem, int highscore_size);
void termlist_insert(struct termlist *tl, const char *term);
struct termlist_score **termlist_highscore(struct termlist *tl, int *len);