-/* $Id: cfile.c,v 1.28 2004-08-04 08:35:22 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
- Index Data Aps
+/* $Id: cfile.c,v 1.35 2005-04-15 10:47:47 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
- logf (LOG_DEBUG, "cf: open %s %s", cf->rmf->name, wflag ? "rdwr" : "rd");
+ yaz_log (YLOG_DEBUG, "cf: open %s %s", cf->rmf->name, wflag ? "rdwr" : "rd");
sprintf (path, "%s-b", fname);
if (!(cf->block_mf = mf_open (area, path, block_size, wflag)))
{
sprintf (path, "%s-b", fname);
if (!(cf->block_mf = mf_open (area, path, block_size, wflag)))
{
exit (1);
}
sprintf (path, "%s-i", fname);
if (!(cf->hash_mf = mf_open (area, path, HASH_BSIZE, wflag)))
{
exit (1);
}
sprintf (path, "%s-i", fname);
if (!(cf->hash_mf = mf_open (area, path, HASH_BSIZE, wflag)))
{
cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket =
(hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2;
cf->head.next_block = 1;
if (wflag)
mf_write (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head);
cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket =
(hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2;
cf->head.next_block = 1;
if (wflag)
mf_write (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head);
{
struct CFile_hash_bucket *p;
p = alloc_bucket (cf, block_no, hno);
if (!mf_read (cf->hash_mf, block_no, 0, 0, &p->ph))
{
{
struct CFile_hash_bucket *p;
p = alloc_bucket (cf, block_no, hno);
if (!mf_read (cf->hash_mf, block_no, 0, 0, &p->ph))
{
block_no = *block_nop = cf->head.next_bucket++;
p = alloc_bucket (cf, block_no, hno);
block_no = *block_nop = cf->head.next_bucket++;
p = alloc_bucket (cf, block_no, hno);
- mf_read (cf->hash_mf, hno+cf->head.next_bucket, off, sizeof(int), &vno);
+ mf_read (cf->hash_mf, hno+cf->head.next_bucket, off, sizeof(zint), &vno);
{
int hno = cf_hash (cf, no);
struct CFile_hash_bucket *hb;
{
int hno = cf_hash (cf, no);
struct CFile_hash_bucket *hb;
hno += cf->head.next_bucket;
if (hno >= cf->head.flat_bucket)
cf->head.flat_bucket = hno+1;
cf->dirty = 1;
hno += cf->head.next_bucket;
if (hno >= cf->head.flat_bucket)
cf->head.flat_bucket = hno+1;
cf->dirty = 1;
- mf_write (cf->hash_mf, hno, off, sizeof(int), &vno);
+ mf_write (cf->hash_mf, hno, off, sizeof(zint), &vno);
- logf (LOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name);
- logf (LOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total="
+ yaz_log (YLOG_DEBUG, "cf: Moving to flat shadow: %s", cf->rmf->name);
+ yaz_log (YLOG_DEBUG, "cf: hits=%d miss=%d bucket_in_memory=" ZINT_FORMAT " total="
ZINT_FORMAT,
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
ZINT_FORMAT,
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
{
if (!mf_read (cf->hash_mf, i, 0, 0, &p->ph))
{
{
if (!mf_read (cf->hash_mf, i, 0, 0, &p->ph))
{
{
if (cf->head.state > 1)
return cf_lookup_flat (cf, no);
return cf_lookup_hash (cf, no);
}
{
if (cf->head.state > 1)
return cf_lookup_flat (cf, no);
return cf_lookup_hash (cf, no);
}
{
int hno = cf_hash (cf, no);
struct CFile_hash_bucket *hbprev = NULL, *hb = cf->parray[hno];
{
int hno = cf_hash (cf, no);
struct CFile_hash_bucket *hbprev = NULL, *hb = cf->parray[hno];
- int *bucketpp = &cf->array[hno];
- int i, vno = (cf->head.next_block)++;
+ zint *bucketpp = &cf->array[hno];
+ int i;
+ zint vno = (cf->head.next_block)++;
int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf)
{
int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf)
{
zebra_mutex_unlock (&cf->mutex);
if (!mf_read (cf->block_mf, block, offset, nbytes, buf))
{
zebra_mutex_unlock (&cf->mutex);
if (!mf_read (cf->block_mf, block, offset, nbytes, buf))
{
- logf (LOG_FATAL|LOG_ERRNO, "cf_read no=" ZINT_FORMAT ", block=%d", no, block);
+ yaz_log (YLOG_FATAL|YLOG_ERRNO, "cf_read no=" ZINT_FORMAT " block=" ZINT_FORMAT, no, block);
int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf)
{
int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf)
{
zebra_mutex_unlock (&cf->mutex);
if (mf_write (cf->block_mf, block, offset, nbytes, buf))
{
zebra_mutex_unlock (&cf->mutex);
if (mf_write (cf->block_mf, block, offset, nbytes, buf))
{
- logf (LOG_FATAL|LOG_ERRNO, "cf_write no=" ZINT_FORMAT ", block=%d", no, block);
+ yaz_log (YLOG_FATAL|YLOG_ERRNO, "cf_write no=" ZINT_FORMAT
+ " block=" ZINT_FORMAT, no, block);
" total=" ZINT_FORMAT,
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
" total=" ZINT_FORMAT,
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);