~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/ha_archive.h

  • Committer: Stewart Smith
  • Date: 2009-08-20 17:15:54 UTC
  • mto: (1119.2.2 merge)
  • mto: This revision was merged to the branch mainline in revision 1124.
  • Revision ID: stewart@flamingspork.com-20090820171554-72eo1tqlc4n64rak
Valgrind 3.5 requires --alignment to be a power of 2 between 16 and 4096. The specifying --alignment is not important for us, so remove it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  along with this program; if not, write to the Free Software
14
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
 
#ifndef PLUGIN_ARCHIVE_HA_ARCHIVE_H
17
 
#define PLUGIN_ARCHIVE_HA_ARCHIVE_H
 
16
 
 
17
#include <inttypes.h>
 
18
#include <zlib.h>
 
19
#include "azio.h"
 
20
#include <mysys/thr_lock.h>
 
21
#include <mysys/hash.h>
 
22
#include <drizzled/handler.h>
 
23
#include <string>
18
24
 
19
25
/*
20
26
  Please read ha_archive.cc first. If you are looking for more general
40
46
  char data_file_name[FN_REFLEN];
41
47
  uint32_t use_count;
42
48
  pthread_mutex_t mutex;
43
 
  drizzled::THR_LOCK lock;
 
49
  THR_LOCK lock;
44
50
  azio_stream archive_write;     /* Archive file we are working with */
45
51
  bool archive_write_open;
46
52
  bool dirty;               /* Flag for if a flush should occur */
47
53
  bool crashed;             /* Meta file is crashed */
48
54
  uint64_t mean_rec_length;
49
55
  char real_path[FN_REFLEN];
50
 
  uint64_t  version;
51
 
  drizzled::ha_rows rows_recorded;    /* Number of rows in tables */
52
 
  drizzled::ha_rows version_rows;
 
56
  unsigned int  version;
 
57
  ha_rows rows_recorded;    /* Number of rows in tables */
 
58
  ha_rows version_rows;
53
59
};
54
60
 
55
61
/*
60
66
*/
61
67
#define ARCHIVE_VERSION 3
62
68
 
63
 
class ha_archive: public drizzled::Cursor
 
69
class ha_archive: public handler
64
70
{
65
 
  drizzled::THR_LOCK_DATA lock;        /* MySQL lock */
 
71
  THR_LOCK_DATA lock;        /* MySQL lock */
66
72
  ArchiveShare *share;      /* Shared lock info */
67
73
 
68
74
  azio_stream archive;            /* Archive file we are working with */
69
 
  drizzled::internal::my_off_t current_position;  /* The position of the row we just read */
 
75
  my_off_t current_position;  /* The position of the row we just read */
70
76
  unsigned char byte_buffer[IO_SIZE]; /* Initial buffer for our string */
71
 
  drizzled::String buffer;             /* Buffer used for blob storage */
72
 
  drizzled::ha_rows scan_rows;         /* Number of rows left in scan */
 
77
  String buffer;             /* Buffer used for blob storage */
 
78
  ha_rows scan_rows;         /* Number of rows left in scan */
73
79
  bool delayed_insert;       /* If the insert is delayed */
74
80
  bool bulk_insert;          /* If we are performing a bulk insert */
75
81
  const unsigned char *current_key;
82
88
  void destroy_record_buffer(archive_record_buffer *r);
83
89
 
84
90
public:
85
 
  ha_archive(drizzled::plugin::StorageEngine &engine_arg,
86
 
             drizzled::TableShare &table_arg);
 
91
  ha_archive(StorageEngine *engine, TableShare *table_arg);
87
92
  ~ha_archive()
88
 
  { }
 
93
  {
 
94
  }
89
95
 
90
96
  const char *index_type(uint32_t)
91
97
  { return "NONE"; }
 
98
  uint64_t table_flags() const
 
99
  {
 
100
    return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ |
 
101
            HA_STATS_RECORDS_IS_EXACT |
 
102
            HA_HAS_RECORDS);
 
103
  }
 
