Blocks are stored in chunks on free list - up to factor 2 in speed.
[idzebra-moved-to-github.git] / isamc / isamc-p.h
1 /*
2  * Copyright (c) 1995-1996, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: isamc-p.h,v $
7  * Revision 1.6  1998-03-18 09:23:55  adam
8  * Blocks are stored in chunks on free list - up to factor 2 in speed.
9  * Fixed bug that could occur in block category rearrangemen.
10  *
11  * Revision 1.5  1998/03/16 10:37:24  adam
12  * Added more statistics.
13  *
14  * Revision 1.4  1996/11/08 11:15:28  adam
15  * Number of keys in chain are stored in first block and the function
16  * to retrieve this information, isc_pp_num is implemented.
17  *
18  * Revision 1.3  1996/11/04 14:08:55  adam
19  * Optimized free block usage.
20  *
21  * Revision 1.2  1996/11/01 08:59:13  adam
22  * First version of isc_merge that supports update/delete.
23  *
24  * Revision 1.1  1996/10/29 13:40:47  adam
25  * First work.
26  *
27  */
28
29 #include <bfile.h>
30 #include <isamc.h>
31
32 typedef struct {
33     int lastblock;
34     int freelist;
35 } ISAMC_head;
36
37 typedef unsigned ISAMC_BLOCK_SIZE;
38
39 typedef struct ISAMC_file_s {
40     ISAMC_head head;
41     BFile bf;
42     int head_is_dirty;
43     
44     int no_writes;
45     int no_reads;
46     int no_skip_writes;
47     int no_allocated;
48     int no_released;
49     int no_remap;
50
51     int no_forward;
52     int no_backward;
53     int sum_forward;
54     int sum_backward;
55     int no_next;
56     int no_prev;
57
58     char *alloc_buf;
59     int alloc_entries_num;
60     int alloc_entries_max;
61
62     int fc_max;
63     int *fc_list;
64 } *ISAMC_file;
65
66 struct ISAMC_s {
67     int no_files;
68     int max_cat;
69     char *merge_buf;
70     ISAMC_M method;
71     ISAMC_file files;
72 }; 
73
74 struct ISAMC_PP_s {
75     char *buf;
76     ISAMC_BLOCK_SIZE offset;
77     ISAMC_BLOCK_SIZE size;
78     int cat;
79     int pos;
80     int next;
81     ISAMC is;
82     void *decodeClientData;
83     int deleteFlag;
84     int numKeys;
85 };
86
87 #define ISAMC_BLOCK_OFFSET_N (sizeof(int)+sizeof(ISAMC_BLOCK_SIZE)) 
88 #define ISAMC_BLOCK_OFFSET_1 (sizeof(int)+sizeof(ISAMC_BLOCK_SIZE)+sizeof(int)) 
89 int isc_alloc_block (ISAMC is, int cat);
90 void isc_release_block (ISAMC is, int cat, int pos);
91 int isc_read_block (ISAMC is, int cat, int pos, char *dst);
92 int isc_write_block (ISAMC is, int cat, int pos, char *src);