X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzsets.c;h=a26ac401fb1a6d4b5012fa08b4c2b35e5d09de48;hb=2e4e9c6def27f1e1463dcb6f205fab6a98054f38;hp=cf0e7d0a84a7546bca8c72cd5e2d437e063525cb;hpb=e408f6de48df5e13552ca72bb035f8b18f33d988;p=idzebra-moved-to-github.git diff --git a/index/zsets.c b/index/zsets.c index cf0e7d0..a26ac40 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.47 2004-05-10 08:47:54 adam Exp $ +/* $Id: zsets.c,v 1.50 2004-08-04 08:35:24 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -58,7 +58,7 @@ struct zebra_set { }; struct zset_sort_entry { - int sysno; + zint sysno; int score; char buf[ZSET_SORT_MAX_LEVEL][SORT_IDX_ENTRYSIZE]; }; @@ -207,6 +207,8 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov) } else { + const char *sort_max_str = zebra_get_resource(zh, "sortmax", "1000"); + yaz_log (LOG_DEBUG, "adding result set %s", name); s = (ZebraSet) xmalloc (sizeof(*s)); s->next = zh->sets; @@ -216,7 +218,10 @@ ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov) s->sort_info = (struct zset_sort_info *) xmalloc (sizeof(*s->sort_info)); - s->sort_info->max_entries = 1000; + s->sort_info->max_entries = atoi(sort_max_str); + if (s->sort_info->max_entries < 2) + s->sort_info->max_entries = 2; + s->sort_info->entries = (struct zset_sort_entry **) xmalloc (sizeof(*s->sort_info->entries) * s->sort_info->max_entries); @@ -379,7 +384,7 @@ ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, { int position = 0; int num_i = 0; - int psysno = 0; + zint psysno = 0; int term_index; RSFD rfd; struct it_key key; @@ -391,9 +396,14 @@ ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, rfd = rset_open (rset, RSETF_READ); while (num_i < num && rset_read (rset, rfd, &key, &term_index)) { - if (key.sysno != psysno) +#if IT_KEY_NEW + zint this_sys = key.mem[0]; +#else + zint this_sys = key.sysno; +#endif + if (this_sys != psysno) { - psysno = key.sysno; + psysno = this_sys; if (sort_info) { /* determine we alreay have this in our set */ @@ -433,7 +443,7 @@ struct sortKeyInfo { void resultSetInsertSort (ZebraHandle zh, ZebraSet sset, struct sortKeyInfo *criteria, int num_criteria, - int sysno) + zint sysno) { struct zset_sort_entry this_entry; struct zset_sort_entry *new_entry = NULL; @@ -507,7 +517,7 @@ void resultSetInsertSort (ZebraHandle zh, ZebraSet sset, } void resultSetInsertRank (ZebraHandle zh, struct zset_sort_info *sort_info, - int sysno, int score, int relation) + zint sysno, int score, int relation) { struct zset_sort_entry *new_entry = NULL; int i, j; @@ -598,7 +608,8 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, ZebraSet sset, RSET rset, Z_SortKeySpecList *sort_sequence, int *sort_status) { - int i, psysno = 0; + int i; + zint psysno = 0; struct it_key key; struct sortKeyInfo sort_criteria[3]; int num_criteria; @@ -670,10 +681,15 @@ void resultSetSortSingle (ZebraHandle zh, NMEM nmem, rfd = rset_open (rset, RSETF_READ); while (rset_read (rset, rfd, &key, &term_index)) { - if (key.sysno != psysno) +#if IT_KEY_NEW + zint this_sys = key.mem[0]; +#else + zint this_sys = key.sysno; +#endif + if (this_sys != psysno) { (sset->hits)++; - psysno = key.sysno; + psysno = this_sys; resultSetInsertSort (zh, sset, sort_criteria, num_criteria, psysno); } @@ -709,6 +725,7 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) ZebraRankClass rank_class; struct rank_control *rc; struct zset_sort_info *sort_info; + const char *rank_handler_name = res_get_def(zh->res, "rank", "rank-1"); sort_info = zebraSet->sort_info; sort_info->num_entries = 0; @@ -717,28 +734,42 @@ void resultSetRank (ZebraHandle zh, ZebraSet zebraSet, RSET rset) yaz_log (LOG_LOG, "resultSetRank"); - rank_class = zebraRankLookup (zh, res_get_def(zh->res, "rank", "rank-1")); + rank_class = zebraRankLookup (zh, rank_handler_name); + if (!rank_class) + { + yaz_log (LOG_WARN, "No such rank handler: %s", rank_handler_name); + return; + } rc = rank_class->control; if (rset_read (rset, rfd, &key, &term_index)) { - int psysno = key.sysno; +#if IT_KEY_NEW + zint psysno = key.mem[0]; +#else + zint psysno = key.sysno; +#endif int score; void *handle = (*rc->begin) (zh->reg, rank_class->class_handle, rset); (zebraSet->hits)++; do { +#if IT_KEY_NEW + zint this_sys = key.mem[0]; +#else + zint this_sys = key.sysno; +#endif kno++; - if (key.sysno != psysno) + if (this_sys != psysno) { score = (*rc->calc) (handle, psysno); resultSetInsertRank (zh, sort_info, psysno, score, 'A'); (zebraSet->hits)++; - psysno = key.sysno; + psysno = this_sys; } - (*rc->add) (handle, key.seqno, term_index); + (*rc->add) (handle, this_sys, term_index); } while (rset_read (rset, rfd, &key, &term_index)); score = (*rc->calc) (handle, psysno);