X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=rset%2Frset.c;h=5a187422e3337bc6677003b580e82c1eaff3234d;hb=a741f3ed46c75118dd042c30b375c9cea923b33e;hp=780727a12fb0286768d4b8825908299e93a9e257;hpb=9d5bfe73fd06d99c306f91860a322aece5b6f4fc;p=idzebra-moved-to-github.git diff --git a/rset/rset.c b/rset/rset.c index 780727a..5a18742 100644 --- a/rset/rset.c +++ b/rset/rset.c @@ -1,8 +1,5 @@ -/* $Id: rset.c,v 1.54 2006-06-22 22:58:59 adam Exp $ - Copyright (C) 1995-2005 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1995-2008 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -15,9 +12,9 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include @@ -65,19 +62,43 @@ RSFD rfd_create_base(RSET rs) return rnew; } +static void rset_close_int(RSET rs, RSFD rfd) +{ + RSFD *pfd; + (*rs->control->f_close)(rfd); + + yaz_log(log_level, "rfd_delete_base: rfd=%p rs=%p priv=%p fl=%p", + rfd, rs, rfd->priv, rs->free_list); + for (pfd = &rs->use_list; *pfd; pfd = &(*pfd)->next) + if (*pfd == rfd) + { + *pfd = (*pfd)->next; + rfd->next = rs->free_list; + rs->free_list = rfd; + return; + } + yaz_log(YLOG_WARN, "rset_close handle not found. type=%s", + rs->control->desc); +} + +void rset_set_hits_limit(RSET rs, zint l) +{ + rs->hits_limit = l; +} + /** \brief Closes a result set RFD handle \param rfd the RFD handle. */ void rset_close(RSFD rfd) { - RSFD *pfd; RSET rs = rfd->rset; if (rs->hits_count == 0) { TERMID termid; char buf[100]; + while(rfd->counted_items <= rs->hits_limit && rset_default_read(rfd, buf, &termid)) ; @@ -116,20 +137,7 @@ void rset_close(RSFD rfd) yaz_log(log_level, "rset_close p=%p count=" ZINT_FORMAT, rs, rs->hits_count); } - (*rs->control->f_close)(rfd); - - yaz_log(log_level, "rfd_delete_base: rfd=%p rs=%p priv=%p fl=%p", - rfd, rs, rfd->priv, rs->free_list); - for (pfd = &rs->use_list; *pfd; pfd = &(*pfd)->next) - if (*pfd == rfd) - { - *pfd = (*pfd)->next; - rfd->next = rs->free_list; - rs->free_list = rfd; - return; - } - yaz_log(YLOG_WARN, "rset_close handle not found. type=%s", - rs->control->desc); + rset_close_int(rs, rfd); } /** @@ -261,7 +269,7 @@ zint rset_count(RSET rs) double cur, tot; RSFD rfd = rset_open(rs, 0); rset_pos(rfd, &cur, &tot); - rset_close(rfd); + rset_close_int(rs, rfd); return (zint) tot; } @@ -358,8 +366,17 @@ int rset_default_read(RSFD rfd, void *buf, TERMID *term) int rc = (*rset->control->f_read)(rfd, buf, term); if (rc > 0) { - if (rfd->counted_items == 0 || - (rset->keycontrol->cmp)(buf, rfd->counted_buf) > rset->scope) + int got_scope; + if (rfd->counted_items == 0) + got_scope = rset->scope+1; + else + got_scope = rset->keycontrol->cmp(buf, rfd->counted_buf); + +#if 0 + key_logdump_txt(YLOG_LOG, buf, "rset_default_read"); + yaz_log(YLOG_LOG, "rset_scope=%d got_scope=%d", rset->scope, got_scope); +#endif + if (got_scope > rset->scope) { memcpy(rfd->counted_buf, buf, rset->keycontrol->key_size); rfd->counted_items++;