746c14c68a6ccb32f0800a401ec06e958d2b544b
[idzebra-moved-to-github.git] / isamc / isamd-p.h
1 /* $Id: isamd-p.h,v 1.8 1999-09-23 18:01:18 heikki Exp $
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     int no_op_nodiff; /* existing blocks opened for reading without diffs */
43     int no_op_intdiff; /* - with internal diffs */
44     int no_op_extdiff; /* with separate diff blocks */
45     int no_fbuilds;    /* number of first-time builds */
46     int no_appds;      /* number of appends */
47     int no_merges;     /* number of merges done */
48     int no_remerges;   /* number of times more than one merge needed */
49
50     char *alloc_buf;    /* free-list handling (?) */
51     int alloc_entries_num;
52     int alloc_entries_max;
53
54     int fc_max;
55     int *fc_list;
56 } *ISAMD_file;
57
58 struct ISAMD_s {
59     int no_files;
60     int max_cat;
61     ISAMD_M method;
62     ISAMD_file files;
63 }; 
64
65
66 typedef struct ISAMD_DIFF_s *ISAMD_DIFF;
67
68 struct ISAMD_PP_s {
69     char *buf;   /* buffer for read/write operations */
70     ISAMD_BLOCK_SIZE offset; /* position for next read/write */
71     ISAMD_BLOCK_SIZE size;   /* size of actual data */
72     int cat;  /* category of this block */
73     int pos;  /* block number of this block */
74     int next; /* number of the next block */
75     int diffs; /* not used in the modern isam-d, but kept for stats compatibility */
76                /* never stored on disk, though */
77     ISAMD is;
78     void *decodeClientData;  /* delta-encoder's own data */
79     ISAMD_DIFF diffinfo;
80     char *diffbuf; /* buffer for the diff block */
81     int numKeys;
82 };
83
84 #define ISAMD_BLOCK_OFFSET_N (sizeof(int) +  \
85                               sizeof(ISAMD_BLOCK_SIZE)) 
86 /* == 8 */
87 #define ISAMD_BLOCK_OFFSET_1 (sizeof(int) + \
88                               sizeof(ISAMD_BLOCK_SIZE) + \
89                               sizeof(ISAMD_BLOCK_SIZE)) 
90 /* == 12  (was 16) */
91 //                              sizeof(int) + 
92
93
94 int isamd_alloc_block (ISAMD is, int cat);
95 void isamd_release_block (ISAMD is, int cat, int pos);
96 int isamd_read_block (ISAMD is, int cat, int pos, char *dst);
97 int isamd_write_block (ISAMD is, int cat, int pos, char *src);
98 void isamd_free_diffs(ISAMD_PP pp);
99
100 int is_singleton(ISAMD_P ipos);
101 void singleton_decode (int code, struct it_key *k);
102 int singleton_encode(struct it_key *k);
103
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109
110
111 /*
112  * $Log: isamd-p.h,v $
113  * Revision 1.8  1999-09-23 18:01:18  heikki
114  * singleton optimising
115  *
116  * Revision 1.7  1999/09/20 15:48:06  heikki
117  * Small changes
118  *
119  * Revision 1.6  1999/08/25 18:09:23  heikki
120  * Starting to optimize
121  *
122  * Revision 1.5  1999/08/20 12:25:58  heikki
123  * Statistics in isamd
124  *
125  * Revision 1.4  1999/07/21 14:24:50  heikki
126  * isamd write and read functions ok, except when diff block full.
127  * (merge not yet done)
128  *
129  * Revision 1.3  1999/07/14 15:05:30  heikki
130  * slow start on isam-d
131  *
132  * Revision 1.1  1999/07/14 12:34:43  heikki
133  * Copied from isamh, starting to change things...
134  *
135  *
136  */