X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=index%2Fzebraapi.c;h=3d9d89f246a9de2427fd4fd41cc5af20b12d4776;hp=d1c4baa56b1ebd757ab7236ea8746d66e42cd693;hb=13bf0c380e98816595127291b64368dd9b8ca639;hpb=f7e93f016e75e43d037b5c3e89aeb27b7176513a diff --git a/index/zebraapi.c b/index/zebraapi.c index d1c4baa..3d9d89f 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.123 2004-08-06 13:14:46 adam Exp $ +/* $Id: zebraapi.c,v 1.128 2004-09-03 14:59:49 heikki Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -22,6 +22,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include +#include #ifdef WIN32 #include #include @@ -35,7 +36,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "index.h" #include -#include "zebraapi.h" +#include /* simple asserts to validate the most essential input args */ #define ASSERTZH assert(zh && zh->service) @@ -765,6 +766,8 @@ int zebra_select_databases (ZebraHandle zh, int num_bases, int zebra_search_RPN (ZebraHandle zh, ODR o, Z_RPNQuery *query, const char *setname, int *hits) { + const char *max; + zint maxhits; ASSERTZH; yaz_log(LOG_API,"zebra_search_rpn"); zh->errCode=0; @@ -780,8 +783,21 @@ int zebra_search_RPN (ZebraHandle zh, ODR o, zh->num_basenames, zh->basenames, setname); zebra_end_read (zh); - - *hits = zh->hits; + max = res_get (zh->res, "maxhits"); + if (max) + maxhits=atoi(max); + else { + int i=0; + maxhits=INT_MAX; + while (maxhits>100) { maxhits/=10; i++;} + while (i--) maxhits *= 10; + } + if (zh->hits > maxhits) { /* too large for yaz to handle */ + logf(LOG_LOG,"limiting hits to "ZINT_FORMAT, maxhits); + *hits=maxhits; /* round it down to two digits, to look like rounded */ + } + else + *hits = zh->hits; return 0; } @@ -1561,7 +1577,8 @@ int zebra_end_transaction (ZebraHandle zh, ZebraTransactionStatus *status) zebra_register_close (zh->service, zh->reg); zh->reg = 0; - yaz_log (LOG_LOG, "Records: %7d i/u/d %d/%d/%d", + yaz_log (LOG_LOG, "Records: "ZINT_FORMAT" i/u/d " + ZINT_FORMAT"/"ZINT_FORMAT"/"ZINT_FORMAT, zh->records_processed, zh->records_inserted, zh->records_updated, zh->records_deleted); @@ -2042,7 +2059,6 @@ 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_by_specstr (ZebraHandle zh, ODR stream,