X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fzebraapi.c;h=3b62367c6890701a64530f82cf11e6ba4388d2b8;hb=c3143b73c994edc3e1ec3dff53b91136ac00437c;hp=750c32661fcd056d8ccca248c3c30983e8ad4b89;hpb=c6d31ee570fabe247e8b1fe708d04b9684cf43e3;p=idzebra-moved-to-github.git diff --git a/index/zebraapi.c b/index/zebraapi.c index 750c326..3b62367 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.108 2003-06-23 14:35:41 heikki Exp $ +/* $Id: zebraapi.c,v 1.111 2003-07-07 13:55:37 pop Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003 Index Data Aps @@ -793,7 +793,7 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, ZebraRetrievalRecord *recs) { ZebraPosSet poset; - int i, *pos_array; + int i, *pos_array, ret = 0; ASSERTZH; yaz_log(LOG_API,"zebra_records_retrieve n=%d",num_recs); zh->errCode=0; @@ -802,13 +802,13 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, { zh->errCode = 30; zh->errString = odr_strdup (stream, setname); - return 1; + return -1; } zh->errCode = 0; if (zebra_begin_read (zh)) - return 1; + return -1; pos_array = (int *) xmalloc (num_recs * sizeof(*pos_array)); for (i = 0; ierrCode = 30; zh->errString = nmem_strdup (stream->mem, setname); + ret = -1; } else { @@ -849,6 +850,7 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, sprintf (num_str, "%d", pos_array[i]); zh->errCode = 13; zh->errString = odr_strdup (stream, num_str); + ret = -1; break; } } @@ -856,7 +858,7 @@ int zebra_records_retrieve (ZebraHandle zh, ODR stream, } zebra_end_read (zh); xfree (pos_array); - return 0; + return ret; } int zebra_scan (ZebraHandle zh, ODR stream, Z_AttributesPlusTerm *zapt, @@ -1098,11 +1100,59 @@ int zebra_admin_exchange_record (ZebraHandle zh, return 0; } +int delete_w_handle(const char *info, void *handle) +{ + ZebraHandle zh = (ZebraHandle) handle; + ISAMC_P pos; + + if (*info == sizeof(pos)) + { + memcpy (&pos, info+1, sizeof(pos)); + isamb_unlink(zh->reg->isamb, pos); + } + return 0; +} + +static int delete_SU_handle(void *handle, int ord) +{ + ZebraHandle zh = (ZebraHandle) handle; + char ord_buf[20]; + int ord_len; + + ord_len = key_SU_encode (ord, ord_buf); + ord_buf[ord_len] = '\0'; + + assert (zh->reg->isamb); + dict_delete_subtree(zh->reg->dict, ord_buf, + zh, delete_w_handle); + return 0; +} + +int zebra_drop_database (ZebraHandle zh, const char *database) +{ + ASSERTZH; + yaz_log(LOG_API,"zebra_drop_database"); + zh->errCode = 0; + + if (zebra_select_database (zh, database)) + return -1; + if (zebra_begin_trans (zh, 1)) + return -1; + if (zh->reg->isamb) + { + zebraExplain_curDatabase (zh->reg->zei, database); + + zebraExplain_trav_ord(zh->reg->zei, zh, delete_SU_handle); + zebraExplain_removeDatabase(zh->reg->zei, zh); + } + zebra_end_trans (zh); + return 0; +} + int zebra_create_database (ZebraHandle zh, const char *database) { - ZebraService zs; ASSERTZH; - yaz_log(LOG_API,"zebra_admin_create"); + yaz_log(LOG_API,"zebra_create_database"); zh->errCode=0; if (zebra_select_database (zh, database)) @@ -1110,7 +1160,6 @@ int zebra_create_database (ZebraHandle zh, const char *database) if (zebra_begin_trans (zh, 1)) return -1; - zs = zh->service; /* announce database */ if (zebraExplain_newDatabase (zh->reg->zei, database, 0 /* explainDatabase */)) @@ -2058,6 +2107,8 @@ int zebra_search_PQF (ZebraHandle zh, const char *pqf_query, odr_destroy(odr); + yaz_log(LOG_API,"Hits: %d",numhits); + if (numhits) *numhits=hits; @@ -2068,11 +2119,11 @@ int zebra_search_PQF (ZebraHandle zh, const char *pqf_query, Sort - a simplified interface, with optional read locks. FIXME - This is a horrible name, will conflict with half the applications */ -int zebra_sort_2 (ZebraHandle zh, - ODR stream, - const char *sort_spec, - const char *output_setname, - const char **input_setnames) +int zebra_sort_by_specstr (ZebraHandle zh, + ODR stream, + const char *sort_spec, + const char *output_setname, + const char **input_setnames) { int num_input_setnames = 0; int sort_status = 0;