1 /* $Id: isamg.c,v 1.3 2003-04-02 19:01:47 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 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
33 * Local type declarations
34 * Not to be used from outside this module
35 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
42 /* The isam type itself. File handles, statistics, block sizes */
43 typedef struct ISAMG_file_s {
45 enum isam_types isam_type;
47 /* these might be better off as an union of different types. */
62 typedef struct ISAMG_DIFF_s *ISAMG_DIFF;
64 /* ISAMG position structure. Used for reading through the isam */
67 char *buf; /* buffer for read/write operations */
68 ISAMG_BLOCK_SIZE offset; /* position for next read/write */
69 ISAMG_BLOCK_SIZE size; /* size of actual data */
70 int cat; /* category of this block */
71 int pos; /* block number of this block */
72 int next; /* number of the next block */
73 int diffs; /* not used in the modern isam-d, but kept for stats compatibility */
74 /* never stored on disk, though */
76 ISAMG is; /* the isam itself */
77 void *decodeClientData; /* delta-encoder's own data */
80 char *diffbuf; /* buffer for the diff block */
86 #define ISAMG_BLOCK_OFFSET_N (sizeof(int) + \
87 sizeof(ISAMG_BLOCK_SIZE))
89 #define ISAMG_BLOCK_OFFSET_1 (sizeof(int) + \
90 sizeof(ISAMG_BLOCK_SIZE) + \
91 sizeof(ISAMG_BLOCK_SIZE))
95 int isamg_alloc_block (ISAMG is, int cat);
96 void isamg_release_block (ISAMG is, int cat, int pos);
97 int isamg_read_block (ISAMG is, int cat, int pos, char *dst);
98 int isamg_write_block (ISAMG is, int cat, int pos, char *src);
99 void isamg_free_diffs(ISAMG_PP pp);
101 int is_singleton(ISAMG_P ipos);
102 void singleton_decode (int code, struct it_key *k);
103 int singleton_encode(struct it_key *k);
106 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
108 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
110 ISAMG isamg_open (BFiles bfs, int writeflag, char *isam_type_name, Res res){
112 is = (ISAMD) xmalloc(sizeof(*is));
113 is->isam_type_name = strdup(isam_type_name);
114 if ( (0==strcmp(isam_type_name,"d") ||
115 (0==strcmp(isam_type_name,"isam_d")) {
116 is->isam_type = isamtype_isamd;
117 is->isamd = isamd_open(bfs,FNAME_ISAMD,
118 writeflag, key_isamd_m (res,&isamd_m)
121 logf (LOG_FATAL, "isamg: Unknown isam type: %s", isam_type_name);
126 int isamg_close (ISAMG is){
128 assert(is->isam_type);
129 select (is->isam_type) {
130 case isamtype_isamd: return isams_close(is->isamd);
144 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
146 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
151 * Revision 1.3 2003-04-02 19:01:47 adam
154 * Revision 1.2 2002/08/02 19:26:56 adam
157 * Revision 1.1 2001/01/16 19:05:45 heikki
158 * Started to work on isamg