isamd write and read functions ok, except when diff block full.
[idzebra-moved-to-github.git] / isamc / isamd-p.h
1 /*
2  * Copyright (c) 1995-1996, Index Data.
3  * See the file LICENSE for details.
4  * Heikki Levanto
5  *
6  * log at the end
7  */
8
9 #include <bfile.h>
10 #include <isamd.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 typedef struct {
17     int lastblock;
18     int freelist;
19 } ISAMD_head;
20
21 typedef unsigned ISAMD_BLOCK_SIZE;
22
23 typedef struct ISAMD_file_s {
24     ISAMD_head head;
25     BFile bf;
26     int head_is_dirty;
27     
28     int no_writes;  /* statistics, to be used properly... */
29     int no_reads;
30     int no_skip_writes;
31     int no_allocated;
32     int no_released;
33     int no_remap;
34
35     int no_forward;
36     int no_backward;
37     int sum_forward;
38     int sum_backward;
39     int no_next;
40     int no_prev;
41
42     char *alloc_buf;    /* free-list handling (?) */
43     int alloc_entries_num;
44     int alloc_entries_max;
45
46     int fc_max;
47     int *fc_list;
48 } *ISAMD_file;
49
50 struct ISAMD_s {
51     int no_files;
52     int max_cat;
53     ISAMD_M method;
54     ISAMD_file files;
55 }; 
56
57
58 typedef struct ISAMD_DIFF_s *ISAMD_DIFF;
59
60 struct ISAMD_PP_s {
61     char *buf;   /* buffer for read/write operations */
62     ISAMD_BLOCK_SIZE offset; /* position for next read/write */
63     ISAMD_BLOCK_SIZE size;   /* size of actual pointer data */
64     int cat;  /* category of this block */
65     int pos;  /* block number of this block */
66     int next; /* number of the next block */
67     int diffs; /* either block or offset (in head) of start of diffs */
68     ISAMD is;
69     void *decodeClientData;
70     ISAMD_DIFF diffinfo;
71     char *diffbuf; /* buffer for the diff block, only when reading */
72     int numKeys;
73 };
74
75 #define ISAMD_BLOCK_OFFSET_N (sizeof(int) +  \
76                               sizeof(ISAMD_BLOCK_SIZE)) 
77 /* == 8 */
78 #define ISAMD_BLOCK_OFFSET_1 (sizeof(int) + \
79                               sizeof(ISAMD_BLOCK_SIZE) + \
80                               sizeof(int) + \
81                               sizeof(ISAMD_BLOCK_SIZE)) 
82 /* == 16 */
83
84
85 int isamd_alloc_block (ISAMD is, int cat);
86 void isamd_release_block (ISAMD is, int cat, int pos);
87 int isamd_read_block (ISAMD is, int cat, int pos, char *dst);
88 int isamd_write_block (ISAMD is, int cat, int pos, char *src);
89 void isamd_free_diffs(ISAMD_PP pp);
90
91 #ifdef __cplusplus
92 }
93 #endif
94
95
96
97 /*
98  * $Log: isamd-p.h,v $
99  * Revision 1.4  1999-07-21 14:24:50  heikki
100  * isamd write and read functions ok, except when diff block full.
101  * (merge not yet done)
102  *
103  * Revision 1.3  1999/07/14 15:05:30  heikki
104  * slow start on isam-d
105  *
106  * Revision 1.1  1999/07/14 12:34:43  heikki
107  * Copied from isamh, starting to change things...
108  *
109  *
110  */