More work on boolean sets.
[idzebra-moved-to-github.git] / include / isam.h
1 /*
2  * Copyright (C) 1994, Index Data I/S 
3  * All rights reserved.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: isam.h,v $
7  * Revision 1.10  1995-09-06 16:10:57  adam
8  * More work on boolean sets.
9  *
10  * Revision 1.9  1994/09/28  16:58:26  quinn
11  * Small mod.
12  *
13  * Revision 1.8  1994/09/28  12:56:09  quinn
14  * Added access functions (ISPT)
15  *
16  * Revision 1.7  1994/09/28  11:56:13  quinn
17  * Removed const from input to is_merge
18  *
19  * Revision 1.6  1994/09/28  11:29:28  quinn
20  * Added cmp parameter.
21  *
22  * Revision 1.5  1994/09/27  20:03:36  quinn
23  * Seems relatively bug-free.
24  *
25  * Revision 1.4  1994/09/26  17:05:54  quinn
26  * Trivial.
27  *
28  * Revision 1.3  1994/09/26  16:08:42  quinn
29  * Most of the functionality in place.
30  *
31  * Revision 1.2  1994/09/14  13:10:35  quinn
32  * Small changes
33  *
34  * Revision 1.1  1994/09/12  08:02:07  quinn
35  * Not functional yet
36  *
37  */
38
39 #ifndef ISAM_H
40 #define ISAM_H
41
42 #include <bfile.h>
43
44 #include "../isam/memory.h"
45 #include "../isam/physical.h"
46
47 #define IS_MAX_BLOCKTYPES 4
48 #define IS_MAX_RECORD 512
49 #define IS_DEF_REPACK_PERCENT "30" /* how much relative change before repack */
50
51 typedef unsigned int SYSNO; /* should be somewhere else */
52
53 /*
54  * Description of a blocktype (part of an isam file)
55  */
56 typedef struct isam_blocktype
57 {
58     BFile bf;                    /* blocked file */
59     int blocksize;
60     int first_block;             /* position of first data block */
61     int max_keys_block;          /* max num of keys per block */
62     int max_keys_block0;         /* max num of keys in first block */
63     int nice_keys_block;         /* nice number of keys per block */
64     int max_keys;                /* max number of keys per table */
65     int freelist;                /* first free block */
66     int top;                     /* first unused block */
67     int index;                   /* placeholder. Always 0. */
68     char *dbuf;                  /* buffer for use in I/O operations */
69 } isam_blocktype;
70
71 /*
72  * Handle to an open isam complex.
73  */
74 typedef struct isam_struct
75 {
76     isam_blocktype types[IS_MAX_BLOCKTYPES]; /* block_types used in this file */
77     int num_types;                /* number of block types used */
78     int writeflag;
79     int keysize;                  /* size of the keys (records) used */
80     int repack;                   /* how many percent to grow before repack */
81     int (*cmp)(const void *k1, const void *k2); /* compare function */
82 } isam_struct;
83
84 typedef struct ispt_struct
85 {
86     struct is_mtable tab;
87     struct ispt_struct *next;      /* freelist */
88 } ispt_struct, *ISPT; 
89
90 #define is_type(x) ((x) & 3)      /* type part of position */
91 #define is_block(x) ((x) >> 2)     /* block # part of position */
92
93 #define is_keysize(is) ((is)->keysize)
94
95 /*
96  * Public Prototypes.
97  *******************************************************************
98  */
99
100 /*
101  * Open isam file.
102  */
103 ISAM is_open(const char *name, int (*cmp)(const void *p1, const void *p2),
104     int writeflag, int keysize);
105
106 /*
107  * Close isam file.
108  */
109 int is_close(ISAM is);
110
111 /*
112  * Locate a table of keys in an isam file. The ISPT is an individual
113  * position marker for that table.
114  */
115 ISPT is_position(ISAM is, ISAM_P pos);
116
117 /*
118  * Release ISPT.
119  */
120 void is_pt_free(ISPT ip);
121
122 /*
123  * Read a key from a table.
124  */
125 int is_readkey(ISPT ip, void *buf);
126
127 int is_writekey(ISPT ip, const void *buf);
128
129 int is_numkeys(ISPT ip);
130
131 void is_rewind(ISPT ip);
132
133 ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data);
134
135 #endif