From b547f7eb4e4ae29d08a2c0fb7e2108b22ade3dd7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 20 May 2003 12:52:49 +0000 Subject: [PATCH] ODR handles no longer needed for zebra_search_{rpn,PQF} --- include/zebraapi.h | 8 ++++++-- index/index.h | 8 ++++---- index/zebraapi.c | 39 +++++++++++++++++---------------------- index/zserver.c | 4 ++-- index/zsets.c | 6 +++--- perl/IDZebra.i | 4 +--- test/api/t2.c | 13 ++++++------- 7 files changed, 39 insertions(+), 43 deletions(-) diff --git a/include/zebraapi.h b/include/zebraapi.h index eecaab0..1733617 100644 --- a/include/zebraapi.h +++ b/include/zebraapi.h @@ -1,4 +1,4 @@ -/* $Id: zebraapi.h,v 1.3 2003-04-24 19:47:30 adam Exp $ +/* $Id: zebraapi.h,v 1.4 2003-05-20 12:52:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -132,6 +132,10 @@ YAZ_EXPORT void zebra_search_rpn (ZebraHandle zh, ODR input, ODR output, Z_RPNQuery *query, const char *setname, int *hits); +YAZ_EXPORT int zebra_search_PQF (ZebraHandle zh, + const char *pqf_query, + const char *setname); + /* Retrieve record(s) */ YAZ_EXPORT void zebra_records_retrieve (ZebraHandle zh, ODR stream, const char *setname, Z_RecordComposition *comp, @@ -172,7 +176,7 @@ YAZ_EXPORT int zebra_string_norm (ZebraHandle zh, unsigned reg_id, * Admin */ -YAZ_EXPORT void zebra_admin_create (ZebraHandle zh, const char *db); +YAZ_EXPORT void zebra_create_database (ZebraHandle zh, const char *db); YAZ_EXPORT void zebra_admin_shutdown (ZebraHandle zh); diff --git a/index/index.h b/index/index.h index e8957c5..a3f9426 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.98 2003-03-26 16:41:48 adam Exp $ +/* $Id: index.h,v 1.99 2003-05-20 12:52:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -361,9 +361,9 @@ void resultSetAddTerm (ZebraHandle zh, ZebraSet s, int reg_type, int use, const char *term); ZebraSet resultSetAdd (ZebraHandle zh, const char *name, int ov); ZebraSet resultSetGet (ZebraHandle zh, const char *name); -ZebraSet resultSetAddRPN (ZebraHandle zh, ODR stream, ODR decode, - Z_RPNQuery *rpn, int num_bases, - char **basenames, const char *setname); +ZebraSet resultSetAddRPN (ZebraHandle zh, Z_RPNQuery *rpn, + int num_bases, char **basenames, + const char *setname); RSET resultSetRef (ZebraHandle zh, const char *resultSetId); void resultSetDestroy (ZebraHandle zh, int num_names, char **names, int *statuses); diff --git a/index/zebraapi.c b/index/zebraapi.c index 22e60a5..45bee3e 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.99 2003-05-13 13:52:12 adam Exp $ +/* $Id: zebraapi.c,v 1.100 2003-05-20 12:52:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -757,7 +757,7 @@ void zebra_search_rpn (ZebraHandle zh, ODR decode, ODR stream, zebra_livcode_transform(zh, query); - resultSetAddRPN (zh, decode, stream, query, + resultSetAddRPN (zh, query, zh->num_basenames, zh->basenames, setname); zebra_end_read (zh); @@ -1032,7 +1032,7 @@ int zebra_admin_exchange_record (ZebraHandle zh, return 0; } -void zebra_admin_create (ZebraHandle zh, const char *database) +void zebra_create_database (ZebraHandle zh, const char *database) { ZebraService zs; ASSERTZH; @@ -1894,43 +1894,38 @@ int zebra_delete_record (ZebraHandle zh, is not mandatory. (it's repeatable now, also in zebraapi.c) */ -void zebra_search_RPN (ZebraHandle zh, ODR decode, ODR stream, - Z_RPNQuery *query, const char *setname, int *hits) +void zebra_search_RPN (ZebraHandle zh, Z_RPNQuery *query, + const char *setname, int *hits) { zh->hits = 0; *hits = 0; if (zebra_begin_read (zh)) return; - resultSetAddRPN (zh, decode, stream, query, - zh->num_basenames, zh->basenames, setname); + resultSetAddRPN (zh, query, zh->num_basenames, zh->basenames, setname); zebra_end_read (zh); *hits = zh->hits; } -int zebra_search_PQF (ZebraHandle zh, - ODR odr_input, ODR odr_output, - const char *pqf_query, +int zebra_search_PQF (ZebraHandle zh, const char *pqf_query, const char *setname) - { - int hits; + int hits = 0; Z_RPNQuery *query; - query = p_query_rpn (odr_input, PROTO_Z3950, pqf_query); + ODR odr = odr_createmem(ODR_ENCODE); - if (!query) { - logf (LOG_WARN, "bad query %s\n", pqf_query); - odr_reset (odr_input); - return(0); - } - zebra_search_RPN (zh, odr_input, odr_output, query, setname, &hits); + query = p_query_rpn (odr, PROTO_Z3950, pqf_query); - odr_reset (odr_input); - odr_reset (odr_output); + if (!query) + yaz_log (LOG_WARN, "bad query %s\n", pqf_query); + else + zebra_search_RPN (zh, query, setname, &hits); - return(hits); + odr_destroy(odr); + + return hits; } /* --------------------------------------------------------------------------- diff --git a/index/zserver.c b/index/zserver.c index 24b7648..c73c02c 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -1,4 +1,4 @@ -/* $Id: zserver.c,v 1.104 2003-03-04 23:30:20 adam Exp $ +/* $Id: zserver.c,v 1.105 2003-05-20 12:52:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -383,7 +383,7 @@ static int es_admin_request (ZebraHandle zh, Z_AdminEsRequest *r) break; case Z_ESAdminOriginPartToKeep_create: yaz_log(LOG_LOG, "adm-create %s", r->toKeep->databaseName); - zebra_admin_create (zh, r->toKeep->databaseName); + zebra_create_database (zh, r->toKeep->databaseName); break; case Z_ESAdminOriginPartToKeep_import: yaz_log(LOG_LOG, "adm-import"); diff --git a/index/zsets.c b/index/zsets.c index 299a534..51e48af 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -1,4 +1,4 @@ -/* $Id: zsets.c,v 1.44 2003-03-26 16:41:48 adam Exp $ +/* $Id: zsets.c,v 1.45 2003-05-20 12:52:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -70,7 +70,7 @@ struct zset_sort_info { struct zset_sort_entry **entries; }; -ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output, +ZebraSet resultSetAddRPN (ZebraHandle zh, Z_RPNQuery *rpn, int num_bases, char **basenames, const char *setname) @@ -96,7 +96,7 @@ ZebraSet resultSetAddRPN (ZebraHandle zh, ODR input, ODR output, zebraSet->basenames[i] = nmem_strdup (zebraSet->nmem, basenames[i]); - zebraSet->rset = rpn_search (zh, output->mem, rpn, + zebraSet->rset = rpn_search (zh, zebraSet->nmem, rpn, zebraSet->num_bases, zebraSet->basenames, zebraSet->name, zebraSet); diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 3878c04..2881661 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -323,15 +323,13 @@ int zebra_delete_record (ZebraHandle zh, int force_update); -/* == Search (zebra_api_ext.c) ============================================= */ +/* == Search (zebraapi.c) ================================================== */ %name(search_PQF) int zebra_search_PQF (ZebraHandle zh, - ODR odr_input, ODR odr_output, const char *pqf_query, const char *setname); - /* == YAZ - query tools ==================================================== */ diff --git a/test/api/t2.c b/test/api/t2.c index 2db3bd3..fc359fe 100644 --- a/test/api/t2.c +++ b/test/api/t2.c @@ -1,4 +1,4 @@ -/* $Id: t2.c,v 1.4 2003-03-04 23:30:20 adam Exp $ +/* $Id: t2.c,v 1.5 2003-05-20 12:52:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -26,6 +26,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA int main(int argc, char **argv) { + int ret, hits; ZebraService zs; ZebraHandle zh; const char *myrec = @@ -36,22 +37,20 @@ int main(int argc, char **argv) nmem_init (); - odr_input = odr_createmem (ODR_DECODE); - odr_output = odr_createmem (ODR_ENCODE); - zs = zebra_start("t2.cfg"); zh = zebra_open (zs); zebra_select_database(zh, "Default"); zebra_begin_trans (zh, 1); zebra_record_insert (zh, myrec, strlen(myrec)); + + hits = zebra_search_PQF (zh, "@attr 1=4 my", "set1"); + printf ("hits: %d\n", hits); + zebra_end_trans (zh); zebra_commit (zh); zebra_close (zh); zebra_stop (zs); - odr_destroy (odr_input); - odr_destroy (odr_output); - nmem_exit (); xmalloc_trav ("x"); exit (0); -- 1.7.10.4