~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/csv/ha_tina.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <sys/stat.h>
24
24
#include "transparent_file.h"
25
25
 
26
 
#define DEFAULT_CHAIN_LENGTH 512
27
26
/*
28
27
  Version for file format.
29
28
  1 - Initial Version. That is, the version when the metafile was introduced.
37
36
  TinaShare(const TinaShare &);
38
37
  TinaShare& operator=(const TinaShare &);
39
38
public:
40
 
  explicit TinaShare(const char *name);
 
39
  explicit TinaShare(const std::string &name);
41
40
  ~TinaShare();
42
41
 
43
42
  std::string table_name;
44
 
  char data_file_name[FN_REFLEN];
 
43
  std::string data_file_name;
45
44
  uint32_t use_count;
46
45
  /*
47
46
    Here we save the length of the file for readers. This is updated by
50
49
  */
51
50
  off_t saved_data_file_length;
52
51
  pthread_mutex_t mutex;
53
 
  drizzled::THR_LOCK lock;
54
52
  bool update_file_opened;
55
53
  bool tina_write_opened;
56
54
  int meta_file;           /* Meta file we use */
60
58
  uint32_t data_file_version;   /* Version of the data file used */
61
59
};
62
60
 
63
 
struct tina_set {
64
 
  off_t begin;
65
 
  off_t end;
66
 
};
67
 
 
68
61
class ha_tina: public drizzled::Cursor
69
62
{
70
63
  drizzled::THR_LOCK_DATA lock;      /* MySQL lock */
80
73
  drizzled::String buffer;
81
74
  /*
82
75
    The chain contains "holes" in the file, occured because of
83
 
    deletes/updates. It is used in rnd_end() to get rid of them
 
76
    deletes/updates. It is used in doEndTableScan() to get rid of them
84
77
    in the end of the query.
85
78
  */
86
 
  tina_set chain_buffer[DEFAULT_CHAIN_LENGTH];
87
 
  tina_set *chain;
88
 
  tina_set *chain_ptr;
89
 
  unsigned char chain_alloced;
90
 
  uint32_t chain_size;
 
79
  std::vector< std::pair<off_t, off_t> > chain;
91
80
  uint32_t local_data_file_version;  /* Saved version of the data file used */
92
81
  bool records_is_known;
93
82
  drizzled::memory::Root blobroot;
94
83
 
95
 
  bool get_write_pos(off_t *end_pos, tina_set *closest_hole);
 
84
  bool get_write_pos(off_t *end_pos,
 
85
                     std::vector< std::pair<off_t, off_t> >::iterator &closest_hole);
96
86
  int open_update_temp_file_if_needed();
97
87
  int init_tina_writer();
98
88
  int init_data_file();
101
91
  ha_tina(drizzled::plugin::StorageEngine &engine, drizzled::TableShare &table_arg);
102
92
  ~ha_tina()
103
93
  {
104
 
    if (chain_alloced)
105
 
      free(chain);
106
94
    if (file_buff)
107
95
      delete file_buff;
108
96
  }
118
106
  /* The next method will never be called */
119
107
  virtual bool fast_key_read() { return 1;}
120
108
  /*
121
 
    TODO: return actual upper bound of number of records in the table.
 
109
    @TODO return actual upper bound of number of records in the table.
122
110
    (e.g. save number of records seen on full table scan and/or use file size
123
111
    as upper bound)
124
112
  */
125
113
  drizzled::ha_rows estimate_rows_upper_bound() { return HA_POS_ERROR; }
126
114
 
127
 
  int open(const char *name, int mode, uint32_t open_options);
 
115
  int doOpen(const drizzled::TableIdentifier &identifier, int mode, uint32_t test_if_locked);
 
116
  int open(const char *, int , uint32_t ) { assert(0); return -1; }
128
117
  int close(void);
129
 
  int write_row(unsigned char * buf);
130
 
  int update_row(const unsigned char * old_data, unsigned char * new_data);
131
 
  int delete_row(const unsigned char * buf);
132
 
  int rnd_init(bool scan=1);
 
118
  int doInsertRecord(unsigned char * buf);
 
119
  int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
 
120
  int doDeleteRecord(const unsigned char * buf);
 
121
  int doStartTableScan(bool scan=1);
133
122
  int rnd_next(unsigned char *buf);
134
123
  int rnd_pos(unsigned char * buf, unsigned char *pos);
135
 
  int rnd_end();
136
 
  TinaShare *get_share(const char *table_name);
 
124
  int doEndTableScan();
 
125
  TinaShare *get_share(const std::string &table_name);
137
126
  int free_share();
138
127
  int repair(drizzled::Session* session, drizzled::HA_CHECK_OPT* check_opt);
139
128
  /* This is required for SQL layer to know that we support autorepair */
140
129
  void position(const unsigned char *record);
141
130
  int info(uint);
142
131
  int delete_all_rows(void);
143
 
 
144
 
  /*
145
 
    These functions used to get/update status of the Cursor.
146
 
    Needed to enable concurrent inserts.
147
 
  */
148
 
  void get_status();
149
 
  void update_status();
 
132
  void get_auto_increment(uint64_t, uint64_t,
 
133
                          uint64_t,
 
134
                          uint64_t *,
 
135
                          uint64_t *)
 
136
  {}
150
137
 
151
138
  /* The following methods were added just for TINA */
152
139
  int encode_quote(unsigned char *buf);