2 * Copyright (c) 1995-1996, Index Data.
3 * See the file LICENSE for details.
5 * ISAM-G the general encapsulation of all our ISAM types
19 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20 * Local type declarations
21 * Not to be used from outside this module
22 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
29 /* The isam type itself. File handles, statistics, block sizes */
30 typedef struct ISAMG_file_s {
32 enum isam_types isam_type;
34 /* these might be better off as an union of different types. */
49 typedef struct ISAMG_DIFF_s *ISAMG_DIFF;
51 /* ISAMG position structure. Used for reading through the isam */
54 char *buf; /* buffer for read/write operations */
55 ISAMG_BLOCK_SIZE offset; /* position for next read/write */
56 ISAMG_BLOCK_SIZE size; /* size of actual data */
57 int cat; /* category of this block */
58 int pos; /* block number of this block */
59 int next; /* number of the next block */
60 int diffs; /* not used in the modern isam-d, but kept for stats compatibility */
61 /* never stored on disk, though */
63 ISAMG is; /* the isam itself */
64 void *decodeClientData; /* delta-encoder's own data */
67 char *diffbuf; /* buffer for the diff block */
73 #define ISAMG_BLOCK_OFFSET_N (sizeof(int) + \
74 sizeof(ISAMG_BLOCK_SIZE))
76 #define ISAMG_BLOCK_OFFSET_1 (sizeof(int) + \
77 sizeof(ISAMG_BLOCK_SIZE) + \
78 sizeof(ISAMG_BLOCK_SIZE))
83 int isamg_alloc_block (ISAMG is, int cat);
84 void isamg_release_block (ISAMG is, int cat, int pos);
85 int isamg_read_block (ISAMG is, int cat, int pos, char *dst);
86 int isamg_write_block (ISAMG is, int cat, int pos, char *src);
87 void isamg_free_diffs(ISAMG_PP pp);
89 int is_singleton(ISAMG_P ipos);
90 void singleton_decode (int code, struct it_key *k);
91 int singleton_encode(struct it_key *k);
94 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
96 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
98 ISAMG isamg_open (BFiles bfs, int writeflag, char *isam_type_name, Res res){
100 is = (ISAMD) xmalloc(sizeof(*is));
101 is->isam_type_name = strdup(isam_type_name);
102 if ( (0==strcmp(isam_type_name,"d") ||
103 (0==strcmp(isam_type_name,"isam_d")) {
104 is->isam_type = isamtype_isamd;
105 is->isamd = isamd_open(bfs,FNAME_ISAMD,
106 writeflag, key_isamd_m (res,&isamd_m)
109 logf (LOG_FATAL, "isamg: Unknown isam type: %s", isam_type_name);
114 int isamg_close (ISAMG is){
116 assert(is->isam_type);
117 select (is->isam_type) {
118 case isamtype_isamd: return isams_close(is->isamd);
132 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
134 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
139 * Revision 1.1 2001-01-16 19:05:45 heikki
140 * Started to work on isamg