From b718b0a9f4aaf52d38031bfb82d0d539e50332d6 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 4 Nov 1999 15:00:45 +0000 Subject: [PATCH] Implemented delete result set(s). --- index/zebraapi.c | 31 +++++++++++++++++++++++++-- index/zebraapi.h | 10 ++++++++- index/zserver.c | 18 ++++++++++++---- index/zserver.h | 8 +++++-- index/zsets.c | 61 ++++++++++++++++++++++++++++++++++++++---------------- 5 files changed, 101 insertions(+), 27 deletions(-) diff --git a/index/zebraapi.c b/index/zebraapi.c index 3400ea9..50b9988 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.c,v $ - * Revision 1.24 1999-10-14 14:33:50 adam + * Revision 1.25 1999-11-04 15:00:45 adam + * Implemented delete result set(s). + * + * Revision 1.24 1999/10/14 14:33:50 adam * Added truncation 5=106. * * Revision 1.23 1999/09/07 11:36:32 adam @@ -328,7 +331,7 @@ void zebra_close (ZebraHandle zh) zebra_chdir (zh); if (zh->records) { - resultSetDestroy (zh); + resultSetDestroy (zh, -1, 0, 0); zebraExplain_close (zh->zei, 0, 0); dict_close (zh->dict); sortIdx_close (zh->sortIdx); @@ -516,6 +519,30 @@ void zebra_sort (ZebraHandle zh, ODR stream, zebra_register_unlock (zh); } +int zebra_deleleResultSet(ZebraHandle zh, int function, + int num_setnames, char **setnames, + int *statuses) +{ + int i, status; + if (zebra_register_lock (zh)) + return Z_DeleteStatus_systemProblemAtTarget; + switch (function) + { + case Z_DeleteRequest_list: + resultSetDestroy (zh, num_setnames, setnames, statuses); + break; + case Z_DeleteRequest_all: + resultSetDestroy (zh, -1, 0, statuses); + break; + } + zebra_register_unlock (zh); + status = Z_DeleteStatus_success; + for (i = 0; ierrCode; diff --git a/index/zebraapi.h b/index/zebraapi.h index 21a6e81..f092167 100644 --- a/index/zebraapi.h +++ b/index/zebraapi.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zebraapi.h,v $ - * Revision 1.6 1999-02-17 11:29:57 adam + * Revision 1.7 1999-11-04 15:00:45 adam + * Implemented delete result set(s). + * + * Revision 1.6 1999/02/17 11:29:57 adam * Fixed in record_fetch. Minor updates to API. * * Revision 1.5 1998/09/22 10:48:19 adam @@ -74,6 +77,11 @@ YAZ_EXPORT void zebra_scan (ZebraHandle zh, ODR stream, int *position, int *num_entries, ZebraScanEntry **list, int *is_partial); + +/* Delete Result Set(s) */ +YAZ_EXPORT int zebra_deleleResultSet(ZebraHandle zh, int function, + int num_setnames, char **setnames, + int *statuses); /* Close zebra and destroy handle */ YAZ_EXPORT void zebra_close (ZebraHandle zh); diff --git a/index/zserver.c b/index/zserver.c index 4cfeb3a..a7e29fd 100644 --- a/index/zserver.c +++ b/index/zserver.c @@ -4,9 +4,8 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.c,v $ - * Revision 1.72 1999-10-29 10:01:54 adam - * Minor fix in bend_init where handle wasn't set to NULL when - * zebra_init fails. + * Revision 1.73 1999-11-04 15:00:45 adam + * Implemented delete result set(s). * * Revision 1.71 1999/07/14 10:59:26 adam * Changed functions isc_getmethod, isams_getmethod. @@ -282,6 +281,7 @@ #endif static int bend_sort (void *handle, bend_sort_rr *rr); +static int bend_delete (void *handle, bend_delete_rr *rr); bend_initresult *bend_init (bend_initrequest *q) { @@ -292,10 +292,10 @@ bend_initresult *bend_init (bend_initrequest *q) char *user = NULL; char *passwd = NULL; - r->handle = 0; r->errcode = 0; r->errstring = 0; q->bend_sort = bend_sort; + q->bend_delete = bend_delete; logf (LOG_DEBUG, "bend_init"); @@ -446,6 +446,16 @@ int bend_sort (void *handle, bend_sort_rr *rr) return 0; } +int bend_delete (void *handle, bend_delete_rr *rr) +{ + ZebraHandle zh = (ZebraHandle) handle; + + rr->delete_status = zebra_deleleResultSet(zh, rr->function, + rr->num_setnames, rr->setnames, + rr->statuses); + return 0; +} + #ifndef WIN32 static void bend_start (struct statserv_options_block *sob) { diff --git a/index/zserver.h b/index/zserver.h index 18bde7d..a4c2f24 100644 --- a/index/zserver.h +++ b/index/zserver.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zserver.h,v $ - * Revision 1.43 1999-07-14 10:59:27 adam + * Revision 1.44 1999-11-04 15:00:45 adam + * Implemented delete result set(s). + * + * Revision 1.43 1999/07/14 10:59:27 adam * Changed functions isc_getmethod, isams_getmethod. * Improved fatal error handling (such as missing EXPLAIN schema). * @@ -244,7 +247,8 @@ 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); RSET resultSetRef (ZebraHandle zh, Z_ResultSetId *resultSetId); -void resultSetDestroy (ZebraHandle zh); +void resultSetDestroy (ZebraHandle zh, int num_names, char **names, + int *statuses); ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, int num, int *positions); diff --git a/index/zsets.c b/index/zsets.c index 6394f3d..d0ce024 100644 --- a/index/zsets.c +++ b/index/zsets.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: zsets.c,v $ - * Revision 1.23 1999-05-26 07:49:13 adam + * Revision 1.24 1999-11-04 15:00:45 adam + * Implemented delete result set(s). + * + * Revision 1.23 1999/05/26 07:49:13 adam * C++ compilation. * * Revision 1.22 1999/02/02 14:51:15 adam @@ -218,26 +221,48 @@ ZebraSet resultSetGet (ZebraHandle zh, const char *name) return NULL; } - -void resultSetDestroy (ZebraHandle zh) +void resultSetDestroy (ZebraHandle zh, int num, char **names,int *statuses) { - ZebraSet s, s1; - - for (s = zh->sets; s; s = s1) + ZebraSet *ss = &zh->sets; + int i; + + if (statuses) + for (i = 0; ierrCode = 0; + zh->errString = NULL; + while (*ss) { - s1 = s->next; - - xfree (s->sort_info->all_entries); - xfree (s->sort_info->entries); - xfree (s->sort_info); - - if (s->nmem) - nmem_destroy (s->nmem); - rset_delete (s->rset); - xfree (s->name); - xfree (s); + int i = -1; + ZebraSet s = *ss; + if (num >= 0) + { + for (i = 0; iname, names[i])) + { + if (statuses) + statuses[i] = Z_DeleteStatus_success; + i = -1; + break; + } + } + if (i < 0) + { + *ss = s->next; + + xfree (s->sort_info->all_entries); + xfree (s->sort_info->entries); + xfree (s->sort_info); + + if (s->nmem) + nmem_destroy (s->nmem); + rset_delete (s->rset); + xfree (s->name); + xfree (s); + } + else + ss = &s->next; } - zh->sets = NULL; } ZebraPosSet zebraPosSetCreate (ZebraHandle zh, const char *name, -- 1.7.10.4