+Added zebra_set_approx_limit for a ZebraHandle (session). Results
+will be approximate if hit count is greater than the limit specified.
+
Added support for term hit counts. This was not in place for earlier
1.4 versions, but is present in the 1.3 series. Bug #124.
-/* $Id: api.h,v 1.25 2005-06-02 11:59:53 adam Exp $
+/* $Id: api.h,v 1.26 2005-06-09 10:39:52 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
YAZ_EXPORT
void zebra_clearError(ZebraHandle zh);
+
+/**
+ \brief Set limit before Zebra does approx hit count
+ \param zh session handle
+ \param approx_limit the limit
+
+ Results will be approximiate if hit count is greater than the
+ limit specified. By default there is a high-limit (no limit).
+*/
+ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit);
+
/**
\brief Search using PQF Query
\param zh session handle
-/* $Id: index.h,v 1.142 2005-06-07 14:53:39 adam Exp $
+/* $Id: index.h,v 1.143 2005-06-09 10:39:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
char **basenames;
int num_basenames;
+ zint approx_limit;
char *reg_name;
char *path_reg;
-/* $Id: zebraapi.c,v 1.174 2005-06-07 11:36:38 adam Exp $
+/* $Id: zebraapi.c,v 1.175 2005-06-09 10:39:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
zh->num_basenames = 0;
zh->basenames = 0;
+ zh->approx_limit = 1000000000;
zh->trans_no = 0;
zh->trans_w_no = 0;
return ZEBRA_OK;
}
+ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit)
+{
+ zh->approx_limit = approx_limit;
+ return ZEBRA_OK;
+}
+
ZEBRA_RES zebra_search_RPN(ZebraHandle zh, ODR o, Z_RPNQuery *query,
const char *setname, zint *hits)
{
-/* $Id: zrpn.c,v 1.197 2005-06-07 14:53:39 adam Exp $
+/* $Id: zrpn.c,v 1.198 2005-06-09 10:39:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
*dst = nmem_strdup(stream, term_src);
}
-static void count_set (RSET r, int *count)
+static void count_set(ZebraHandle zh, RSET rset, zint *count)
{
zint psysno = 0;
- int kno = 0;
struct it_key key;
RSFD rfd;
yaz_log(YLOG_DEBUG, "count_set");
+ rset->hits_limit = zh->approx_limit;
+
*count = 0;
- rfd = rset_open (r, RSETF_READ);
- while (rset_read (rfd, &key,0 /* never mind terms */))
+ rfd = rset_open(rset, RSETF_READ);
+ while (rset_read(rfd, &key,0 /* never mind terms */))
{
if (key.mem[0] != psysno)
{
psysno = key.mem[0];
- (*count)++;
+ if (rfd->counted_items >= rset->hits_limit)
+ break;
}
- kno++;
}
rset_close (rfd);
- yaz_log(YLOG_DEBUG, "%d keys, %d records", kno, *count);
+ *count = rset->hits_count;
}
ZEBRA_RES rpn_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt,
}
if (lo >= 0)
{
+ zint count;
/* merge with limit_set if given */
if (limit_set)
{
2, rsets);
}
/* count it */
- count_set(rset, &glist[lo].occurrences);
+ count_set(zh, rset, &count);
+ glist[lo].occurrences = count;
rset_delete(rset);
}
}
const char *tst;
RSET rset;
int lo = before-1-i; /* offset in result list */
+ zint count;
for (j = 0; j <ord_no; j++)
{
rset = rsmulti_and_create(rset_nmem, kc,
kc->scope, 2, rsets);
}
- count_set (rset, &glist[lo].occurrences);
+ count_set(zh, rset, &count);
+ glist[lo].occurrences = count;
rset_delete (rset);
}
(*kc->dec)(kc);
-/* $Id: zsets.c,v 1.88 2005-06-07 14:53:39 adam Exp $
+/* $Id: zsets.c,v 1.89 2005-06-09 10:39:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
zint cache_position; /* last position */
RSFD cache_rfd; /* rfd (NULL if not existing) */
zint cache_psysno; /* sysno for last position */
+ zint approx_limit; /* limit before we do approx */
};
struct zset_sort_entry {
for (i = 0; sort_sequence->specs[i]; i++)
;
sort_sequence->num_specs = i;
+ rset->hits_limit = sset->approx_limit;
if (!i)
{
res = resultSetRank (zh, sset, rset, rset_nmem);
zh->hits = 0;
- zebraSet = resultSetAdd (zh, setname, 1);
+ zebraSet = resultSetAdd(zh, setname, 1);
if (!zebraSet)
return ZEBRA_FAIL;
zebraSet->locked = 1;
zebraSet->basenames =
nmem_malloc (zebraSet->nmem, num_bases * sizeof(*zebraSet->basenames));
for (i = 0; i<num_bases; i++)
- zebraSet->basenames[i] = nmem_strdup (zebraSet->nmem, basenames[i]);
+ zebraSet->basenames[i] = nmem_strdup(zebraSet->nmem, basenames[i]);
res = resultSetSearch(zh, zebraSet->nmem, zebraSet->rset_nmem,
rpn, zebraSet);
(s->hits)++;
}
-ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov)
+ZebraSet resultSetAdd(ZebraHandle zh, const char *name, int ov)
{
ZebraSet s;
int i;
s->rpn = 0;
s->cache_position = 0;
s->cache_rfd = 0;
+ s->approx_limit = zh->approx_limit;
return s;
}
-ZebraSet resultSetGet (ZebraHandle zh, const char *name)
+ZebraSet resultSetGet(ZebraHandle zh, const char *name)
{
ZebraSet s;
}
}
-void resultSetDestroy (ZebraHandle zh, int num, char **names,int *statuses)
+void resultSetDestroy(ZebraHandle zh, int num, char **names,int *statuses)
{
ZebraSet * ss = &zh->sets;
int i;
RSFD rfd = rset_open(rset, RSETF_READ);
struct rank_control *rc = rank_class->control;
double score;
+ zint count = 0;
void *handle =
(*rc->begin) (zh->reg, rank_class->class_handle, rset, nmem,
{
score = (*rc->calc) (handle, psysno);
resultSetInsertRank (zh, sort_info, psysno, score, 'A');
+ count++;
}
psysno = this_sys;
}
{
score = (*rc->calc)(handle, psysno);
resultSetInsertRank(zh, sort_info, psysno, score, 'A');
+ count++;
}
(*rc->end) (zh->reg, handle);
rset_close (rfd);
-/* $Id: rset.c,v 1.50 2005-06-07 14:53:39 adam Exp $
+/* $Id: rset.c,v 1.51 2005-06-09 10:39:53 adam Exp $
Copyright (C) 1995-2005
Index Data ApS
rset->free_list = NULL;
rset->use_list = NULL;
rset->hits_count = 0;
- rset->hits_limit = 1000;
+ rset->hits_limit = 0;
rset->hits_round = 1000;
rset->keycontrol = kcontrol;
(*kcontrol->inc)(kcontrol);
if (rc > 0)
{
if (rfd->counted_items == 0 ||
- (rset->keycontrol->cmp)(buf, rfd->counted_buf) >= rset->scope)
+ (rset->keycontrol->cmp)(buf, rfd->counted_buf) > rset->scope)
{
memcpy(rfd->counted_buf, buf, rset->keycontrol->key_size);
rfd->counted_items++;