-/* $Id: zebraapi.c,v 1.124 2004-08-10 08:19:15 heikki Exp $
+/* $Id: zebraapi.c,v 1.129 2004-09-09 09:07:12 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)
strcat(path, "zebrasrv.pid");
}
+Dict dict_open_res (BFiles bfs, const char *name, int cache, int rw,
+ int compact_flag, Res res)
+{
+ int page_size = 4096;
+ char resource_str[200];
+ const char *v;
+ sprintf (resource_str, "dict.%.100s.pagesize", name);
+
+ v = res_get(res, resource_str);
+ if (v)
+ {
+ page_size = atoi(v);
+ yaz_log(LOG_LOG, "Using custom dictionary page size %d for %s",
+ page_size, name);
+ }
+ return dict_open(bfs, name, cache, rw, compact_flag, page_size);
+}
+
+
static
struct zebra_register *zebra_register_open (ZebraService zs, const char *name,
int rw, int useshadow, Res res,
}
if (rw)
{
- reg->matchDict = dict_open (reg->bfs, GMATCH_DICT, 20, 1, 0);
+ reg->matchDict = dict_open_res (reg->bfs, GMATCH_DICT, 20, 1, 0, res);
}
- if (!(reg->dict = dict_open (reg->bfs, FNAME_DICT, 40, rw, 0)))
+ if (!(reg->dict = dict_open_res (reg->bfs, FNAME_DICT, 40, rw, 0, res)))
{
logf (LOG_WARN, "dict_open");
return 0;
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;
}
/* ---------------------------------------------------------------------------
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,