1 /* $Id: isam.h,v 1.15 2002-08-02 19:26:55 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
31 #include "../isam/memory.h"
32 #include "../isam/physical.h"
38 #define IS_MAX_BLOCKTYPES 4
39 #define IS_MAX_RECORD 512
40 #define IS_DEF_REPACK_PERCENT "30" /* how much relative change before repack */
43 * Description of a blocktype (part of an isam file)
45 typedef struct isam_blocktype
47 BFile bf; /* blocked file */
49 int first_block; /* position of first data block */
50 int max_keys_block; /* max num of keys per block */
51 int max_keys_block0; /* max num of keys in first block */
52 int nice_keys_block; /* nice number of keys per block */
53 int max_keys; /* max number of keys per table */
54 int freelist; /* first free block */
55 int top; /* first unused block */
56 int index; /* placeholder. Always 0. */
57 char *dbuf; /* buffer for use in I/O operations */
61 * Handle to an open isam complex.
63 typedef struct isam_struct
65 isam_blocktype types[IS_MAX_BLOCKTYPES]; /* block_types used in this file */
66 int num_types; /* number of block types used */
68 int keysize; /* size of the keys (records) used */
69 int repack; /* how many percent to grow before repack */
70 int (*cmp)(const void *k1, const void *k2); /* compare function */
73 typedef struct ispt_struct
76 struct ispt_struct *next; /* freelist */
79 #define is_type(x) ((x) & 3) /* type part of position */
80 #define is_block(x) ((x) >> 2) /* block # part of position */
82 #define is_keysize(is) ((is)->keysize)
86 *******************************************************************
92 ISAM is_open(BFiles bfs, const char *name,
93 int (*cmp)(const void *p1, const void *p2),
94 int writeflag, int keysize, Res res);
99 int is_close(ISAM is);
102 * Locate a table of keys in an isam file. The ISPT is an individual
103 * position marker for that table.
105 ISPT is_position(ISAM is, ISAM_P pos);
110 void is_pt_free(ISPT ip);
113 * Read a key from a table.
115 int is_readkey(ISPT ip, void *buf);
117 int is_writekey(ISPT ip, const void *buf);
119 int is_numkeys(ISPT ip);
121 void is_rewind(ISPT ip);
123 ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data);