From: Adam Dickmeiss Date: Mon, 3 Dec 2007 13:04:04 +0000 (+0000) Subject: Added function zebra_create_rset_isam . X-Git-Tag: ZEBRA.2.0.20~42 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=f82c996895d8dcd69e987660ebf9fdaafdba35b0;p=idzebra-moved-to-github.git Added function zebra_create_rset_isam . --- diff --git a/index/Makefile.am b/index/Makefile.am index 14c06b9..a75caac 100644 --- a/index/Makefile.am +++ b/index/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.66 2007-11-23 13:59:14 adam Exp $ +## $Id: Makefile.am,v 1.67 2007-12-03 13:04:04 adam Exp $ aux_libs = \ ../rset/libidzebra-rset.la \ @@ -98,7 +98,7 @@ libidzebra_2_0_la_SOURCES = \ rpnscan.c rpnsearch.c rpnfacet.c sortidx.c symtab.c stream.c \ update_path.c update_file.c trunc.c untrans.c isam_methods.c \ zaptterm.c zebraapi.c zinfo.c zinfo.h zsets.c key_block.c key_block.h \ - check_res.c + check_res.c rset_isam.c bin_PROGRAMS = zebraidx zebrasrv diff --git a/index/index.h b/index/index.h index bc631cf..a123b30 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.211 2007-12-03 11:49:11 adam Exp $ +/* $Id: index.h,v 1.212 2007-12-03 13:04:04 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -452,6 +452,10 @@ ZEBRA_RES zebra_result_recid_to_sysno(ZebraHandle zh, void zebra_count_set(ZebraHandle zh, RSET rset, zint *count, zint approx_limit); +RSET zebra_create_rset_isam(ZebraHandle zh, + NMEM rset_nmem, struct rset_key_control *kctl, + int scope, ISAM_P pos, TERMID termid); + YAZ_END_CDECL #endif diff --git a/index/retrieve.c b/index/retrieve.c index 70d0da2..d3928d9 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.77 2007-12-03 11:49:11 adam Exp $ +/* $Id: retrieve.c,v 1.78 2007-12-03 13:04:04 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -614,8 +614,7 @@ zint freq_term(ZebraHandle zh, int ord, const char *term, RSET rset_set) RSET rsets[2], rset; memcpy(&isam_p, info+1, sizeof(ISAM_P)); - rsets[0] = rsisamb_create(nmem, kc, - 2, zh->reg->isamb, isam_p, 0); + rsets[0] = zebra_create_rset_isam(zh, nmem, kc, kc->scope, isam_p, 0); rsets[1] = rset_dup(rset_set); rset = rset_create_and(nmem, kc, kc->scope, 2, rsets); @@ -839,7 +838,7 @@ static ZEBRA_RES facet_fetch(ZebraHandle zh, const char *setname, *rec_bufp = odr_strdup(odr, wrbuf_cstr(wr)); wrbuf_destroy(wr); *rec_lenp = strlen(*rec_bufp); - *output_format = input_format; + *output_format = yaz_oid_recsyn_xml; xfree(pos_array); zebra_meta_records_destroy(zh, poset, num_recs); diff --git a/index/rpnsearch.c b/index/rpnsearch.c index c3d0544..1a82f99 100644 --- a/index/rpnsearch.c +++ b/index/rpnsearch.c @@ -1,4 +1,4 @@ -/* $Id: rpnsearch.c,v 1.24 2007-11-30 12:19:08 adam Exp $ +/* $Id: rpnsearch.c,v 1.25 2007-12-03 13:04:04 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -1345,13 +1345,6 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, return ZEBRA_FAIL; } - if (!zh->reg->isamb && !zh->reg->isamc) - { - zebra_setError_zint(zh, YAZ_BIB1_UNSUPP_POSITION_ATTRIBUTE, - position_value); - return ZEBRA_FAIL; - } - if (zebra_apt_get_ord(zh, zapt, index_type, 0, attributeSet, &ord) != ZEBRA_OK) { @@ -1365,13 +1358,9 @@ static ZEBRA_RES rpn_search_APT_position(ZebraHandle zh, { assert(*val == sizeof(ISAM_P)); memcpy(&isam_p, val+1, sizeof(isam_p)); - - if (zh->reg->isamb) - *rset = rsisamb_create(rset_nmem, kc, kc->scope, - zh->reg->isamb, isam_p, 0); - else if (zh->reg->isamc) - *rset = rsisamc_create(rset_nmem, kc, kc->scope, - zh->reg->isamc, isam_p, 0); + + *rset = zebra_create_rset_isam(zh, rset_nmem, kc, kc->scope, + isam_p, 0); } return ZEBRA_OK; } diff --git a/index/rset_isam.c b/index/rset_isam.c new file mode 100644 index 0000000..b862a4b --- /dev/null +++ b/index/rset_isam.c @@ -0,0 +1,58 @@ +/* $Id: rset_isam.c,v 1.1 2007-12-03 13:04:04 adam Exp $ + Copyright (C) 1995-2007 + Index Data ApS + +This file is part of the Zebra server. + +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 +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +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 this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +/** \file + \brief factory function for RSET from ISAM +*/ +#include +#include + +#include "index.h" +#include + +RSET zebra_create_rset_isam(ZebraHandle zh, + NMEM rset_nmem, struct rset_key_control *kctrl, + int scope, ISAM_P pos, TERMID termid) +{ + assert(zh); + assert(zh->reg); + if (zh->reg->isamb) + return rsisamb_create(rset_nmem, kctrl, scope, + zh->reg->isamb, pos, termid); + else if (zh->reg->isams) + return rsisams_create(rset_nmem, kctrl, scope, + zh->reg->isams, pos, termid); + else if (zh->reg->isamc) + return rsisamc_create(rset_nmem, kctrl, scope, + zh->reg->isamc, pos, termid); + else + return rset_create_null(rset_nmem, kctrl, termid); +} + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/index/trunc.c b/index/trunc.c index c664daa..9fb5854 100644 --- a/index/trunc.c +++ b/index/trunc.c @@ -1,4 +1,4 @@ -/* $Id: trunc.c,v 1.69 2007-10-29 16:57:53 adam Exp $ +/* $Id: trunc.c,v 1.70 2007-12-03 13:04:04 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -400,7 +400,7 @@ static int isamc_trunc_cmp(const void *p1, const void *p2) return 0; } -RSET rset_trunc(ZebraHandle zi, ISAM_P *isam_p, int no, +RSET rset_trunc(ZebraHandle zh, ISAM_P *isam_p, int no, const char *term, int length, const char *flags, int preserve_position, int term_type, NMEM rset_nmem, struct rset_key_control *kctrl, int scope, @@ -410,55 +410,36 @@ RSET rset_trunc(ZebraHandle zi, ISAM_P *isam_p, int no, TERMID termid; RSET result; int trunc_chunk; - + int trunc_limit = atoi(res_get_def(zh->res, "trunclimit", "10000")); + termid = rset_term_create(term, length, flags, term_type, rset_nmem, ol, *index_type, hits_limit, term_ref_id); + if (no < 1) return rset_create_null(rset_nmem, kctrl, termid); - - if (zi->reg->isams) + else if (no == 1) + return zebra_create_rset_isam(zh, rset_nmem, kctrl, + scope, *isam_p, termid); + else if (zh->reg->isamb && no > 1 && no < trunc_limit) { - if (no == 1) - return rsisams_create(rset_nmem, kctrl, scope, - zi->reg->isams, *isam_p, termid); - qsort(isam_p, no, sizeof(*isam_p), isams_trunc_cmp); - } - else if (zi->reg->isamc) - { - if (no == 1) - return rsisamc_create(rset_nmem, kctrl, scope, - zi->reg->isamc, *isam_p, termid); - qsort(isam_p, no, sizeof(*isam_p), isamc_trunc_cmp); + RSET r; + RSET *rsets = xmalloc(no*sizeof(RSET)); /* use nmem! */ + int i; + for (i = 0; ireg->isamb, isam_p[i], + 0 /* termid */); + r = rset_create_or(rset_nmem, kctrl, scope, + termid, no, rsets); + xfree(rsets); + return r; } - else if (zi->reg->isamb) - { - int trunc_limit = atoi(res_get_def(zi->res, "trunclimit", "10000")); - if (no == 1) - return rsisamb_create(rset_nmem, kctrl, scope, - zi->reg->isamb, *isam_p, termid); - else if (no < trunc_limit) - { - RSET r; - RSET *rsets = xmalloc(no*sizeof(RSET)); /* use nmem! */ - int i; - for (i = 0; ireg->isamb, isam_p[i], - 0 /* termid */); - r = rset_create_or(rset_nmem, kctrl, scope, - termid, no, rsets); - xfree(rsets); - return r; - } + if (zh->reg->isamc) qsort(isam_p, no, sizeof(*isam_p), isamc_trunc_cmp); - } else - { - yaz_log(YLOG_WARN, "Unknown isam set in rset_trunc"); - return rset_create_null(rset_nmem, kctrl, 0); - } - trunc_chunk = atoi(res_get_def(zi->res, "truncchunk", "20")); - result = rset_trunc_r(zi, term, length, flags, isam_p, 0, no, trunc_chunk, + qsort(isam_p, no, sizeof(*isam_p), isams_trunc_cmp); + trunc_chunk = atoi(res_get_def(zh->res, "truncchunk", "20")); + result = rset_trunc_r(zh, term, length, flags, isam_p, 0, no, trunc_chunk, preserve_position, term_type, rset_nmem, kctrl, scope, termid); return result; diff --git a/win/makefile b/win/makefile index 0452e24..cf61eaa 100644 --- a/win/makefile +++ b/win/makefile @@ -1,5 +1,5 @@ # Zebra makefile for MS NMAKE -# $Id: makefile,v 1.68 2007-11-23 14:00:16 adam Exp $ +# $Id: makefile,v 1.69 2007-12-03 13:04:04 adam Exp $ ########################################################### ############### Parameters @@ -406,6 +406,7 @@ ZEBRALIB_OBJS= \ $(OBJDIR)\rsbetween.obj \ $(OBJDIR)\rsbool.obj \ $(OBJDIR)\rset.obj \ + $(OBJDIR)\rset_isam.obj \ $(OBJDIR)\rsisamb.obj \ $(OBJDIR)\rsisamc.obj \ $(OBJDIR)\rsisams.obj \