From aa7cc3c1655c632a7b3a7053fb5b46b8ce0d3aeb Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 9 Aug 2005 09:35:25 +0000 Subject: [PATCH] Added extra parameter setname for zebra scan functions. This allows a scan to be limited by a result set (NULL for no limit). If no result set is given for scan functions, attribute 8 is inspected. If present, value of attribute 8 is used as limit. --- examples/gils/zebra.cfg | 6 ++++-- include/idzebra/api.h | 9 ++++++--- index/zebraapi.c | 26 +++++++++++++++++++++----- index/zserver.c | 5 +++-- test/api/testlib.c | 5 +++-- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/examples/gils/zebra.cfg b/examples/gils/zebra.cfg index ab98930..db4e49b 100644 --- a/examples/gils/zebra.cfg +++ b/examples/gils/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.7 2005-05-12 10:16:26 adam Exp $ +# $Id: zebra.cfg,v 1.8 2005-08-09 09:35:25 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: .:../../tab @@ -16,7 +16,9 @@ isam: c perm.anonymous: rw #rank: zvrank -#recordId: (bib-1,identifier-standard) +recordId: (bib-1,title) + +database: adam modulePath: ../../recctrl/.libs #shadow: shadow:100M diff --git a/include/idzebra/api.h b/include/idzebra/api.h index e2bddc2..bb707cb 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -1,4 +1,4 @@ -/* $Id: api.h,v 1.27 2005-06-22 19:42:38 adam Exp $ +/* $Id: api.h,v 1.28 2005-08-09 09:35:25 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -267,13 +267,15 @@ ZEBRA_RES zebra_result_set_term_info(ZebraHandle zh, const char *setname, \param num_entries number of terms requested / returned \param entries list of resulting terms (ODR allocated) \param is_partial upon return 1=partial, 0=complete + \param setname limit scan by this set (NULL means no limit) */ YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, oid_value attributeset, int *position, int *num_entries, ZebraScanEntry **entries, - int *is_partial); + int *is_partial, + const char *setname); /** \brief performs Scan (taking PQF string) @@ -284,11 +286,12 @@ YAZ_EXPORT ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, \param num_entries number of terms requested / returned \param entries list of resulting terms (ODR allocated) \param is_partial upon return 1=partial, 0=complete + \param setname limit scan by this set (NULL means no limit) */ YAZ_EXPORT ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query, int *position, int *num_entries, ZebraScanEntry **entries, - int *is_partial); + int *is_partial, const char *setname); /** \brief authenticate user. Returns 0 if OK, != 0 on failure diff --git a/index/zebraapi.c b/index/zebraapi.c index cbf4514..5995610 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.179 2005-06-23 06:45:46 adam Exp $ +/* $Id: zebraapi.c,v 1.180 2005-08-09 09:35:25 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1015,7 +1015,8 @@ ZEBRA_RES zebra_records_retrieve(ZebraHandle zh, ODR stream, ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query, int *position, int *num_entries, ZebraScanEntry **entries, - int *is_partial) + int *is_partial, + const char *setname) { YAZ_PQF_Parser pqf_parser = yaz_pqf_create (); Z_AttributesPlusTerm *zapt; @@ -1029,7 +1030,8 @@ ZEBRA_RES zebra_scan_PQF(ZebraHandle zh, ODR stream, const char *query, } else res = zebra_scan(zh, stream, zapt, VAL_BIB1, - position, num_entries, entries, is_partial); + position, num_entries, entries, is_partial, + setname); yaz_pqf_destroy (pqf_parser); return res; } @@ -1038,9 +1040,11 @@ ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, oid_value attributeset, int *position, int *num_entries, ZebraScanEntry **entries, - int *is_partial) + int *is_partial, + const char *setname) { ZEBRA_RES res; + RSET limit_rset = 0; ASSERTZH; assert(stream); assert(zapt); @@ -1056,9 +1060,21 @@ ZEBRA_RES zebra_scan(ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, *num_entries = 0; return ZEBRA_FAIL; } + if (setname) + { + limit_rset = resultSetRef(zh, setname); + if (!limit_rset) + { + zebra_setError(zh, + YAZ_BIB1_SPECIFIED_RESULT_SET_DOES_NOT_EXIST, + setname); + zebra_end_read (zh); + return ZEBRA_FAIL; + } + } res = rpn_scan (zh, stream, zapt, attributeset, zh->num_basenames, zh->basenames, position, - num_entries, entries, is_partial, 0, 0); + num_entries, entries, is_partial, limit_rset, 0); zebra_end_read (zh); return res; } diff --git a/index/zserver.c b/index/zserver.c index 7feac45..c0eacbe 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.137 2005-06-22 19:42:38 adam Exp $ +/* $Id: zserver.c,v 1.138 2005-08-09 09:35:25 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -359,7 +359,8 @@ static int bend_scan (void *handle, bend_scan_rr *r) res = zebra_scan(zh, r->stream, r->term, r->attributeset, &r->term_position, - &r->num_entries, &entries, &is_partial); + &r->num_entries, &entries, &is_partial, + 0 /* setname */); if (res == ZEBRA_OK) { if (is_partial) diff --git a/test/api/testlib.c b/test/api/testlib.c index 3d1f743..8301cb6 100644 --- a/test/api/testlib.c +++ b/test/api/testlib.c @@ -1,4 +1,4 @@ -/* $Id: testlib.c,v 1.23 2005-06-14 20:28:54 adam Exp $ +/* $Id: testlib.c,v 1.24 2005-08-09 09:35:26 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -238,7 +238,8 @@ void do_scan(int lineno, ZebraHandle zh, const char *query, yaz_log(log_level, "======================================"); yaz_log(log_level, "scan[%d]: pos=%d num=%d %s", lineno, pos, num, query); - res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial); + res = zebra_scan_PQF(zh, odr, query, &pos, &num, &entries, &partial, + 0 /* setname */); if (res != ZEBRA_OK) { printf("Error: scan returned %d (FAIL), but no error was expected\n" -- 1.7.10.4