-/* $Id: zsets.c,v 1.89 2005-06-09 10:39:53 adam Exp $
+/* $Id: zsets.c,v 1.94 2005-08-19 11:04:23 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
RSET rset;
int i;
struct zset_sort_info *sort_info;
+ size_t sysno_mem_index = 0;
+
+ if (zh->m_staticrank)
+ sysno_mem_index = 1;
if (!log_level_set)
loglevels();
}
while (num_i < num && rset_read (rfd, &key, 0))
{
- zint this_sys = key.mem[0];
+ zint this_sys = key.mem[sysno_mem_index];
if (this_sys != psysno)
{
psysno = this_sys;
TERMID termid;
TERMID *terms;
int numTerms = 0;
+ size_t sysno_mem_index = 0;
+
+ if (zh->m_staticrank)
+ sysno_mem_index = 1;
+
assert(nmem); /* compiler shut up about unused param */
sset->sort_info->num_entries = 0;
rfd = rset_open (rset, RSETF_READ);
while (rset_read (rfd, &key, &termid))
{
- zint this_sys = key.mem[0];
+ zint this_sys = key.mem[sysno_mem_index];
if (log_level_searchhits)
key_logdump_txt(log_level_searchhits, &key, termid->name);
kno++;
ZebraRankClass rank_class;
struct zset_sort_info *sort_info;
const char *rank_handler_name = res_get_def(zh->res, "rank", "rank-1");
+ size_t sysno_mem_index = 0;
+
+ if (zh->m_staticrank)
+ sysno_mem_index = 1;
if (!log_level_set)
loglevels();
terms = (TERMID *) nmem_malloc(nmem, sizeof(*terms)*n);
rset_getterms(rset, terms, n, &numTerms);
+
rank_class = zebraRankLookup(zh, rank_handler_name);
if (!rank_class)
{
void *handle =
(*rc->begin) (zh->reg, rank_class->class_handle, rset, nmem,
terms, numTerms);
- zint psysno = 0;
+ zint psysno = 0; /* previous doc id / sys no */
+ zint pstaticrank = 0; /* previous static rank */
+ int stop_flag = 0;
while (rset_read(rfd, &key, &termid))
{
- zint this_sys = key.mem[0];
+ zint this_sys = key.mem[sysno_mem_index];
+
zint seqno = key.mem[key.len-1];
kno++;
if (log_level_searchhits)
key_logdump_txt(log_level_searchhits, &key, termid->name);
- if (this_sys != psysno)
- {
- if (rfd->counted_items >= rset->hits_limit)
+ if (this_sys != psysno)
+ { /* new record .. */
+ if (rfd->counted_items > rset->hits_limit)
break;
if (psysno)
- {
- score = (*rc->calc) (handle, psysno);
+ { /* only if we did have a previous record */
+ score = (*rc->calc) (handle, psysno, pstaticrank,
+ &stop_flag);
+ /* insert the hit. A=Ascending */
resultSetInsertRank (zh, sort_info, psysno, score, 'A');
count++;
+ if (stop_flag)
+ break;
}
psysno = this_sys;
+ if (zh->m_staticrank)
+ pstaticrank = key.mem[0];
}
(*rc->add) (handle, CAST_ZINT_TO_INT(seqno), termid);
}
+ /* no more items */
if (psysno)
- {
- score = (*rc->calc)(handle, psysno);
+ { /* we had - at least - one record */
+ score = (*rc->calc)(handle, psysno, pstaticrank, &stop_flag);
+ /* insert the hit. A=Ascending */
resultSetInsertRank(zh, sort_info, psysno, score, 'A');
count++;
}
if (approx_array)
approx_array[no] = rset->hits_approx;
#if 0
- yaz_log(YLOG_LOG, "rset=%p term=%s count=" ZINT_FORMAT,
- rset, rset->term->name, rset->hits_count);
+ yaz_log(YLOG_LOG, "rset=%p term=%s limit=" ZINT_FORMAT
+ " count=" ZINT_FORMAT,
+ rset, rset->term->name, rset->hits_limit, rset->hits_count);
#endif
no++;
}
ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname,
int no, zint *count, int *approx,
- char *termbuf, size_t *termlen)
+ char *termbuf, size_t *termlen,
+ const char **term_ref_id)
{
ZebraSet sset = resultSetGet(zh, setname);
if (sset)
}
termbuf[*termlen] = '\0';
}
+ if (term_ref_id)
+ *term_ref_id = term_array[no]->ref_id;
xfree(term_array);
xfree(hits_array);