1fa1dbd7a63154f29ed21e0f3a0640861ac0336d
[idzebra-moved-to-github.git] / isamc / isamd-p.h
1 /* $Id: isamd-p.h,v 1.10 2002-04-29 18:10:24 adam 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;  /* stats from pp_read, for isam-c compatibility */
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_diffonly;/* number of opens without mainblock */
43     int no_op_main;    /* number of opens with a main block */
44
45     char *alloc_buf;    /* free-list handling (?) */
46     int alloc_entries_num;
47     int alloc_entries_max;
48
49     int fc_max;
50     int *fc_list;
51 } *ISAMD_file;
52
53 struct ISAMD_s {
54     int no_files;
55     int max_cat;
56     ISAMD_M method;
57     ISAMD_file files;
58     int last_pos;   /* last read/write position for seek stats */
59     int last_cat;   /* same for category */
60     int no_read;    /* blocks read (in all categories) */
61     int no_write;   /* blocks written (in all categories) */
62     int no_op_single;/* singleton "blocks" opened */
63     int no_read_keys;/* number of keys read (occurences of words) */
64     int no_read_main;/* number of main keys read (not diffs) */
65     int no_read_eof; /* number of key sequence ends read (no of words read) */
66     int no_seek_nxt; /* seeks to the next record (fast) */
67     int no_seek_sam; /* seeks to same record (fast) */
68     int no_seek_fwd; /* seeks forward */
69     int no_seek_prv; /* seeks to previous */
70     int no_seek_bak; /* seeks backwards */
71     int no_seek_cat; /* seeks to different category (expensive) */
72     int no_op_new;  /* "open"s for new blocks */
73     int no_fbuilds;    /* number of first-time builds */
74     int no_appds;      /* number of appends */
75     int no_merges;     /* number of merges done */
76     int no_non;     /* merges without any work */
77     int no_singles; /* new items resulting in singletons */
78 }; 
79
80
81 typedef struct ISAMD_DIFF_s *ISAMD_DIFF;
82
83 struct ISAMD_PP_s {
84     char *buf;   /* buffer for read/write operations */
85     ISAMD_BLOCK_SIZE offset; /* position for next read/write */
86     ISAMD_BLOCK_SIZE size;   /* size of actual data */
87     int cat;  /* category of this block */
88     int pos;  /* block number of this block */
89     int next; /* number of the next block */
90     int diffs; /* not used in the modern isam-d, but kept for stats compatibility */
91                /* never stored on disk, though */
92     ISAMD is;
93     void *decodeClientData;  /* delta-encoder's own data */
94     ISAMD_DIFF diffinfo;
95     char *diffbuf; /* buffer for the diff block */
96     int numKeys;
97 };
98
99 #define ISAMD_BLOCK_OFFSET_N (sizeof(int) +  \
100                               sizeof(ISAMD_BLOCK_SIZE)) 
101 /* == 8 */
102 #define ISAMD_BLOCK_OFFSET_1 (sizeof(int) + \
103                               sizeof(ISAMD_BLOCK_SIZE) + \
104                               sizeof(ISAMD_BLOCK_SIZE)) 
105 /* == 12  (was 16) */
106 //                              sizeof(int) + 
107
108
109 int isamd_alloc_block (ISAMD is, int cat);
110 void isamd_release_block (ISAMD is, int cat, int pos);
111 int isamd_read_block (ISAMD is, int cat, int pos, char *dst);
112 int isamd_write_block (ISAMD is, int cat, int pos, char *src);
113 void isamd_free_diffs(ISAMD_PP pp);
114
115 int is_singleton(ISAMD_P ipos);
116 void singleton_decode (int code, struct it_key *k);
117 int singleton_encode(struct it_key *k);
118
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124
125
126 /*
127  * $Log: isamd-p.h,v $
128  * Revision 1.10  2002-04-29 18:10:24  adam
129  * Newline at end of file
130  *
131  * Revision 1.9  1999/10/05 09:57:40  heikki
132  * Tuning the isam-d (and fixed a small "detail")
133  *
134  * Revision 1.8  1999/09/23 18:01:18  heikki
135  * singleton optimising
136  *
137  * Revision 1.7  1999/09/20 15:48:06  heikki
138  * Small changes
139  *
140  * Revision 1.6  1999/08/25 18:09:23  heikki
141  * Starting to optimize
142  *
143  * Revision 1.5  1999/08/20 12:25:58  heikki
144  * Statistics in isamd
145  *
146  * Revision 1.4  1999/07/21 14:24:50  heikki
147  * isamd write and read functions ok, except when diff block full.
148  * (merge not yet done)
149  *
150  * Revision 1.3  1999/07/14 15:05:30  heikki
151  * slow start on isam-d
152  *
153  * Revision 1.1  1999/07/14 12:34:43  heikki
154  * Copied from isamh, starting to change things...
155  *
156  *
157  */
158