-/* $Id: dcompact.c,v 1.8 2002-08-02 19:26:55 adam Exp $
+/* $Id: dcompact.c,v 1.9 2004-09-09 09:07:12 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
int no_dir = 0;
Dict dict_from, dict_to;
int *map, i;
- dict_from = dict_open (bfs, from_name, 0, 0, 0);
+ dict_from = dict_open (bfs, from_name, 0, 0, 0, 4096);
if (!dict_from)
return -1;
map = (int *) xmalloc ((dict_from->head.last+1) * sizeof(*map));
for (i = 0; i <= (int) (dict_from->head.last); i++)
map[i] = -1;
- dict_to = dict_open (bfs, to_name, 0, 1, 1);
+ dict_to = dict_open (bfs, to_name, 0, 1, 1, 4096);
if (!dict_to)
return -1;
map[0] = 0;
-/* $Id: dicttest.c,v 1.28 2004-01-22 11:27:20 adam Exp $
+/* $Id: dicttest.c,v 1.29 2004-09-09 09:07:12 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
logf (LOG_FATAL, "bfs_create fail");
exit (1);
}
- dict = dict_open (bfs, name, cache, rw, 0);
+ dict = dict_open (bfs, name, cache, rw, 0, 4096);
if (!dict)
{
logf (LOG_FATAL, "dict_open fail of `%s'", name);
-/* $Id: open.c,v 1.19 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: open.c,v 1.20 2004-09-09 09:07:12 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
#include <dict.h>
Dict dict_open (BFiles bfs, const char *name, int cache, int rw,
- int compact_flag)
+ int compact_flag, int page_size)
{
Dict dict;
void *head_buf;
- char resource_str[80];
- int page_size;
dict = (Dict) xmalloc (sizeof(*dict));
if (cache < 5)
cache = 5;
- sprintf (resource_str, "dict.%s.pagesize", name);
dict->grep_cmap = NULL;
page_size = DICT_DEFAULT_PAGESIZE;
if (page_size < 2048)
{
- logf (LOG_WARN, "Resource %s was too small. Set to 2048",
- resource_str);
+ logf (LOG_WARN, "Page size for dict %s %d<2048. Set to 2048",
+ name, page_size);
page_size = 2048;
}
dict->dbf = dict_bf_open (bfs, name, page_size, cache, rw);
}
if (dict->head.page_size != page_size)
{
- logf (LOG_WARN, "Resource %s is %d and pagesize of `%s' is %d",
- resource_str, page_size, name, dict->head.page_size);
- return 0;
+ logf (LOG_WARN, "Page size for existing dict %s is %d. Current is %d",
+ name, dict->head.page_size, page_size);
}
}
if (dict->head.compact_flag)
-/* $Id: dict.h,v 1.32 2002-08-02 19:26:55 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
+/* $Id: dict.h,v 1.33 2004-09-09 09:07:12 adam Exp $
+ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
This file is part of the Zebra server.
void dict_bf_compact (Dict_BFile dbf);
Dict dict_open (BFiles bfs, const char *name, int cache, int rw,
- int compact_flag);
+ int compact_flag, int page_size);
int dict_close (Dict dict);
int dict_insert (Dict dict, const char *p, int userlen, void *userinfo);
int dict_delete (Dict dict, const char *p);
-/* $Id: index.h,v 1.117 2004-09-01 15:01:32 heikki Exp $
+/* $Id: index.h,v 1.118 2004-09-09 09:07:12 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
void iscz1_decode (void *vp, char **dst, const char **src);
void iscz1_encode (void *vp, char **dst, const char **src);
+Dict dict_open_res (BFiles bfs, const char *name, int cache, int rw,
+ int compact_flag, Res res);
+
YAZ_END_CDECL
#endif
-/* $Id: trav.c,v 1.44 2004-01-22 11:27:21 adam Exp $
+/* $Id: trav.c,v 1.45 2004-09-09 09:07:12 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
Index Data Aps
Dict dict;
struct dirs_info *di;
- if (!(dict = dict_open (zh->reg->bfs, FMATCH_DICT, 50, 0, 0)))
+ if (!(dict = dict_open_res (zh->reg->bfs, FMATCH_DICT, 50, 0, 0, zh->res)))
{
yaz_log (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
return;
if (zh->m_record_id && !strcmp (zh->m_record_id, "file"))
{
Dict dict;
- if (!(dict = dict_open (zh->reg->bfs, FMATCH_DICT, 50,
- zh->m_flag_rw, 0)))
+ if (!(dict = dict_open_res (zh->reg->bfs, FMATCH_DICT, 50,
+ zh->m_flag_rw, 0, zh->res)))
{
yaz_log (LOG_FATAL, "dict_open fail of %s", FMATCH_DICT);
return ;
-/* $Id: zebraapi.c,v 1.128 2004-09-03 14:59:49 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
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;