Drizzled Public API Documentation

ha_heap.h
1 /* Copyright (C) 2000-2006 MySQL AB
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 
17 
18 /* class for the the heap Cursor */
19 
20 #pragma once
21 
22 #include <drizzled/cursor.h>
23 #include <drizzled/thr_lock.h>
24 
25 typedef struct st_heap_info HP_INFO;
26 typedef unsigned char *HEAP_PTR;
27 
28 class ha_heap : public drizzled::Cursor
29 {
30  HP_INFO *file;
31  /* number of records changed since last statistics update */
32  uint32_t records_changed;
33  uint32_t key_stat_version;
34  bool internal_table;
35 public:
37  ~ha_heap() {}
38  Cursor *clone(drizzled::memory::Root *mem_root);
39 
40  const char *index_type(uint32_t inx);
41 
42  double scan_time()
43  { return (double) (stats.records+stats.deleted) / 20.0+10; }
44  double read_time(uint32_t, uint32_t,
45  drizzled::ha_rows rows)
46  { return (double) rows / 20.0+1; }
47 
48  int doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked);
49  int close(void);
50  void set_keys_for_scanning(void);
51  int doInsertRecord(unsigned char * buf);
52  int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
53  int doDeleteRecord(const unsigned char * buf);
54  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
55  uint64_t nb_desired_values,
56  uint64_t *first_value,
57  uint64_t *nb_reserved_values);
58  int index_read_map(unsigned char * buf, const unsigned char * key,
59  drizzled::key_part_map keypart_map,
60  enum drizzled::ha_rkey_function find_flag);
61  int index_read_last_map(unsigned char *buf, const unsigned char *key,
62  drizzled::key_part_map keypart_map);
63  int index_read_idx_map(unsigned char * buf, uint32_t index,
64  const unsigned char * key,
65  drizzled::key_part_map keypart_map,
66  enum drizzled::ha_rkey_function find_flag);
67  int index_next(unsigned char * buf);
68  int index_prev(unsigned char * buf);
69  int index_first(unsigned char * buf);
70  int index_last(unsigned char * buf);
71  int doStartTableScan(bool scan);
72  int rnd_next(unsigned char *buf);
73  int rnd_pos(unsigned char * buf, unsigned char *pos);
74  void position(const unsigned char *record);
75  int info(uint);
76  int extra(enum drizzled::ha_extra_function operation);
77  int reset();
78  int delete_all_rows(void);
79  int disable_indexes(uint32_t mode);
80  int enable_indexes(uint32_t mode);
81  int indexes_are_disabled(void);
82  drizzled::ha_rows records_in_range(uint32_t inx,
83  drizzled::key_range *min_key,
84  drizzled::key_range *max_key);
85  void drop_table();
86 
87  int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
88  int reset_auto_increment(uint64_t value)
89  {
90  file->getShare()->auto_increment= value;
91  return 0;
92  }
93 private:
94  void update_key_stats();
95 };
96