1 /* $Id: isamd.c,v 1.25 2003-03-05 16:41:10 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
32 #include "../index/index.h" /* isamd uses the internal structure of it_key */
35 static void flush_block (ISAMD is, int cat);
36 static void release_fc (ISAMD is, int cat);
37 static void init_fc (ISAMD is, int cat);
39 #define ISAMD_FREELIST_CHUNK 1
43 ISAMD_M isamd_getmethod (ISAMD_M me)
45 static struct ISAMD_filecat_s def_cat[] = {
47 /* blocksz, max. Unused time being */
48 { 32, 40 }, /* 24 is the smallest unreasonable size! */
73 { 24, 1 }, /* Experimental sizes */
84 ISAMD_M m = (ISAMD_M) xmalloc (sizeof(*m)); /* never released! */
85 m->filecat = def_cat; /* ok, only alloc'd once */
92 m->compare_item = NULL;
94 m->debug = 0; /* default to no debug */
96 m->max_blocks_mem = 10;
103 ISAMD isamd_open (BFiles bfs, const char *name, int writeflag, ISAMD_M method)
106 ISAMD_filecat filecat;
109 is = (ISAMD) xmalloc (sizeof(*is));
111 is->method = (ISAMD_M) xmalloc (sizeof(*is->method));
112 memcpy (is->method, method, sizeof(*method));
113 filecat = is->method->filecat;
116 /* determine number of block categories */
117 if (is->method->debug>0)
118 logf (LOG_LOG, "isamd: bsize maxkeys");
121 if (is->method->debug>0)
122 logf (LOG_LOG, "isamd:%6d %6d",
123 filecat[i].bsize, filecat[i].mblocks);
124 } while (filecat[i++].mblocks);
128 assert (is->no_files > 0);
129 assert (is->max_cat <=8 ); /* we have only 3 bits for it */
131 is->files = (ISAMD_file) xmalloc (sizeof(*is->files)*is->no_files);
133 for (i = 0; i<is->no_files; i++)
137 sprintf (fname, "%s%c", name, i+'A');
138 is->files[i].bf = bf_open (bfs, fname, is->method->filecat[i].bsize,
140 is->files[i].head_is_dirty = 0;
141 if (!bf_read (is->files[i].bf, 0, 0, sizeof(ISAMD_head),
144 is->files[i].head.lastblock = 1;
145 is->files[i].head.freelist = 0;
147 is->files[i].alloc_entries_num = 0;
148 is->files[i].alloc_entries_max =
149 is->method->filecat[i].bsize / sizeof(int) - 1;
150 is->files[i].alloc_buf = (char *)
151 xmalloc (is->method->filecat[i].bsize);
152 is->files[i].no_writes = 0; /* clear statistics */
153 is->files[i].no_reads = 0;
154 is->files[i].no_skip_writes = 0;
155 is->files[i].no_allocated = 0;
156 is->files[i].no_released = 0;
157 is->files[i].no_remap = 0;
158 is->files[i].no_forward = 0;
159 is->files[i].no_backward = 0;
160 is->files[i].sum_forward = 0;
161 is->files[i].sum_backward = 0;
162 is->files[i].no_next = 0;
163 is->files[i].no_prev = 0;
164 is->files[i].no_op_diffonly=0;
165 is->files[i].no_op_main=0;
192 int isamd_block_used (ISAMD is, int type)
194 if ( type==-1) /* singleton */
196 if (type < 0 || type >= is->no_files)
198 return is->files[type].head.lastblock-1;
201 int isamd_block_size (ISAMD is, int type)
203 ISAMD_filecat filecat = is->method->filecat;
204 if ( type==-1) /* singleton */
205 return 0; /* no bytes used */
206 if (type < 0 || type >= is->no_files)
208 return filecat[type].bsize;
211 int isamd_close (ISAMD is)
216 if (is->method->debug>0)
218 logf (LOG_LOG, "isamd statistics");
219 logf (LOG_LOG, "f nxt forw mid-f prev backw mid-b");
220 for (i = 0; i<is->no_files; i++)
221 logf (LOG_LOG, "%d%7d%7d%7.1f%7d%7d%7.1f",i,
222 is->files[i].no_next,
223 is->files[i].no_forward,
224 is->files[i].no_forward ?
225 (double) is->files[i].sum_forward/is->files[i].no_forward
227 is->files[i].no_prev,
228 is->files[i].no_backward,
229 is->files[i].no_backward ?
230 (double) is->files[i].sum_backward/is->files[i].no_backward
233 if (is->method->debug>0)
234 logf (LOG_LOG, "f writes reads skipped alloc released ");
235 for (i = 0; i<is->no_files; i++)
238 assert (is->files[i].bf);
239 if (is->files[i].head_is_dirty)
240 bf_write (is->files[i].bf, 0, 0, sizeof(ISAMD_head),
242 if (is->method->debug>0)
243 logf (LOG_LOG, "%d%8d%8d%8d%8d%8d",i,
244 is->files[i].no_writes,
245 is->files[i].no_reads,
246 is->files[i].no_skip_writes,
247 is->files[i].no_allocated,
248 is->files[i].no_released);
249 xfree (is->files[i].fc_list);
251 bf_close (is->files[i].bf);
254 if (is->method->debug>0)
256 logf (LOG_LOG, "f opens main diffonly");
257 for (i = 0; i<is->no_files; i++)
259 logf (LOG_LOG, "%d%8d%8d%8d",i,
260 is->files[i].no_op_main+
261 is->files[i].no_op_diffonly,
262 is->files[i].no_op_main,
263 is->files[i].no_op_diffonly);
265 logf(LOG_LOG,"open single %8d", is->no_op_single);
266 logf(LOG_LOG,"open new %8d", is->no_op_new);
268 logf(LOG_LOG, "new build %8d", is->no_fbuilds);
269 logf(LOG_LOG, "append %8d", is->no_appds);
270 logf(LOG_LOG, " merges %8d", is->no_merges);
271 logf(LOG_LOG, " singles %8d", is->no_singles);
272 logf(LOG_LOG, " no-ops %8d", is->no_non);
274 logf(LOG_LOG, "read blocks %8d", is->no_read);
275 logf(LOG_LOG, "read keys: %8d %8.1f k/bl",
277 1.0*(is->no_read_keys+1)/(is->no_read+1) );
278 logf(LOG_LOG, "read main-k %8d %8.1f %% of keys",
280 100.0*(is->no_read_main+1)/(is->no_read_keys+1) );
281 logf(LOG_LOG, "read ends: %8d %8.1f k/e",
283 1.0*(is->no_read_keys+1)/(is->no_read_eof+1) );
284 s= is->no_seek_nxt+ is->no_seek_sam+ is->no_seek_fwd +
285 is->no_seek_prv+ is->no_seek_bak+ is->no_seek_cat;
288 logf(LOG_LOG, "seek same %8d %8.1f%%",
289 is->no_seek_sam, 100.0*is->no_seek_sam/s );
290 logf(LOG_LOG, "seek next %8d %8.1f%%",
291 is->no_seek_nxt, 100.0*is->no_seek_nxt/s );
292 logf(LOG_LOG, "seek prev %8d %8.1f%%",
293 is->no_seek_prv, 100.0*is->no_seek_prv/s );
294 logf(LOG_LOG, "seek forw %8d %8.1f%%",
295 is->no_seek_fwd, 100.0*is->no_seek_fwd/s );
296 logf(LOG_LOG, "seek back %8d %8.1f%%",
297 is->no_seek_bak, 100.0*is->no_seek_bak/s );
298 logf(LOG_LOG, "seek cat %8d %8.1f%%",
299 is->no_seek_cat, 100.0*is->no_seek_cat/s );
307 static void isamd_seek_stat(ISAMD is, int cat, int pos)
309 if (cat != is->last_cat)
311 else if ( pos == is->last_pos)
313 else if ( pos == is->last_pos+1)
315 else if ( pos == is->last_pos-1)
317 else if ( pos > is->last_pos)
319 else if ( pos < is->last_pos)
325 int isamd_read_block (ISAMD is, int cat, int pos, char *dst)
327 isamd_seek_stat(is,cat,pos);
328 ++(is->files[cat].no_reads);
330 if (is->method->debug > 6)
331 logf (LOG_LOG, "isamd: read_block %d:%d",cat, pos);
332 return bf_read (is->files[cat].bf, pos, 0, 0, dst);
335 int isamd_write_block (ISAMD is, int cat, int pos, char *src)
337 isamd_seek_stat(is,cat,pos);
338 ++(is->files[cat].no_writes);
340 if (is->method->debug > 6)
341 logf (LOG_LOG, "isamd: write_block %d:%d", cat, pos);
342 return bf_write (is->files[cat].bf, pos, 0, 0, src);
345 int isamd_write_dblock (ISAMD is, int cat, int pos, char *src,
346 int nextpos, int offset)
348 ISAMD_BLOCK_SIZE size = offset + ISAMD_BLOCK_OFFSET_N;
349 if (is->method->debug > 4)
350 logf (LOG_LOG, "isamd: write_dblock. size=%d nextpos=%d",
351 (int) size, nextpos);
352 src -= ISAMD_BLOCK_OFFSET_N;
353 assert( ISAMD_BLOCK_OFFSET_N == sizeof(int)+sizeof(int) );
354 memcpy (src, &nextpos, sizeof(int));
355 memcpy (src + sizeof(int), &size, sizeof(size));
356 return isamd_write_block (is, cat, pos, src);
359 #if ISAMD_FREELIST_CHUNK
360 static void flush_block (ISAMD is, int cat)
362 char *abuf = is->files[cat].alloc_buf;
363 int block = is->files[cat].head.freelist;
364 if (block && is->files[cat].alloc_entries_num)
366 memcpy (abuf, &is->files[cat].alloc_entries_num, sizeof(int));
367 bf_write (is->files[cat].bf, block, 0, 0, abuf);
368 is->files[cat].alloc_entries_num = 0;
373 static int alloc_block (ISAMD is, int cat)
375 int block = is->files[cat].head.freelist;
376 char *abuf = is->files[cat].alloc_buf;
378 (is->files[cat].no_allocated)++;
382 block = (is->files[cat].head.lastblock)++; /* no free list */
383 is->files[cat].head_is_dirty = 1;
387 if (!is->files[cat].alloc_entries_num) /* read first time */
389 bf_read (is->files[cat].bf, block, 0, 0, abuf);
390 memcpy (&is->files[cat].alloc_entries_num, abuf,
391 sizeof(is->files[cat].alloc_entries_num));
392 assert (is->files[cat].alloc_entries_num > 0);
394 /* have some free blocks now */
395 assert (is->files[cat].alloc_entries_num > 0);
396 is->files[cat].alloc_entries_num--;
397 if (!is->files[cat].alloc_entries_num) /* last one in block? */
399 memcpy (&is->files[cat].head.freelist, abuf + sizeof(int),
401 is->files[cat].head_is_dirty = 1;
403 if (is->files[cat].head.freelist)
405 bf_read (is->files[cat].bf, is->files[cat].head.freelist,
407 memcpy (&is->files[cat].alloc_entries_num, abuf,
408 sizeof(is->files[cat].alloc_entries_num));
409 assert (is->files[cat].alloc_entries_num);
413 memcpy (&block, abuf + sizeof(int) + sizeof(int) *
414 is->files[cat].alloc_entries_num, sizeof(int));
419 static void release_block (ISAMD is, int cat, int pos)
421 char *abuf = is->files[cat].alloc_buf;
422 int block = is->files[cat].head.freelist;
424 (is->files[cat].no_released)++;
426 if (block && !is->files[cat].alloc_entries_num) /* must read block */
428 bf_read (is->files[cat].bf, block, 0, 0, abuf);
429 memcpy (&is->files[cat].alloc_entries_num, abuf,
430 sizeof(is->files[cat].alloc_entries_num));
431 assert (is->files[cat].alloc_entries_num > 0);
433 assert (is->files[cat].alloc_entries_num <= is->files[cat].alloc_entries_max);
434 if (is->files[cat].alloc_entries_num == is->files[cat].alloc_entries_max)
437 memcpy (abuf, &is->files[cat].alloc_entries_num, sizeof(int));
438 bf_write (is->files[cat].bf, block, 0, 0, abuf);
439 is->files[cat].alloc_entries_num = 0;
441 if (!is->files[cat].alloc_entries_num) /* make new buffer? */
443 memcpy (abuf + sizeof(int), &block, sizeof(int));
444 is->files[cat].head.freelist = pos;
445 is->files[cat].head_is_dirty = 1;
449 memcpy (abuf + sizeof(int) +
450 is->files[cat].alloc_entries_num*sizeof(int),
453 is->files[cat].alloc_entries_num++;
456 static void flush_block (ISAMD is, int cat)
458 char *abuf = is->files[cat].alloc_buf;
462 static int alloc_block (ISAMD is, int cat)
465 char buf[sizeof(int)];
467 is->files[cat].head_is_dirty = 1;
468 (is->files[cat].no_allocated)++;
469 if ((block = is->files[cat].head.freelist))
471 bf_read (is->files[cat].bf, block, 0, sizeof(int), buf);
472 memcpy (&is->files[cat].head.freelist, buf, sizeof(int));
475 block = (is->files[cat].head.lastblock)++;
479 static void release_block (ISAMD is, int cat, int pos)
481 char buf[sizeof(int)];
483 (is->files[cat].no_released)++;
484 is->files[cat].head_is_dirty = 1;
485 memcpy (buf, &is->files[cat].head.freelist, sizeof(int));
486 is->files[cat].head.freelist = pos;
487 bf_write (is->files[cat].bf, pos, 0, sizeof(int), buf);
491 int isamd_alloc_block (ISAMD is, int cat)
495 if (is->files[cat].fc_list)
498 for (j = 0; j < is->files[cat].fc_max; j++)
499 if ((nb = is->files[cat].fc_list[j]) && (!block || nb < block))
501 is->files[cat].fc_list[j] = 0;
507 block = alloc_block (is, cat);
508 if (is->method->debug > 4)
509 logf (LOG_LOG, "isamd: alloc_block in cat %d: %d", cat, block);
513 void isamd_release_block (ISAMD is, int cat, int pos)
515 if (is->method->debug > 4)
516 logf (LOG_LOG, "isamd: release_block in cat %d: %d", cat, pos);
519 if (is->files[cat].fc_list)
522 for (j = 0; j<is->files[cat].fc_max; j++)
523 if (!is->files[cat].fc_list[j])
525 is->files[cat].fc_list[j] = pos;
529 release_block (is, cat, pos);
532 static void init_fc (ISAMD is, int cat)
536 is->files[cat].fc_max = j;
537 is->files[cat].fc_list = (int *)
538 xmalloc (sizeof(*is->files[0].fc_list) * j);
540 is->files[cat].fc_list[j] = 0;
543 static void release_fc (ISAMD is, int cat)
545 int b, j = is->files[cat].fc_max;
548 if ((b = is->files[cat].fc_list[j]))
550 release_block (is, cat, b);
551 is->files[cat].fc_list[j] = 0;
555 void isamd_pp_close (ISAMD_PP pp)
559 (*is->method->code_stop)(ISAMD_DECODE, pp->decodeClientData);
560 isamd_free_diffs(pp); /* see merge-d.h */
561 if (is->method->debug > 5)
562 logf (LOG_LOG, "isamd_pp_close %p %d=%d:%d sz=%d n=%d=%d:%d nk=%d",
563 pp, isamd_addr(pp->pos, pp->cat), pp->cat, pp->pos, pp->size,
564 pp->next, isamd_type(pp->next), isamd_block(pp->next),
571 ISAMD_PP isamd_pp_create (ISAMD is, int cat)
572 /* creates a pp_buff without data in it. pos=0, cat as given */
574 ISAMD_PP pp = (ISAMD_PP) xmalloc (sizeof(*pp));
575 int sz = is->method->filecat[is->max_cat].bsize;
578 pp->buf = (char *) xmalloc (sz);
579 memset(pp->buf,'\0',sz); /* clear the buffer, for new blocks */
588 pp->decodeClientData = (*is->method->code_start)(ISAMD_DECODE);
597 ISAMD_PP isamd_pp_open (ISAMD is, const char *dictbuf, int dictlen)
600 ISAMD_PP pp = (ISAMD_PP) xmalloc (sizeof(*pp));
602 int sz = is->method->filecat[is->max_cat].bsize;
603 /* always allocate for the largest blocks, saves trouble */
607 src = pp->buf = (char *) xmalloc (sz);
608 memset(src,'\0',sz); /* clear the buffer, for new blocks */
617 pp->decodeClientData = (*is->method->code_start)(ISAMD_DECODE);
619 dictnum=*dictbuf; /* numkeys for internals, 0 for externals */
623 memcpy(&ipos, dictbuf+1, sizeof(ISAMD_P) );
625 else /* dictionary block, fake a real one */
629 if (is->method->debug > 5)
630 logf (LOG_LOG, "isamd_pp_open dict");
631 pp->numKeys=(unsigned char) dictbuf[0];
632 memcpy(pp->buf+ISAMD_BLOCK_OFFSET_1, dictbuf+1,dictlen-1);
633 pp->size=pp->offset=dictlen+ISAMD_BLOCK_OFFSET_1-1;
638 pp->cat = isamd_type(ipos);
639 pp->pos = isamd_block(ipos);
647 isamd_read_block (is, pp->cat, pp->pos, src);
648 memcpy (&pp->next, src, sizeof(pp->next));
649 src += sizeof(pp->next);
650 memcpy (&pp->size, src, sizeof(pp->size));
651 src += sizeof(pp->size);
652 memcpy (&pp->numKeys, src, sizeof(pp->numKeys));
653 src += sizeof(pp->numKeys);
654 assert (pp->next != isamd_addr(pp->pos,pp->cat));
655 pp->offset = src - pp->buf;
656 assert (pp->offset == ISAMD_BLOCK_OFFSET_1);
657 assert(pp->size>=ISAMD_BLOCK_OFFSET_1); /*??*/
659 is->files[pp->cat].no_op_main++;
661 is->files[pp->cat].no_op_diffonly++;
663 if (is->method->debug > 5)
664 logf (LOG_LOG, "isamd_pp_open %p %d=%d:%d sz=%d n=%d=%d:%d",
665 pp, isamd_addr(pp->pos, pp->cat), pp->cat, pp->pos, pp->size,
666 pp->next, isamd_type(pp->next), isamd_block(pp->next) );
673 void isamd_buildfirstblock(ISAMD_PP pp){
676 assert(pp->next != isamd_addr(pp->pos,pp->cat));
677 memcpy(dst, &pp->next, sizeof(pp->next) );
678 dst += sizeof(pp->next);
679 memcpy(dst, &pp->size,sizeof(pp->size));
680 dst += sizeof(pp->size);
681 memcpy(dst, &pp->numKeys, sizeof(pp->numKeys));
682 dst += sizeof(pp->numKeys);
683 assert (dst - pp->buf == ISAMD_BLOCK_OFFSET_1);
684 if (pp->is->method->debug > 5)
685 logf (LOG_LOG, "isamd: bldfirst: p=%d=%d:%d n=%d:%d:%d sz=%d nk=%d ",
686 isamd_addr(pp->pos,pp->cat),pp->cat, pp->pos,
687 pp->next, isamd_type(pp->next), isamd_block(pp->next),
688 pp->size, pp->numKeys);
691 void isamd_buildlaterblock(ISAMD_PP pp){
694 assert(pp->next != isamd_addr(pp->pos,pp->cat));
695 memcpy(dst, &pp->next, sizeof(pp->next) );
696 dst += sizeof(pp->next);
697 memcpy(dst, &pp->size,sizeof(pp->size));
698 dst += sizeof(pp->size);
699 assert (dst - pp->buf == ISAMD_BLOCK_OFFSET_N);
700 if (pp->is->method->debug > 5)
701 logf (LOG_LOG, "isamd: l8r: sz=%d p=%d/%d>%d/%d",
704 isamd_block(pp->next), isamd_type(pp->next) );
709 /* returns non-zero if item could be read; 0 otherwise */
710 int isamd_pp_read (ISAMD_PP pp, void *buf)
713 return isamd_read_item (pp, (char **) &buf);
714 /* note: isamd_read_item is in merge-d.c, because it is so */
715 /* convoluted with the merge process */
718 /* read one main item from file - decode and store it in *dst.
719 Does not worry about diffs
722 1 if item could be read ok
724 int isamd_read_main_item (ISAMD_PP pp, char **dst)
727 char *src = pp->buf + pp->offset;
731 if (pp->offset >= pp->size)
736 return 0; /* end of file */
738 if (pp->next > pp->pos)
740 if (pp->next == pp->pos + 1)
741 is->files[pp->cat].no_next++;
744 is->files[pp->cat].no_forward++;
745 is->files[pp->cat].sum_forward += pp->next - pp->pos;
750 if (pp->next + 1 == pp->pos)
751 is->files[pp->cat].no_prev++;
754 is->files[pp->cat].no_backward++;
755 is->files[pp->cat].sum_backward += pp->pos - pp->next;
758 /* out new block position */
759 newcat = isamd_type(pp->next);
760 pp->pos = isamd_block(pp->next);
761 pp->cat = isamd_type(pp->next);
762 pp->is->no_read_main++;
764 /* read block and save 'next' and 'size' entry */
765 isamd_read_block (is, pp->cat, pp->pos, src);
766 memcpy (&pp->next, src, sizeof(pp->next));
767 src += sizeof(pp->next);
768 memcpy (&pp->size, src, sizeof(pp->size));
769 src += sizeof(pp->size);
770 /* assume block is non-empty */
771 pp->offset = oldoffs = src - pp->buf;
772 assert (pp->offset == ISAMD_BLOCK_OFFSET_N);
773 assert (pp->next != isamd_addr(pp->pos,pp->cat));
774 (*is->method->code_reset)(pp->decodeClientData);
775 /* finally, read the item */
776 (*is->method->code_item)(ISAMD_DECODE, pp->decodeClientData, dst, &src);
777 pp->offset = src - pp->buf;
778 if (is->method->debug > 8)
779 logf (LOG_LOG, "isamd: read_m: block %d:%d sz=%d ofs=%d-%d next=%d",
780 pp->cat, pp->pos, pp->size, oldoffs, pp->offset, pp->next);
784 (*is->method->code_item)(ISAMD_DECODE, pp->decodeClientData, dst, &src);
785 pp->offset = src - pp->buf;
786 if (is->method->debug > 8)
787 logf (LOG_LOG, "isamd: read_m: got %d:%d sz=%d ofs=%d-%d next=%d",
788 pp->cat, pp->pos, pp->size, oldoffs, pp->offset, pp->next);
792 int isamd_pp_num (ISAMD_PP pp)
799 static char *hexdump(unsigned char *p, int len, char *buff) {
800 static char localbuff[128];
802 if (!buff) buff=localbuff;
805 sprintf(bytebuff,"%02x",*p);
807 strcat(buff,bytebuff);
808 if (len) strcat(buff," ");
815 /* needs different arguments, or something */
816 void isamd_pp_dump (ISAMD is, ISAMD_P ipos)
827 int olddebug= is->method->debug;
828 is->method->debug=0; /* no debug logs while reading for dump */
830 logf(LOG_LOG,"dumping isamd block %d (%d:%d)",
831 (int)ipos, isamd_type(ipos), isamd_block(ipos) );
832 pp=isamd_pp_open(is,ipos);
833 logf(LOG_LOG,"numKeys=%d, ofs=%d sz=%d",
834 pp->numKeys, pp->offset, pp->size );
835 diffidx=oldoffs= pp->offset;
836 while ((diffidx < is->method->filecat[pp->cat].bsize) && (diffmax>0))
838 memcpy(&diffmax,&(pp->buf[diffidx]),sizeof(int));
839 logf (LOG_LOG,"diff set at %d-%d: %s", diffidx, diffmax,
840 hexdump(pp->buf+diffidx,8,0));
841 /*! todo: dump the actual diffs as well !!! */
845 while(isamd_pp_read(pp, &key))
847 if (oldaddr != isamd_addr(pp->pos,pp->cat) )
849 oldaddr = isamd_addr(pp->pos,pp->cat);
850 logf(LOG_LOG,"block %d=%d:%d sz=%d nx=%d=%d:%d ofs=%d",
851 isamd_addr(pp->pos,pp->cat), pp->cat, pp->pos,
853 pp->next, isamd_type(pp->next), isamd_block(pp->next),
859 logf(LOG_LOG," %05x: %s",i,hexdump(pp->buf+i,n,hexbuff));
862 if (oldoffs > ISAMD_BLOCK_OFFSET_N)
863 oldoffs=ISAMD_BLOCK_OFFSET_N;
866 logf (LOG_LOG," got %d:%d=%x:%x from %s at %d=%x",
867 key.sysno, key.seqno,
868 key.sysno, key.seqno,
869 hexdump(pp->buf+oldoffs, pp->offset-oldoffs, hexbuff),
871 oldoffs = pp->offset;
873 /*!*/ /*TODO: dump diffs too!!! */
875 is->method->debug=olddebug;
882 * Revision 1.25 2003-03-05 16:41:10 adam
885 * Revision 1.24 2002/11/26 22:18:34 adam
888 * Revision 1.23 2002/08/02 19:26:56 adam
891 * Revision 1.22 2002/07/12 18:12:21 heikki
892 * Isam-D now stores small entries directly in the dictionary.
893 * Needs more tuning and cleaning...
895 * Revision 1.21 2002/07/11 16:16:00 heikki
896 * Fixed a bug in isamd, failed to store a single key when its bits
897 * did not fit into a singleton.
899 * Revision 1.20 2002/06/19 10:29:18 adam
900 * align block sizes for isam sys. Better plot for test
902 * Revision 1.19 1999/11/30 13:48:04 adam
903 * Improved installation. Updated for inclusion of YAZ header files.
905 * Revision 1.18 1999/10/06 15:18:13 heikki
907 * Improving block sizes again
909 * Revision 1.17 1999/10/06 11:46:36 heikki
910 * mproved statistics on isam-d
912 * Revision 1.16 1999/10/05 09:57:40 heikki
913 * Tuning the isam-d (and fixed a small "detail")
915 * Revision 1.15 1999/09/27 14:36:36 heikki
918 * Revision 1.14 1999/09/23 18:01:18 heikki
919 * singleton optimising
921 * Revision 1.13 1999/09/20 15:48:06 heikki
924 * Revision 1.12 1999/09/13 13:28:28 heikki
925 * isam-d optimizing: merging input data in the same go
927 * Revision 1.11 1999/08/25 18:09:24 heikki
928 * Starting to optimize
930 * Revision 1.10 1999/08/24 13:17:42 heikki
931 * Block sizes, comments
933 * Revision 1.9 1999/08/20 12:25:58 heikki
934 * Statistics in isamd
936 * Revision 1.8 1999/08/18 13:28:16 heikki
937 * Set log levels to decent values
939 * Revision 1.6 1999/08/17 19:44:25 heikki
942 * Revision 1.4 1999/08/04 14:21:18 heikki
943 * isam-d seems to be working.
945 * Revision 1.3 1999/07/21 14:24:50 heikki
946 * isamd write and read functions ok, except when diff block full.
947 * (merge not yet done)
949 * Revision 1.1 1999/07/14 12:34:43 heikki
950 * Copied from isamh, starting to change things...