104
  uint32_t index_flags(uint32_t, uint32_t, bool) const
 
105
  {
 
106
    return HA_ONLY_WHOLE_INDEX;
 
107
  }
92
108
  void get_auto_increment(uint64_t, uint64_t, uint64_t,
93
109
                          uint64_t *first_value, uint64_t *nb_reserved_values);
94
 
  drizzled::ha_rows records() { return share->rows_recorded; }
 
110
  uint32_t max_supported_keys()          const { return 1; }
 
111
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
 
112
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
 
113
  ha_rows records() { return share->rows_recorded; }
95
114
  int index_init(uint32_t keynr, bool sorted);
96
115
  virtual int index_read(unsigned char * buf, const unsigned char * key,
97
 
                         uint32_t key_len,
98
 
                         drizzled::ha_rkey_function find_flag);
99
 
  virtual int index_read_idx(unsigned char * buf, uint32_t index,
100
 
                             const unsigned char * key,
101
 
                             uint32_t key_len,
102
 
                             drizzled::ha_rkey_function find_flag);
 
116
                         uint32_t key_len, enum ha_rkey_function find_flag);
 
117
  virtual int index_read_idx(unsigned char * buf, uint32_t index, const unsigned char * key,
 
118
                             uint32_t key_len, enum ha_rkey_function find_flag);
103
119
  int index_next(unsigned char * buf);
104
120
  int open(const char *name, int mode, uint32_t test_if_locked);
105
121
  int close(void);
109
125
  int rnd_init(bool scan=1);
110
126
  int rnd_next(unsigned char *buf);
111
127
  int rnd_pos(unsigned char * buf, unsigned char *pos);
 
128
  int get_row(azio_stream *file_to_read, unsigned char *buf);
 
129
  int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
 
130
  int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
112
131
  ArchiveShare *get_share(const char *table_name, int *rc);
113
132
  int free_share();
114
133
  int init_archive_writer();
115
134
  int init_archive_reader();
 
135
  bool auto_repair() const { return 1; } // For the moment we just do this
 
136
  int read_data_header(azio_stream *file_to_read);
116
137
  void position(const unsigned char *record);
117
138
  int info(uint);
118
 
private:
119
 
  int get_row(azio_stream *file_to_read, unsigned char *buf);
120
 
  int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
121
 
  int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
122
 
  int read_data_header(azio_stream *file_to_read);
123
 
  int optimize();
124
 
  int repair();
125
 
public:
126
 
  void start_bulk_insert(drizzled::ha_rows rows);
 
139
  int optimize(Session* session, HA_CHECK_OPT* check_opt);
 
140
  int repair(Session* session, HA_CHECK_OPT* check_opt);
 
141
  void start_bulk_insert(ha_rows rows);
127
142
  int end_bulk_insert();
128
 
  enum drizzled::row_type get_row_type() const
 
143
  enum row_type get_row_type() const
129
144
  {
130
 
    return drizzled::ROW_TYPE_COMPRESSED;
 
145
    return ROW_TYPE_COMPRESSED;
131
146
  }
132
 
  drizzled::THR_LOCK_DATA **store_lock(drizzled::Session *session,
133
 
                                       drizzled::THR_LOCK_DATA **to,
134
 
                                       drizzled::thr_lock_type lock_type);
135
 
  int check(drizzled::Session* session);
136
 
  bool check_and_repair(drizzled::Session *session);
 
147
  THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
 
148
                             enum thr_lock_type lock_type);
 
149
  bool is_crashed() const;
 
150
  int check(Session* session, HA_CHECK_OPT* check_opt);
 
151
  bool check_and_repair(Session *session);
137
152
  uint32_t max_row_length(const unsigned char *buf);
138
153
  bool fix_rec_buff(unsigned int length);
139
154
  int unpack_row(azio_stream *file_to_read, unsigned char *record);
140
155
  unsigned int pack_row(unsigned char *record);
141
156
};
142
157
 
143
 
#endif /* PLUGIN_ARCHIVE_HA_ARCHIVE_H */