X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=isamb%2Fisamb.c;h=4c1c803a8129193cb0feec0c64471581caa9799e;hb=a5c8c78e8671af863fc61b2ad8b24f92f827f7b2;hp=8a8dcd5ffe44c67ed847c3db05717bd3f1dba153;hpb=97a7adeb9e5059463f039495cc01cfa448463a27;p=idzebra-moved-to-github.git diff --git a/isamb/isamb.c b/isamb/isamb.c index 8a8dcd5..4c1c803 100644 --- a/isamb/isamb.c +++ b/isamb/isamb.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1995-2008 Index Data + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include @@ -47,14 +50,17 @@ struct ISAMB_head { #define INT_ENCODE 1 /* maximum size of encoded buffer */ -#define DST_ITEM_MAX 256 +#define DST_ITEM_MAX 5000 + +/* max page size for _any_ isamb use */ +#define ISAMB_MAX_PAGE 32768 #define ISAMB_MAX_LEVEL 10 /* approx 2*max page + max size of item */ -#define DST_BUF_SIZE (2*4096+300) +#define DST_BUF_SIZE (2*ISAMB_MAX_PAGE+DST_ITEM_MAX+100) /* should be maximum block size of multiple thereof */ -#define ISAMB_CACHE_ENTRY_SIZE 4096 +#define ISAMB_CACHE_ENTRY_SIZE ISAMB_MAX_PAGE /* CAT_MAX: _must_ be power of 2 */ #define CAT_MAX 4 @@ -566,6 +572,10 @@ struct ISAMB_block *new_block(ISAMB b, int leaf, int cat) zint block_no; block_no = b->file[cat].head.last_block++; p->pos = block_no * CAT_MAX + cat; + if (b->log_freelist) + yaz_log(b->log_freelist, "got block " + ZINT_FORMAT " from last %d:" ZINT_FORMAT, p->pos, + cat, p->pos/CAT_MAX); } else { @@ -581,8 +591,10 @@ struct ISAMB_block *new_block(ISAMB b, int leaf, int cat) zebra_exit("isamb:new_block"); } } - yaz_log(b->log_freelist, "got block " ZINT_FORMAT " from freelist %d:" ZINT_FORMAT, p->pos, - cat, p->pos/CAT_MAX); + if (b->log_freelist) + yaz_log(b->log_freelist, "got block " + ZINT_FORMAT " from freelist %d:" ZINT_FORMAT, p->pos, + cat, p->pos/CAT_MAX); memcpy(&b->file[cat].head.free_list, p->buf, sizeof(zint)); } p->cat = cat; @@ -661,6 +673,7 @@ void close_block(ISAMB b, struct ISAMB_block *p) p->pos, p->cat, p->pos/CAT_MAX); memcpy(p->buf, &b->file[p->cat].head.free_list, sizeof(zint)); b->file[p->cat].head.free_list = p->pos; + b->file[p->cat].head_dirty = 1; if (!cache_block(b, p->pos, p->buf, 1)) { yaz_log(b->log_io, "bf_write: close_block (deleted)"); @@ -786,7 +799,7 @@ int insert_int(ISAMB b, struct ISAMB_block *p, void *lookahead_item, #if INT_ENCODE const char *sub_item_ptr = sub_item; #endif - assert(sub_size < 128 && sub_size > 1); + assert(sub_size < DST_ITEM_MAX && sub_size > 1); memcpy(dst, startp, src - startp); @@ -1291,7 +1304,7 @@ void isamb_merge(ISAMB b, ISAM_P *pos, ISAMC_I *stream) #endif encode_ptr(&dst, p->pos); - assert(sub_size < 128 && sub_size > 1); + assert(sub_size < DST_ITEM_MAX && sub_size > 1); #if INT_ENCODE (*b->method->codec.reset)(c1); (*b->method->codec.encode)(c1, &dst, &sub_item_ptr); @@ -1665,6 +1678,7 @@ void isamb_set_root_ptr(ISAMB b, zint root_ptr) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab