~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/archive/ha_archive.h

  • Committer: Monty Taylor
  • Date: 2009-05-09 22:13:47 UTC
  • mto: This revision was merged to the branch mainline in revision 1009.
  • Revision ID: mordred@inaugust.com-20090509221347-l712szviusbobro0
Re-added bitset<> as a replacement for Bitmap<>

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
 
#ifdef USE_PRAGMA_INTERFACE
17
 
#pragma interface                       /* gcc class implementation */
18
 
#endif
19
16
 
20
17
#include <inttypes.h>
21
18
#include <zlib.h>
22
19
#include "azio.h"
 
20
#include <mysys/thr_lock.h>
 
21
#include <mysys/hash.h>
 
22
#include <drizzled/handler.h>
 
23
#include <string>
 
24
 
 
25
using namespace std;
23
26
 
24
27
/*
25
28
  Please read ha_archive.cc first. If you are looking for more general
33
36
} archive_record_buffer;
34
37
 
35
38
 
36
 
typedef struct st_archive_share {
37
 
  char *table_name;
 
39
class ArchiveShare {
 
40
public:
 
41
  ArchiveShare();
 
42
  ArchiveShare(const char *name);
 
43
  ~ArchiveShare();
 
44
 
 
45
  bool prime(uint64_t *auto_increment);
 
46
 
 
47
  string table_name;
38
48
  char data_file_name[FN_REFLEN];
39
 
  uint32_t table_name_length,use_count;
 
49
  uint32_t use_count;
40
50
  pthread_mutex_t mutex;
41
51
  THR_LOCK lock;
42
52
  azio_stream archive_write;     /* Archive file we are working with */
43
53
  bool archive_write_open;
44
54
  bool dirty;               /* Flag for if a flush should occur */
45
55
  bool crashed;             /* Meta file is crashed */
46
 
  ha_rows rows_recorded;    /* Number of rows in tables */
47
56
  uint64_t mean_rec_length;
48
57
  char real_path[FN_REFLEN];
49
58
  unsigned int  version;
 
59
  ha_rows rows_recorded;    /* Number of rows in tables */
50
60
  ha_rows version_rows;
51
 
} ARCHIVE_SHARE;
 
61
};
52
62
 
53
63
/*
54
64
  Version for file format.
61
71
class ha_archive: public handler
62
72
{
63
73
  THR_LOCK_DATA lock;        /* MySQL lock */
64
 
  ARCHIVE_SHARE *share;      /* Shared lock info */
65
 
  
 
74
  ArchiveShare *share;      /* Shared lock info */
 
75
 
66
76
  azio_stream archive;            /* Archive file we are working with */
67
77
  my_off_t current_position;  /* The position of the row we just read */
68
78
  unsigned char byte_buffer[IO_SIZE]; /* Initial buffer for our string */
80
90
  void destroy_record_buffer(archive_record_buffer *r);
81
91
 
82
92
public:
83
 
  ha_archive(handlerton *hton, TABLE_SHARE *table_arg);
 
93
  ha_archive(StorageEngine *engine, TableShare *table_arg);
84
94
  ~ha_archive()
85
95
  {
86
96
  }
87
97
  const char *table_type() const { return "ARCHIVE"; }
88
 
  const char *index_type(uint32_t inx __attribute__((unused)))
 
98
  const char *index_type(uint32_t)
89
99
  { return "NONE"; }
90
100
  const char **bas_ext() const;
91
101
  uint64_t table_flags() const
92
102
  {
93
103
    return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ |
94
 
            HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE |
95
104
            HA_STATS_RECORDS_IS_EXACT |
96
105
            HA_HAS_RECORDS |
97
106
            HA_FILE_BASED);
98
107
  }
99
 
  uint32_t index_flags(uint32_t idx __attribute__((unused)),
100
 
                       uint32_t part __attribute__((unused)),
101
 
                       bool all_parts __attribute__((unused))) const
 
108
  uint32_t index_flags(uint32_t, uint32_t, bool) const
102
109
  {
103
110
    return HA_ONLY_WHOLE_INDEX;
104
111
  }
105
 
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
106
 
                                  uint64_t nb_desired_values,
107
 
                                  uint64_t *first_value,
108
 
                                  uint64_t *nb_reserved_values);
 
112
  void get_auto_increment(uint64_t, uint64_t, uint64_t,
 
113
                          uint64_t *first_value, uint64_t *nb_reserved_values);
109
114
  uint32_t max_supported_keys()          const { return 1; }
110
115
  uint32_t max_supported_key_length()    const { return sizeof(uint64_t); }
111
116
  uint32_t max_supported_key_part_length() const { return sizeof(uint64_t); }
127
132
  int get_row(azio_stream *file_to_read, unsigned char *buf);
128
133
  int get_row_version2(azio_stream *file_to_read, unsigned char *buf);
129
134
  int get_row_version3(azio_stream *file_to_read, unsigned char *buf);
130
 
  ARCHIVE_SHARE *get_share(const char *table_name, int *rc);
 
135
  ArchiveShare *get_share(const char *table_name, int *rc);
131
136
  int free_share();
132
137
  int init_archive_writer();
133
138
  int init_archive_reader();
137
142
  int info(uint);
138
143
  void update_create_info(HA_CREATE_INFO *create_info);
139
144
  int create(const char *name, Table *form, HA_CREATE_INFO *create_info);
140
 
  int optimize(THD* thd, HA_CHECK_OPT* check_opt);
141
 
  int repair(THD* thd, HA_CHECK_OPT* check_opt);
 
145
  int optimize(Session* session, HA_CHECK_OPT* check_opt);
 
146
  int repair(Session* session, HA_CHECK_OPT* check_opt);
142
147
  void start_bulk_insert(ha_rows rows);
143
148
  int end_bulk_insert();
144
 
  enum row_type get_row_type() const 
145
 
  { 
 
149
  enum row_type get_row_type() const
 
150
  {
146
151
    return ROW_TYPE_COMPRESSED;
147
152
  }
148
 
  THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
 
153
  THR_LOCK_DATA **store_lock(Session *session, THR_LOCK_DATA **to,
149
154
                             enum thr_lock_type lock_type);
150
155
  bool is_crashed() const;
151
 
  int check(THD* thd, HA_CHECK_OPT* check_opt);
152
 
  bool check_and_repair(THD *thd);
 
156
  int check(Session* session, HA_CHECK_OPT* check_opt);
 
157
  bool check_and_repair(Session *session);
153
158
  uint32_t max_row_length(const unsigned char *buf);
154
159
  bool fix_rec_buff(unsigned int length);
155
160
  int unpack_row(azio_stream *file_to_read, unsigned char *record);