18
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
#include <drizzled/internal/my_sys.h>
28
#define my_b_EOF INT_MIN
30
class io_cache_st /* Used when cacheing files */
33
typedef int (*IO_CACHE_CALLBACK)(io_cache_st*);
21
#ifndef DRIZZLED_INTERNAL_IOCACHE_H
22
#define DRIZZLED_INTERNAL_IOCACHE_H
24
#include "drizzled/internal/my_sys.h"
32
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
34
struct st_io_cache /* Used when cacheing files */
35
36
/* Offset in file corresponding to the first byte of unsigned char* buffer. */
36
37
my_off_t pos_in_file;
77
78
my_b_read() will call read_function to fetch the data. read_function
78
79
must never be invoked directly.
80
int (*read_function)(io_cache_st* ,unsigned char *,size_t);
81
int (*read_function)(struct st_io_cache *,unsigned char *,size_t);
82
83
Same idea as in the case of read_function, except my_b_write() needs to
83
84
be replaced with my_b_append() for a SEQ_READ_APPEND cache
85
int (*write_function)(io_cache_st* ,const unsigned char *,size_t);
86
int (*write_function)(struct st_io_cache *,const unsigned char *,size_t);
87
88
Specifies the type of the cache. Depending on the type of the cache
88
89
certain operations might not be available and yield unpredicatable
89
90
results. Details to be documented later
94
95
Callbacks when the actual read I/O happens. These were added and
95
96
are currently used for binary logging of LOAD DATA INFILE - when a
96
97
block is read from the file, we create a block create/append event, and
97
when io_cache_st is closed, we create an end event. These functions could,
98
when IO_CACHE is closed, we create an end event. These functions could,
98
99
of course be used for other things
100
101
IO_CACHE_CALLBACK pre_read;
157
167
alloced_buffer(0)
161
int block_write(const void*, size_t, my_off_t);
162
179
void close_cached_file();
163
180
bool real_open_cached_file();
164
181
int end_io_cache();
165
int init_io_cache(int file, size_t cachesize, cache_type type, my_off_t seek_offset, bool use_async_io, myf cache_myflags);
182
int init_io_cache(int file, size_t cachesize,
183
enum cache_type type, my_off_t seek_offset,
184
bool use_async_io, myf cache_myflags);
166
185
void init_functions();
168
bool reinit_io_cache(cache_type type_arg, my_off_t seek_offset, bool use_async_io, bool clear_cache);
187
bool reinit_io_cache(enum cache_type type_arg,
188
my_off_t seek_offset,
169
191
void setup_io_cache();
170
bool open_cached_file(const char *dir, const char *prefix, size_t cache_size, myf cache_myflags);
171
int flush(int need_append_buffer_lock= 1);
183
my_off_t tell() const
185
return pos_in_file + *current_pos - request_pos;
188
int read(void* Buffer0, size_t Count)
190
unsigned char* Buffer= reinterpret_cast<unsigned char*>(Buffer0);
191
if (read_pos + Count > read_end)
192
return read_function(this, Buffer, Count);
193
memcpy(Buffer, read_pos, Count);
198
int write(const void* Buffer0, size_t Count)
200
const unsigned char* Buffer= reinterpret_cast<const unsigned char*>(Buffer0);
201
if (write_pos + Count > write_end)
202
return write_function(this, Buffer, Count);
203
memcpy(write_pos, Buffer, Count);
192
bool open_cached_file(const char *dir,
193
const char *prefix, size_t cache_size,
198
typedef struct st_io_cache IO_CACHE; /* Used when cacheing files */
200
extern int _my_b_get(st_io_cache *info);
201
extern int _my_b_async_read(st_io_cache *info,unsigned char *Buffer,size_t Count);
203
extern int my_block_write(st_io_cache *info, const unsigned char *Buffer,
204
size_t Count, my_off_t pos);
205
extern int my_b_flush_io_cache(st_io_cache *info, int need_append_buffer_lock);
207
#define flush_io_cache(info) my_b_flush_io_cache((info),1)
209
209
} /* namespace internal */
210
210
} /* namespace drizzled */
212
#endif /* DRIZZLED_INTERNAL_IOCACHE_H */