-/* $Id: zebraapi.c,v 1.121 2004-08-04 08:35:23 adam Exp $
+/* $Id: zebraapi.c,v 1.127 2004-08-25 09:23:36 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
#include <assert.h>
#include <stdio.h>
+#include <limits.h>
#ifdef WIN32
#include <io.h>
#include <process.h>
#include <yaz/sortspec.h>
#include "index.h"
#include <charmap.h>
-#include "zebraapi.h"
+#include <idzebra/api.h>
/* simple asserts to validate the most essential input args */
#define ASSERTZH assert(zh && zh->service)
reg->sortIdx = 0;
reg->isams = 0;
reg->matchDict = 0;
- reg->isam = 0;
reg->isamc = 0;
reg->isamb = 0;
reg->zei = 0;
return 0;
}
}
- if (res_get_match (res, "isam", "i", ISAM_DEFAULT))
- {
- if (!(reg->isam = is_open (reg->bfs, FNAME_ISAM, key_compare, rw,
- sizeof (struct it_key), res)))
- {
- logf (LOG_WARN, "is_open");
- return 0;
- }
- }
if (res_get_match (res, "isam", "c", ISAM_DEFAULT))
{
struct ISAMC_M_s isamc_m;
sortIdx_close (reg->sortIdx);
if (reg->isams)
isams_close (reg->isams);
- if (reg->isam)
- is_close (reg->isam);
if (reg->isamc)
isc_close (reg->isamc);
if (reg->isamb)
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;
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;
}
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);
match, fname,
force_update,
1); /* allow_update */
- yaz_log(LOG_LOG, "zebra_update_record returned res=%d", res);
zebra_end_trans(zh);
return res;
}