From 9eaad46fe45a09ea35d9ce6561748145ebd52838 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 13 Jun 2005 10:29:20 +0000 Subject: [PATCH] Recognize resource estimatehits again. Allow server to omit records for bend_fetch in the case of estimate/approximate hits in effect. Requires YAZ 2.1.9. --- configure.in | 4 ++-- index/zebraapi.c | 36 +++++++++++++++++++++++------------- index/zserver.c | 4 ++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/configure.in b/configure.in index 52da348..2536c3a 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Zebra, Index Data ApS, 1995-2005 -dnl $Id: configure.in,v 1.124 2005-05-24 20:39:02 adam Exp $ +dnl $Id: configure.in,v 1.125 2005-06-13 10:29:20 adam Exp $ dnl AC_INIT(include/idzebra/version.h) AM_INIT_AUTOMAKE(idzebra,1.4.0) @@ -31,7 +31,7 @@ else fi dnl dnl ------ YAZ -YAZ_INIT($yazflag,2.1.5) +YAZ_INIT($yazflag,2.1.9) YAZ_DOC dnl ----- libXSLT AC_SUBST(XSLT_LIBS) diff --git a/index/zebraapi.c b/index/zebraapi.c index 9a85e32..37d7399 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.176 2005-06-10 10:55:18 adam Exp $ +/* $Id: zebraapi.c,v 1.177 2005-06-13 10:29:20 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -38,6 +38,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include +#define DEFAULT_APPROX_LIMIT 2000000000 + /* simple asserts to validate the most essential input args */ #define ASSERTZH assert(zh && zh->service) #define ASSERTZHRES assert(zh && zh->service && zh->res) @@ -115,7 +117,7 @@ ZebraHandle zebra_open (ZebraService zs) zh->num_basenames = 0; zh->basenames = 0; - zh->approx_limit = 1000000000; + zh->approx_limit = DEFAULT_APPROX_LIMIT; zh->trans_no = 0; zh->trans_w_no = 0; @@ -234,22 +236,16 @@ Dict dict_open_res (BFiles bfs, const char *name, int cache, int rw, { int page_size = 4096; char resource_str[200]; - const char *v; sprintf (resource_str, "dict.%.100s.pagesize", name); assert(bfs); assert(name); - v = res_get(res, resource_str); - if (v) - { - page_size = atoi(v); + if (res_get_int(res, resource_str, &page_size) == ZEBRA_OK) yaz_log(YLOG_LOG, "Using custom dictionary page size %d for %s", page_size, name); - } return dict_open(bfs, name, cache, rw, compact_flag, page_size); } - static struct zebra_register *zebra_register_open (ZebraService zs, const char *name, int rw, int useshadow, Res res, @@ -693,6 +689,12 @@ static void zebra_select_register (ZebraHandle zh, const char *new_reg) zebra_close_res(zh); } } + if (zh->res) + { + int approx = 0; + if (res_get_int(zh->res, "estimatehits", &approx) == ZEBRA_OK) + zebra_set_approx_limit(zh, approx); + } } void map_basenames_func (void *vp, const char *name, const char *value) @@ -868,7 +870,7 @@ ZEBRA_RES zebra_select_databases (ZebraHandle zh, int num_bases, ZEBRA_RES zebra_set_approx_limit(ZebraHandle zh, zint approx_limit) { if (approx_limit == 0) - approx_limit = 2000000000; + approx_limit = DEFAULT_APPROX_LIMIT; zh->approx_limit = approx_limit; return ZEBRA_OK; } @@ -979,12 +981,20 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, } else { - if (ret == ZEBRA_OK) /* only need to set it once */ + /* only need to set it once */ + if (pos_array[i] < zh->approx_limit && ret == ZEBRA_OK) + { zebra_setError_zint(zh, YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, pos_array[i]); - ret = ZEBRA_FAIL; - break; + ret = ZEBRA_FAIL; + break; + } + recs[i].buf = 0; /* no record and no error issued */ + recs[i].len = 0; + recs[i].errCode = 0; + recs[i].format = VAL_NONE; + recs[i].sysno = 0; } } zebra_meta_records_destroy(zh, poset, num_recs); diff --git a/index/zserver.c b/index/zserver.c index b499c21..e2ec1b3 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.134 2005-05-24 11:35:42 adam Exp $ +/* $Id: zserver.c,v 1.135 2005-06-13 10:29:20 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -309,7 +309,7 @@ int bend_fetch (void *handle, bend_fetch_rr *r) r->last_in_set = 0; res = zebra_records_retrieve (zh, r->stream, r->setname, r->comp, - r->request_format, 1, &retrievalRecord); + r->request_format, 1, &retrievalRecord); if (res != ZEBRA_OK) { /* non-surrogate diagnostic */ -- 1.7.10.4