1 /* This file is part of the Zebra server.
2 Copyright (C) 1995-2008 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
25 #include <yaz/yconfig.h>
29 #define HASH_BUCKET 15
31 struct CFile_ph_bucket { /* structure on disc */
32 zint no[HASH_BUCKET]; /* block number in original file */
33 zint vno[HASH_BUCKET]; /* block number in shadow file */
34 zint this_bucket; /* this bucket number */
35 zint next_bucket; /* next bucket number */
38 struct CFile_hash_bucket {
39 struct CFile_ph_bucket ph;
41 struct CFile_hash_bucket *h_next, **h_prev;
42 struct CFile_hash_bucket *lru_next, *lru_prev;
45 #define HASH_BSIZE sizeof(struct CFile_ph_bucket)
49 typedef struct CFile_struct
52 int state; /* 1 = hash, 2 = flat */
53 zint next_block; /* next free block / last block */
54 int block_size; /* mfile/bfile block size */
55 int hash_size; /* no of chains in hash table */
56 zint first_bucket; /* first hash bucket */
57 zint next_bucket; /* last hash bucket + 1 = first flat bucket */
58 zint flat_bucket; /* last flat bucket + 1 */
63 struct CFile_hash_bucket **parray;
64 struct CFile_hash_bucket *bucket_lru_front, *bucket_lru_back;
66 zint bucket_in_memory;
67 zint max_bucket_in_memory;
75 int cf_close (CFile cf);
76 CFile cf_open (MFile mf, MFile_area area, const char *fname, int block_size,
77 int wflag, int *firstp);
78 int cf_read (CFile cf, zint no, int offset, int nbytes, void *buf);
79 int cf_write (CFile cf, zint no, int offset, int nbytes, const void *buf);
80 int cf_commit (CFile cf) ZEBRA_GCC_ATTR((warn_unused_result));
88 * indent-tabs-mode: nil
90 * vim: shiftwidth=4 tabstop=8 expandtab