stop of result set processing.
-/* $Id: index.h,v 1.148 2005-08-19 09:21:34 adam Exp $
+/* $Id: index.h,v 1.149 2005-08-19 11:04:23 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
* int rssize; // number of records in result set (estimate?)
*/
void (*end)(struct zebra_register *reg, void *set_handle);
- int (*calc)(void *set_handle, zint sysno, zint staticrank);
+ int (*calc)(void *set_handle, zint sysno, zint staticrank,
+ int *stop_flag);
void (*add)(void *set_handle, int seqno, TERMID term);
};
-/* $Id: rank1.c,v 1.26 2005-08-19 09:21:34 adam Exp $
+/* $Id: rank1.c,v 1.27 2005-08-19 11:04:23 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int calc (void *set_handle, zint sysno, zint staticrank)
+static int calc (void *set_handle, zint sysno, zint staticrank,
+ int *stop_flag)
{
int i, lo, divisor, score = 0;
struct rank_set_info *si = (struct rank_set_info *) set_handle;
-/* $Id: rankstatic.c,v 1.2 2005-08-19 10:48:36 adam Exp $
+/* $Id: rankstatic.c,v 1.3 2005-08-19 11:04:23 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int calc (void *set_handle, zint sysno, zint staticrank)
+static int calc (void *set_handle, zint sysno, zint staticrank,
+ int *stop_flag)
{
struct rank_set_info *si = (struct rank_set_info *) set_handle;
if (!si->no_rank_entries)
return -1; /* ranking not enabled for any terms */
+ /* if we set *stop_flag = 1, we stop processing (of result set list) */
/* staticrank = 0 is highest, MAXINT lowest */
return INT_MAX - staticrank; /* but score is reverse (logical) */
}
-/* $Id: zsets.c,v 1.93 2005-08-19 09:21:34 adam Exp $
+/* $Id: zsets.c,v 1.94 2005-08-19 11:04:23 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
terms, numTerms);
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[sysno_mem_index];
break;
if (psysno)
{ /* only if we did have a previous record */
- score = (*rc->calc) (handle, psysno, pstaticrank);
+ 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)
/* no more items */
if (psysno)
{ /* we had - at least - one record */
- score = (*rc->calc)(handle, psysno, pstaticrank);
+ score = (*rc->calc)(handle, psysno, pstaticrank, &stop_flag);
/* insert the hit. A=Ascending */
resultSetInsertRank(zh, sort_info, psysno, score, 'A');
count++;
-/* $Id: zvrank.c,v 1.18 2005-08-19 09:21:34 adam Exp $
+/* $Id: zvrank.c,v 1.19 2005-08-19 11:04:23 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
* score should be between 0 and 1000. If score cannot be obtained
* -1 should be returned.
*/
-static int zv_calc (void *rsi, zint sysno, zint staticrank)
+static int zv_calc (void *rsi, zint sysno, zint staticrank, int *stop_flag)
{
int i, veclen;
int score=0;