1 /* $Id: isamd.c,v 1.23 2002-08-02 19:26:56 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 */
604 struct it_key singlekey;
605 char *c_ptr; /* for fake encoding the singlekey */
611 src = pp->buf = (char *) xmalloc (sz);
612 memset(src,'\0',sz); /* clear the buffer, for new blocks */
621 pp->decodeClientData = (*is->method->code_start)(ISAMD_DECODE);
623 dictnum=*dictbuf; // numkeys for internals, 0 for externals
627 memcpy(&ipos, dictbuf+1, sizeof(ISAMD_P) );
629 else /* dictionary block, fake a real one */
633 if (is->method->debug > 5)
634 logf (LOG_LOG, "isamd_pp_open dict");
635 pp->numKeys=(unsigned char) dictbuf[0];
636 memcpy(pp->buf+ISAMD_BLOCK_OFFSET_1, dictbuf+1,dictlen-1);
637 pp->size=pp->offset=dictlen+ISAMD_BLOCK_OFFSET_1-1;
642 pp->cat = isamd_type(ipos);
643 pp->pos = isamd_block(ipos);
651 isamd_read_block (is, pp->cat, pp->pos, src);
652 memcpy (&pp->next, src, sizeof(pp->next));
653 src += sizeof(pp->next);
654 memcpy (&pp->size, src, sizeof(pp->size));
655 src += sizeof(pp->size);
656 memcpy (&pp->numKeys, src, sizeof(pp->numKeys));
657 src += sizeof(pp->numKeys);
658 assert (pp->next != isamd_addr(pp->pos,pp->cat));
659 pp->offset = src - pp->buf;
660 assert (pp->offset == ISAMD_BLOCK_OFFSET_1);
661 assert(pp->size>=ISAMD_BLOCK_OFFSET_1); /*??*/
663 is->files[pp->cat].no_op_main++;
665 is->files[pp->cat].no_op_diffonly++;
667 if (is->method->debug > 5)
668 logf (LOG_LOG, "isamd_pp_open %p %d=%d:%d sz=%d n=%d=%d:%d",
669 pp, isamd_addr(pp->pos, pp->cat), pp->cat, pp->pos, pp->size,
670 pp->next, isamd_type(pp->next), isamd_block(pp->next) );
677 void isamd_buildfirstblock(ISAMD_PP pp){
680 assert(pp->next != isamd_addr(pp->pos,pp->cat));
681 memcpy(dst, &pp->next, sizeof(pp->next) );
682 dst += sizeof(pp->next);
683 memcpy(dst, &pp->size,sizeof(pp->size));
684 dst += sizeof(pp->size);
685 memcpy(dst, &pp->numKeys, sizeof(pp->numKeys));
686 dst += sizeof(pp->numKeys);
687 assert (dst - pp->buf == ISAMD_BLOCK_OFFSET_1);
688 if (pp->is->method->debug > 5)
689 logf (LOG_LOG, "isamd: bldfirst: p=%d=%d:%d n=%d:%d:%d sz=%d nk=%d ",
690 isamd_addr(pp->pos,pp->cat),pp->cat, pp->pos,
691 pp->next, isamd_type(pp->next), isamd_block(pp->next),
692 pp->size, pp->numKeys);
695 void isamd_buildlaterblock(ISAMD_PP pp){
698 assert(pp->next != isamd_addr(pp->pos,pp->cat));
699 memcpy(dst, &pp->next, sizeof(pp->next) );
700 dst += sizeof(pp->next);
701 memcpy(dst, &pp->size,sizeof(pp->size));
702 dst += sizeof(pp->size);
703 assert (dst - pp->buf == ISAMD_BLOCK_OFFSET_N);
704 if (pp->is->method->debug > 5)
705 logf (LOG_LOG, "isamd: l8r: sz=%d p=%d/%d>%d/%d",
708 isamd_block(pp->next), isamd_type(pp->next) );
713 /* returns non-zero if item could be read; 0 otherwise */
714 int isamd_pp_read (ISAMD_PP pp, void *buf)
717 return isamd_read_item (pp, (char **) &buf);
718 /* note: isamd_read_item is in merge-d.c, because it is so */
719 /* convoluted with the merge process */
722 /* read one main item from file - decode and store it in *dst.
723 Does not worry about diffs
726 1 if item could be read ok
728 int isamd_read_main_item (ISAMD_PP pp, char **dst)
731 char *src = pp->buf + pp->offset;
735 if (pp->offset >= pp->size)
740 return 0; /* end of file */
742 if (pp->next > pp->pos)
744 if (pp->next == pp->pos + 1)
745 is->files[pp->cat].no_next++;
748 is->files[pp->cat].no_forward++;
749 is->files[pp->cat].sum_forward += pp->next - pp->pos;
754 if (pp->next + 1 == pp->pos)
755 is->files[pp->cat].no_prev++;
758 is->files[pp->cat].no_backward++;
759 is->files[pp->cat].sum_backward += pp->pos - pp->next;
762 /* out new block position */
763 newcat = isamd_type(pp->next);
764 pp->pos = isamd_block(pp->next);
765 pp->cat = isamd_type(pp->next);
766 pp->is->no_read_main++;
768 /* read block and save 'next' and 'size' entry */
769 isamd_read_block (is, pp->cat, pp->pos, src);
770 memcpy (&pp->next, src, sizeof(pp->next));
771 src += sizeof(pp->next);
772 memcpy (&pp->size, src, sizeof(pp->size));
773 src += sizeof(pp->size);
774 /* assume block is non-empty */
775 pp->offset = oldoffs = src - pp->buf;
776 assert (pp->offset == ISAMD_BLOCK_OFFSET_N);
777 assert (pp->next != isamd_addr(pp->pos,pp->cat));
778 (*is->method->code_reset)(pp->decodeClientData);
779 /* finally, read the item */
780 (*is->method->code_item)(ISAMD_DECODE, pp->decodeClientData, dst, &src);
781 pp->offset = src - pp->buf;
782 if (is->method->debug > 8)
783 logf (LOG_LOG, "isamd: read_m: block %d:%d sz=%d ofs=%d-%d next=%d",
784 pp->cat, pp->pos, pp->size, oldoffs, pp->offset, pp->next);
788 (*is->method->code_item)(ISAMD_DECODE, pp->decodeClientData, dst, &src);
789 pp->offset = src - pp->buf;
790 if (is->method->debug > 8)
791 logf (LOG_LOG, "isamd: read_m: got %d:%d sz=%d ofs=%d-%d next=%d",
792 pp->cat, pp->pos, pp->size, oldoffs, pp->offset, pp->next);
796 int isamd_pp_num (ISAMD_PP pp)
801 static char *hexdump(unsigned char *p, int len, char *buff) {
802 static char localbuff[128];
804 if (!buff) buff=localbuff;
807 sprintf(bytebuff,"%02x",*p);
809 strcat(buff,bytebuff);
810 if (len) strcat(buff," ");
817 /* needs different arguments, or something */
818 void isamd_pp_dump (ISAMD is, ISAMD_P ipos)
829 int olddebug= is->method->debug;
830 is->method->debug=0; /* no debug logs while reading for dump */
832 logf(LOG_LOG,"dumping isamd block %d (%d:%d)",
833 (int)ipos, isamd_type(ipos), isamd_block(ipos) );
834 pp=isamd_pp_open(is,ipos);
835 logf(LOG_LOG,"numKeys=%d, ofs=%d sz=%d",
836 pp->numKeys, pp->offset, pp->size );
837 diffidx=oldoffs= pp->offset;
838 while ((diffidx < is->method->filecat[pp->cat].bsize) && (diffmax>0))
840 memcpy(&diffmax,&(pp->buf[diffidx]),sizeof(int));
841 logf (LOG_LOG,"diff set at %d-%d: %s", diffidx, diffmax,
842 hexdump(pp->buf+diffidx,8,0));
843 /*! todo: dump the actual diffs as well !!! */
847 while(isamd_pp_read(pp, &key))
849 if (oldaddr != isamd_addr(pp->pos,pp->cat) )
851 oldaddr = isamd_addr(pp->pos,pp->cat);
852 logf(LOG_LOG,"block %d=%d:%d sz=%d nx=%d=%d:%d ofs=%d",
853 isamd_addr(pp->pos,pp->cat), pp->cat, pp->pos,
855 pp->next, isamd_type(pp->next), isamd_block(pp->next),
861 logf(LOG_LOG," %05x: %s",i,hexdump(pp->buf+i,n,hexbuff));
864 if (oldoffs > ISAMD_BLOCK_OFFSET_N)
865 oldoffs=ISAMD_BLOCK_OFFSET_N;
868 logf (LOG_LOG," got %d:%d=%x:%x from %s at %d=%x",
869 key.sysno, key.seqno,
870 key.sysno, key.seqno,
871 hexdump(pp->buf+oldoffs, pp->offset-oldoffs, hexbuff),
873 oldoffs = pp->offset;
875 /*!*/ /*TODO: dump diffs too!!! */
877 is->method->debug=olddebug;
884 * Revision 1.23 2002-08-02 19:26:56 adam
887 * Revision 1.22 2002/07/12 18:12:21 heikki
888 * Isam-D now stores small entries directly in the dictionary.
889 * Needs more tuning and cleaning...
891 * Revision 1.21 2002/07/11 16:16:00 heikki
892 * Fixed a bug in isamd, failed to store a single key when its bits
893 * did not fit into a singleton.
895 * Revision 1.20 2002/06/19 10:29:18 adam
896 * align block sizes for isam sys. Better plot for test
898 * Revision 1.19 1999/11/30 13:48:04 adam
899 * Improved installation. Updated for inclusion of YAZ header files.
901 * Revision 1.18 1999/10/06 15:18:13 heikki
903 * Improving block sizes again
905 * Revision 1.17 1999/10/06 11:46:36 heikki
906 * mproved statistics on isam-d
908 * Revision 1.16 1999/10/05 09:57:40 heikki
909 * Tuning the isam-d (and fixed a small "detail")
911 * Revision 1.15 1999/09/27 14:36:36 heikki
914 * Revision 1.14 1999/09/23 18:01:18 heikki
915 * singleton optimising
917 * Revision 1.13 1999/09/20 15:48:06 heikki
920 * Revision 1.12 1999/09/13 13:28:28 heikki
921 * isam-d optimizing: merging input data in the same go
923 * Revision 1.11 1999/08/25 18:09:24 heikki
924 * Starting to optimize
926 * Revision 1.10 1999/08/24 13:17:42 heikki
927 * Block sizes, comments
929 * Revision 1.9 1999/08/20 12:25:58 heikki
930 * Statistics in isamd
932 * Revision 1.8 1999/08/18 13:28:16 heikki
933 * Set log levels to decent values
935 * Revision 1.6 1999/08/17 19:44:25 heikki
938 * Revision 1.4 1999/08/04 14:21:18 heikki
939 * isam-d seems to be working.
941 * Revision 1.3 1999/07/21 14:24:50 heikki
942 * isamd write and read functions ok, except when diff block full.
943 * (merge not yet done)
945 * Revision 1.1 1999/07/14 12:34:43 heikki
946 * Copied from isamh, starting to change things...