1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Format of first block (assumes a 512 block size)
26 * Format of subsequent blocks
30 * Format of each record
32 * (length, data) - pairs
33 * length = 0 if same as previous
43 #include <yaz/yaz-util.h>
44 #include <idzebra/bfile.h>
54 #define REC_BLOCK_TYPES 2
55 #define REC_HEAD_MAGIC "recindex"
60 int compression_method;
64 char *data_fname[REC_BLOCK_TYPES];
65 BFile data_BFile[REC_BLOCK_TYPES];
70 struct record_cache_entry *record_cache;
75 int compression_chunk_size;
82 zint block_size[REC_BLOCK_TYPES];
83 zint block_free[REC_BLOCK_TYPES];
84 zint block_last[REC_BLOCK_TYPES];
85 zint block_used[REC_BLOCK_TYPES];
86 zint block_move[REC_BLOCK_TYPES];
96 enum recordCacheFlag { recordFlagNop, recordFlagWrite, recordFlagNew,
99 struct record_cache_entry {
101 enum recordCacheFlag flag;
104 struct record_index_entry {
105 zint next; /* first block of record info / next free entry */
106 int size; /* size of record or 0 if free entry */
109 Record rec_cp(Record rec);
111 /* Modify argument to if below: 1=normal, 0=sysno testing */
113 /* If this is used sysno are not converted (no testing) */
114 #define FAKE_OFFSET 0
115 #define USUAL_RANGE 6000000000LL
118 /* Use a fake > 2^32 offset so we can test for proper 64-bit handling */
119 #define FAKE_OFFSET 6000000000LL
120 #define USUAL_RANGE 2000000000LL
123 static zint rec_sysno_to_ext(zint sysno)
125 assert(sysno >= 0 && sysno <= USUAL_RANGE);
126 return sysno + FAKE_OFFSET;
129 zint rec_sysno_to_int(zint sysno)
131 assert(sysno >= FAKE_OFFSET && sysno <= FAKE_OFFSET + USUAL_RANGE);
132 return sysno - FAKE_OFFSET;
135 static void rec_tmp_expand(Records p, int size)
137 if (p->tmp_size < size + 2048 ||
138 p->tmp_size < p->head.block_size[REC_BLOCK_TYPES-1]*2)
141 p->tmp_size = size + (int)
142 (p->head.block_size[REC_BLOCK_TYPES-1])*2 + 2048;
143 p->tmp_buf = (char *) xmalloc(p->tmp_size);
147 static ZEBRA_RES rec_release_blocks(Records p, zint sysno)
149 struct record_index_entry entry;
151 char block_and_ref[sizeof(zint) + sizeof(short)];
155 if (recindex_read_indx(p->recindex, sysno, &entry, sizeof(entry), 1) != 1)
158 freeblock = entry.next;
159 assert(freeblock > 0);
160 dst_type = CAST_ZINT_TO_INT(freeblock & 7);
161 assert(dst_type < REC_BLOCK_TYPES);
162 freeblock = freeblock / 8;
165 if (bf_read(p->data_BFile[dst_type], freeblock, 0,
166 first ? sizeof(block_and_ref) : sizeof(zint),
169 yaz_log(YLOG_FATAL|YLOG_ERRNO, "read in rec_del_single");
175 memcpy(&ref, block_and_ref + sizeof(freeblock), sizeof(ref));
177 memcpy(block_and_ref + sizeof(freeblock), &ref, sizeof(ref));
180 /* there is still a reference to this block.. */
181 if (bf_write(p->data_BFile[dst_type], freeblock, 0,
182 sizeof(block_and_ref), block_and_ref))
184 yaz_log(YLOG_FATAL|YLOG_ERRNO, "write in rec_del_single");
189 /* the list of blocks can all be removed (ref == 0) */
193 if (bf_write(p->data_BFile[dst_type], freeblock, 0, sizeof(freeblock),
194 &p->head.block_free[dst_type]))
196 yaz_log(YLOG_FATAL|YLOG_ERRNO, "write in rec_del_single");
199 p->head.block_free[dst_type] = freeblock;
200 memcpy(&freeblock, block_and_ref, sizeof(freeblock));
202 p->head.block_used[dst_type]--;
204 p->head.total_bytes -= entry.size;
208 static ZEBRA_RES rec_delete_single(Records p, Record rec)
210 struct record_index_entry entry;
212 /* all data in entry must be reset, since it's written verbatim */
213 memset(&entry, '\0', sizeof(entry));
214 if (rec_release_blocks(p, rec_sysno_to_int(rec->sysno)) != ZEBRA_OK)
217 entry.next = p->head.index_free;
219 p->head.index_free = rec_sysno_to_int(rec->sysno);
220 recindex_write_indx(p->recindex, rec_sysno_to_int(rec->sysno), &entry, sizeof(entry));
224 static ZEBRA_RES rec_write_tmp_buf(Records p, int size, zint *sysnos)
226 struct record_index_entry entry;
228 char *cptr = p->tmp_buf;
229 zint block_prev = -1, block_free;
233 /* all data in entry must be reset, since it's written verbatim */
234 memset(&entry, '\0', sizeof(entry));
236 for (i = 1; i<REC_BLOCK_TYPES; i++)
237 if (size >= p->head.block_move[i])
239 while (no_written < size)
241 block_free = p->head.block_free[dst_type];
244 if (bf_read(p->data_BFile[dst_type],
245 block_free, 0, sizeof(*p->head.block_free),
246 &p->head.block_free[dst_type]) != 1)
248 yaz_log(YLOG_FATAL|YLOG_ERRNO, "read in %s at free block "
250 p->data_fname[dst_type], block_free);
255 block_free = p->head.block_last[dst_type]++;
256 if (block_prev == -1)
258 entry.next = block_free*8 + dst_type;
260 p->head.total_bytes += size;
263 recindex_write_indx(p->recindex, *sysnos, &entry, sizeof(entry));
269 memcpy(cptr, &block_free, sizeof(block_free));
270 bf_write(p->data_BFile[dst_type], block_prev, 0, 0, cptr);
271 cptr = p->tmp_buf + no_written;
273 block_prev = block_free;
274 no_written += CAST_ZINT_TO_INT(p->head.block_size[dst_type])
276 p->head.block_used[dst_type]++;
278 assert(block_prev != -1);
280 memcpy(cptr, &block_free, sizeof(block_free));
281 bf_write(p->data_BFile[dst_type], block_prev, 0,
282 sizeof(block_free) + (p->tmp_buf+size) - cptr, cptr);
286 int rec_check_compression_method(int compression_method)
288 switch(compression_method)
290 case REC_COMPRESS_ZLIB:
296 case REC_COMPRESS_BZIP2:
302 case REC_COMPRESS_NONE:
308 Records rec_open(BFiles bfs, int rw, int compression_method)
313 ZEBRA_RES ret = ZEBRA_OK;
315 p = (Records) xmalloc(sizeof(*p));
316 memset(&p->head, '\0', sizeof(p->head));
317 p->compression_method = compression_method;
320 p->tmp_buf = (char *) xmalloc(p->tmp_size);
321 p->compression_chunk_size = 0;
322 if (compression_method == REC_COMPRESS_BZIP2)
323 p->compression_chunk_size = 90000;
324 p->recindex = recindex_open(bfs, rw, 0 /* 1=isamb for recindex */);
325 r = recindex_read_head(p->recindex, p->tmp_buf);
329 memcpy(p->head.magic, REC_HEAD_MAGIC, sizeof(p->head.magic));
330 sprintf(p->head.version, "%3d", REC_VERSION);
331 p->head.index_free = 0;
332 p->head.index_last = 1;
333 p->head.no_records = 0;
334 p->head.total_bytes = 0;
335 for (i = 0; i<REC_BLOCK_TYPES; i++)
337 p->head.block_free[i] = 0;
338 p->head.block_last[i] = 1;
339 p->head.block_used[i] = 0;
341 p->head.block_size[0] = 256;
342 p->head.block_move[0] = 0;
343 for (i = 1; i<REC_BLOCK_TYPES; i++)
345 p->head.block_size[i] = p->head.block_size[i-1] * 8;
346 p->head.block_move[i] = p->head.block_size[i] * 2;
350 if (recindex_write_head(p->recindex,
351 &p->head, sizeof(p->head)) != ZEBRA_OK)
356 memcpy(&p->head, p->tmp_buf, sizeof(p->head));
357 if (memcmp(p->head.magic, REC_HEAD_MAGIC, sizeof(p->head.magic)))
359 yaz_log(YLOG_FATAL, "file %s has bad format",
360 recindex_get_fname(p->recindex));
363 version = atoi(p->head.version);
364 if (version != REC_VERSION)
366 yaz_log(YLOG_FATAL, "file %s is version %d, but version"
368 recindex_get_fname(p->recindex), version, REC_VERSION);
373 for (i = 0; i<REC_BLOCK_TYPES; i++)
376 sprintf(str, "recd%c", i + 'A');
377 p->data_fname[i] = (char *) xmalloc(strlen(str)+1);
378 strcpy(p->data_fname[i], str);
379 p->data_BFile[i] = NULL;
381 for (i = 0; i<REC_BLOCK_TYPES; i++)
383 if (!(p->data_BFile[i] =
384 bf_open(bfs, p->data_fname[i],
385 CAST_ZINT_TO_INT(p->head.block_size[i]), rw)))
387 yaz_log(YLOG_FATAL|YLOG_ERRNO, "bf_open %s", p->data_fname[i]);
394 p->record_cache = (struct record_cache_entry *)
395 xmalloc(sizeof(*p->record_cache)*p->cache_max);
396 zebra_mutex_init(&p->mutex);
397 if (ret == ZEBRA_FAIL)
402 static void rec_encode_unsigned(unsigned n, unsigned char *buf, int *len)
407 buf[*len] = 128 + (n & 127);
415 static void rec_decode_unsigned(unsigned *np, unsigned char *buf, int *len)
421 while (buf[*len] > 127)
423 n += w*(buf[*len] & 127);
432 static void rec_encode_zint(zint n, unsigned char *buf, int *len)
437 buf[*len] = (unsigned) (128 + (n & 127));
441 buf[*len] = (unsigned) n;
445 static void rec_decode_zint(zint *np, unsigned char *buf, int *len)
451 while (buf[*len] > 127)
453 n += w*(buf[*len] & 127);
462 static void rec_cache_flush_block1(Records p, Record rec, Record last_rec,
463 char **out_buf, int *out_size,
469 for (i = 0; i<REC_NO_INFO; i++)
471 if (*out_offset + CAST_ZINT_TO_INT(rec->size[i]) + 20 > *out_size)
473 int new_size = *out_offset + rec->size[i] + 65536;
474 char *np = (char *) xmalloc(new_size);
476 memcpy(np, *out_buf, *out_offset);
478 *out_size = new_size;
483 rec_encode_zint(rec_sysno_to_int(rec->sysno),
484 (unsigned char *) *out_buf + *out_offset, &len);
485 (*out_offset) += len;
487 if (rec->size[i] == 0)
489 rec_encode_unsigned(1, (unsigned char *) *out_buf + *out_offset,
491 (*out_offset) += len;
493 else if (last_rec && rec->size[i] == last_rec->size[i] &&
494 !memcmp(rec->info[i], last_rec->info[i], rec->size[i]))
496 rec_encode_unsigned(0, (unsigned char *) *out_buf + *out_offset,
498 (*out_offset) += len;
502 rec_encode_unsigned(rec->size[i]+1,
503 (unsigned char *) *out_buf + *out_offset,
505 (*out_offset) += len;
506 memcpy(*out_buf + *out_offset, rec->info[i], rec->size[i]);
507 (*out_offset) += rec->size[i];
512 static ZEBRA_RES rec_flush_shared(Records p, short ref_count, zint *sysnos,
513 char *out_buf, int out_offset)
515 ZEBRA_RES ret = ZEBRA_OK;
519 unsigned int csize = 0; /* indicate compression "not performed yet" */
520 char compression_method = p->compression_method;
521 switch (compression_method)
523 case REC_COMPRESS_ZLIB:
525 csize = out_offset + (out_offset >> 6) + 620;
529 uLongf destLen = csize;
530 rec_tmp_expand(p, csize);
531 r = compress((Bytef *) p->tmp_buf+sizeof(zint)+sizeof(short)+
533 &destLen, (const Bytef *) out_buf, out_offset);
539 if (r != Z_MEM_ERROR)
541 yaz_log(YLOG_WARN, "compress error: %d", r);
549 case REC_COMPRESS_BZIP2:
551 csize = out_offset + (out_offset >> 6) + 620;
552 rec_tmp_expand(p, csize);
553 #ifdef BZ_CONFIG_ERROR
554 i = BZ2_bzBuffToBuffCompress
556 i = bzBuffToBuffCompress
558 (p->tmp_buf+sizeof(zint)+sizeof(short)+
560 &csize, out_buf, out_offset, 1, 0, 30);
563 yaz_log(YLOG_WARN, "bzBuffToBuffCompress error code=%d", i);
568 case REC_COMPRESS_NONE:
573 /* either no compression or compression not supported ... */
575 rec_tmp_expand(p, csize);
576 memcpy(p->tmp_buf + sizeof(zint) + sizeof(short) + sizeof(char),
577 out_buf, out_offset);
579 compression_method = REC_COMPRESS_NONE;
581 memcpy(p->tmp_buf + sizeof(zint), &ref_count, sizeof(ref_count));
582 memcpy(p->tmp_buf + sizeof(zint)+sizeof(short),
583 &compression_method, sizeof(compression_method));
585 /* -------- compression */
586 if (rec_write_tmp_buf(p, csize + sizeof(short) + sizeof(char), sysnos)
593 static ZEBRA_RES rec_write_multiple(Records p, int saveCount)
600 char *out_buf = (char *) xmalloc(out_size);
601 zint *sysnos = (zint *) xmalloc(sizeof(*sysnos) * (p->cache_cur + 1));
602 zint *sysnop = sysnos;
603 ZEBRA_RES ret = ZEBRA_OK;
605 for (i = 0; i<p->cache_cur - saveCount; i++)
607 struct record_cache_entry *e = p->record_cache + i;
611 rec_cache_flush_block1(p, e->rec, last_rec, &out_buf,
612 &out_size, &out_offset);
613 *sysnop++ = rec_sysno_to_int(e->rec->sysno);
615 e->flag = recordFlagNop;
618 case recordFlagWrite:
619 if (rec_release_blocks(p, rec_sysno_to_int(e->rec->sysno))
623 rec_cache_flush_block1(p, e->rec, last_rec, &out_buf,
624 &out_size, &out_offset);
625 *sysnop++ = rec_sysno_to_int(e->rec->sysno);
627 e->flag = recordFlagNop;
630 case recordFlagDelete:
631 if (rec_delete_single(p, e->rec) != ZEBRA_OK)
634 e->flag = recordFlagNop;
644 rec_flush_shared(p, ref_count, sysnos, out_buf, out_offset);
650 static ZEBRA_RES rec_cache_flush(Records p, int saveCount)
655 if (saveCount >= p->cache_cur)
658 ret = rec_write_multiple(p, saveCount);
660 for (i = 0; i<p->cache_cur - saveCount; i++)
662 struct record_cache_entry *e = p->record_cache + i;
665 /* i still being used ... */
666 for (j = 0; j<saveCount; j++, i++)
667 memcpy(p->record_cache+j, p->record_cache+i,
668 sizeof(*p->record_cache));
669 p->cache_cur = saveCount;
673 static Record *rec_cache_lookup(Records p, zint sysno,
674 enum recordCacheFlag flag)
677 for (i = 0; i<p->cache_cur; i++)
679 struct record_cache_entry *e = p->record_cache + i;
680 if (e->rec->sysno == sysno)
682 if (flag != recordFlagNop && e->flag == recordFlagNop)
690 static ZEBRA_RES rec_cache_insert(Records p, Record rec, enum recordCacheFlag flag)
692 struct record_cache_entry *e;
693 ZEBRA_RES ret = ZEBRA_OK;
695 if (p->cache_cur == p->cache_max)
696 ret = rec_cache_flush(p, 1);
697 else if (p->cache_cur > 0)
701 for (i = 0; i<p->cache_cur; i++)
703 Record r = (p->record_cache + i)->rec;
704 for (j = 0; j<REC_NO_INFO; j++)
707 if (used > p->compression_chunk_size)
708 ret = rec_cache_flush(p, 1);
710 assert(p->cache_cur < p->cache_max);
712 e = p->record_cache + (p->cache_cur)++;
714 e->rec = rec_cp(rec);
718 ZEBRA_RES rec_close(Records *pp)
722 ZEBRA_RES ret = ZEBRA_OK;
727 zebra_mutex_destroy(&p->mutex);
728 if (rec_cache_flush(p, 0) != ZEBRA_OK)
731 xfree(p->record_cache);
735 if (recindex_write_head(p->recindex, &p->head, sizeof(p->head)) != ZEBRA_OK)
739 recindex_close(p->recindex);
741 for (i = 0; i<REC_BLOCK_TYPES; i++)
743 if (p->data_BFile[i])
744 bf_close(p->data_BFile[i]);
745 xfree(p->data_fname[i]);
753 static Record rec_get_int(Records p, zint sysno)
757 struct record_index_entry entry;
763 char compression_method;
768 if ((recp = rec_cache_lookup(p, sysno, recordFlagNop)))
769 return rec_cp(*recp);
771 if (recindex_read_indx(p->recindex, rec_sysno_to_int(sysno), &entry, sizeof(entry), 1) < 1)
772 return NULL; /* record is not there! */
775 return NULL; /* record is deleted */
777 dst_type = (int) (entry.next & 7);
778 assert(dst_type < REC_BLOCK_TYPES);
779 freeblock = entry.next / 8;
781 assert(freeblock > 0);
783 rec_tmp_expand(p, entry.size);
786 r = bf_read(p->data_BFile[dst_type], freeblock, 0, 0, cptr);
789 memcpy(&freeblock, cptr, sizeof(freeblock));
795 cptr += p->head.block_size[dst_type] - sizeof(freeblock);
797 memcpy(&tmp, cptr, sizeof(tmp));
798 r = bf_read(p->data_BFile[dst_type], freeblock, 0, 0, cptr);
801 memcpy(&freeblock, cptr, sizeof(freeblock));
802 memcpy(cptr, &tmp, sizeof(tmp));
805 rec = (Record) xmalloc(sizeof(*rec));
807 memcpy(&compression_method, p->tmp_buf + sizeof(zint) + sizeof(short),
808 sizeof(compression_method));
809 in_buf = p->tmp_buf + sizeof(zint) + sizeof(short) + sizeof(char);
810 in_size = entry.size - sizeof(short) - sizeof(char);
811 switch (compression_method)
813 case REC_COMPRESS_ZLIB:
817 unsigned int bz_size = entry.size * 20 + 100;
820 uLongf destLen = bz_size;
821 bz_buf = (char *) xmalloc(bz_size);
822 i = uncompress((Bytef *) bz_buf, &destLen,
823 (const Bytef *) in_buf, in_size);
829 yaz_log(YLOG_LOG, "failed");
837 yaz_log(YLOG_FATAL, "cannot decompress record(s) in ZLIB format");
841 case REC_COMPRESS_BZIP2:
845 unsigned int bz_size = entry.size * 20 + 100;
848 bz_buf = (char *) xmalloc(bz_size);
849 #ifdef BZ_CONFIG_ERROR
850 i = BZ2_bzBuffToBuffDecompress
852 i = bzBuffToBuffDecompress
854 (bz_buf, &bz_size, in_buf, in_size, 0, 0);
857 yaz_log(YLOG_LOG, "failed");
865 yaz_log(YLOG_FATAL, "cannot decompress record(s) in BZIP2 format");
869 case REC_COMPRESS_NONE:
872 for (i = 0; i<REC_NO_INFO; i++)
875 nptr = in_buf; /* skip ref count */
876 while (nptr < in_buf + in_size)
880 rec_decode_zint(&this_sysno, (unsigned char *) nptr, &len);
883 for (i = 0; i < REC_NO_INFO; i++)
885 unsigned int this_size;
886 rec_decode_unsigned(&this_size, (unsigned char *) nptr, &len);
891 rec->size[i] = this_size-1;
896 nptr += rec->size[i];
901 if (this_sysno == rec_sysno_to_int(sysno))
904 for (i = 0; i<REC_NO_INFO; i++)
906 if (rec->info[i] && rec->size[i])
908 char *np = xmalloc(rec->size[i]+1);
909 memcpy(np, rec->info[i], rec->size[i]);
910 np[rec->size[i]] = '\0';
915 assert(rec->info[i] == 0);
916 assert(rec->size[i] == 0);
920 if (rec_cache_insert(p, rec, recordFlagNop) != ZEBRA_OK)
925 Record rec_get(Records p, zint sysno)
928 zebra_mutex_lock(&p->mutex);
930 rec = rec_get_int(p, sysno);
931 zebra_mutex_unlock(&p->mutex);
935 Record rec_get_root(Records p)
937 return rec_get(p, rec_sysno_to_ext(1));
940 Record rec_get_next(Records p, Record rec)
943 zint next_sysno_int = rec_sysno_to_int(rec->sysno);
948 if (next_sysno_int == p->head.index_last)
950 next = rec_get(p, rec_sysno_to_ext(next_sysno_int));
955 static Record rec_new_int(Records p)
962 rec = (Record) xmalloc(sizeof(*rec));
963 if (1 || p->head.index_free == 0)
964 sysno = (p->head.index_last)++;
967 struct record_index_entry entry;
969 if (recindex_read_indx(p->recindex, p->head.index_free, &entry, sizeof(entry), 0) < 1)
974 sysno = p->head.index_free;
975 p->head.index_free = entry.next;
977 (p->head.no_records)++;
978 rec->sysno = rec_sysno_to_ext(sysno);
979 for (i = 0; i < REC_NO_INFO; i++)
984 rec_cache_insert(p, rec, recordFlagNew);
988 Record rec_new(Records p)
991 zebra_mutex_lock(&p->mutex);
993 rec = rec_new_int(p);
994 zebra_mutex_unlock(&p->mutex);
998 ZEBRA_RES rec_del(Records p, Record *recpp)
1001 ZEBRA_RES ret = ZEBRA_OK;
1003 zebra_mutex_lock(&p->mutex);
1004 (p->head.no_records)--;
1005 if ((recp = rec_cache_lookup(p, (*recpp)->sysno, recordFlagDelete)))
1012 ret = rec_cache_insert(p, *recpp, recordFlagDelete);
1015 zebra_mutex_unlock(&p->mutex);
1020 ZEBRA_RES rec_put(Records p, Record *recpp)
1023 ZEBRA_RES ret = ZEBRA_OK;
1025 zebra_mutex_lock(&p->mutex);
1026 if ((recp = rec_cache_lookup(p, (*recpp)->sysno, recordFlagWrite)))
1033 ret = rec_cache_insert(p, *recpp, recordFlagWrite);
1036 zebra_mutex_unlock(&p->mutex);
1041 void rec_free(Record *recpp)
1047 for (i = 0; i < REC_NO_INFO; i++)
1048 xfree((*recpp)->info[i]);
1053 Record rec_cp(Record rec)
1058 n = (Record) xmalloc(sizeof(*n));
1059 n->sysno = rec->sysno;
1060 for (i = 0; i < REC_NO_INFO; i++)
1068 n->size[i] = rec->size[i];
1069 n->info[i] = (char *) xmalloc(rec->size[i]+1);
1070 memcpy(n->info[i], rec->info[i], rec->size[i]);
1071 n->info[i][rec->size[i]] = '\0';
1077 char *rec_strdup(const char *s, size_t *len)
1087 p = (char *) xmalloc(*len);
1092 void rec_prstat(Records records, int verbose)
1095 zint total_bytes = 0;
1098 "Total records %8" ZINT_FORMAT0,
1099 records->head.no_records);
1101 for (i = 0; i< REC_BLOCK_TYPES; i++)
1103 yaz_log (YLOG_LOG, "Record blocks of size "ZINT_FORMAT,
1104 records->head.block_size[i]);
1106 " Used/Total/Bytes used "
1107 ZINT_FORMAT "/" ZINT_FORMAT "/" ZINT_FORMAT,
1108 records->head.block_used[i], records->head.block_last[i]-1,
1109 records->head.block_used[i] * records->head.block_size[i]);
1111 records->head.block_used[i] * records->head.block_size[i];
1113 yaz_log(YLOG_LOG, " Block Last " ZINT_FORMAT, records->head.block_last[i]);
1115 { /* analyse free lists */
1117 zint block_free = records->head.block_free[i];
1118 WRBUF w = wrbuf_alloc();
1123 wrbuf_printf(w, " " ZINT_FORMAT, block_free);
1124 if (bf_read(records->data_BFile[i],
1125 block_free, 0, sizeof(nblock), &nblock) != 1)
1127 yaz_log(YLOG_FATAL|YLOG_ERRNO, "read in %s at free block "
1129 records->data_fname[i], block_free);
1132 block_free = nblock;
1135 " Number in free list %8" ZINT_FORMAT0, no_free);
1137 yaz_log(YLOG_LOG, "%s", wrbuf_cstr(w));
1142 "Total size of record index in bytes %8" ZINT_FORMAT0,
1143 records->head.total_bytes);
1145 "Total size with overhead %8" ZINT_FORMAT0,
1152 * c-file-style: "Stroustrup"
1153 * indent-tabs-mode: nil
1155 * vim: shiftwidth=4 tabstop=8 expandtab