Drizzled Public API Documentation

ha_heap.h
00001 /* Copyright (C) 2000-2006 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 
00017 
00018 /* class for the the heap Cursor */
00019 
00020 #pragma once
00021 
00022 #include <drizzled/cursor.h>
00023 #include <drizzled/thr_lock.h>
00024 
00025 typedef struct st_heap_info HP_INFO;
00026 typedef unsigned char *HEAP_PTR;
00027 
00028 
00029 class ha_heap: public drizzled::Cursor
00030 {
00031   HP_INFO *file;
00032   /* number of records changed since last statistics update */
00033   uint32_t    records_changed;
00034   uint32_t    key_stat_version;
00035   bool internal_table;
00036 public:
00037   ha_heap(drizzled::plugin::StorageEngine &engine, drizzled::Table &table);
00038   ~ha_heap() {}
00039   Cursor *clone(drizzled::memory::Root *mem_root);
00040 
00041   const char *index_type(uint32_t inx);
00042 
00043   double scan_time()
00044   { return (double) (stats.records+stats.deleted) / 20.0+10; }
00045   double read_time(uint32_t, uint32_t,
00046                    drizzled::ha_rows rows)
00047   { return (double) rows /  20.0+1; }
00048 
00049   int doOpen(const drizzled::identifier::Table &identifier, int mode, uint32_t test_if_locked);
00050   int close(void);
00051   void set_keys_for_scanning(void);
00052   int doInsertRecord(unsigned char * buf);
00053   int doUpdateRecord(const unsigned char * old_data, unsigned char * new_data);
00054   int doDeleteRecord(const unsigned char * buf);
00055   virtual void get_auto_increment(uint64_t offset, uint64_t increment,
00056                                   uint64_t nb_desired_values,
00057                                   uint64_t *first_value,
00058                                   uint64_t *nb_reserved_values);
00059   int index_read_map(unsigned char * buf, const unsigned char * key,
00060                      drizzled::key_part_map keypart_map,
00061                      enum drizzled::ha_rkey_function find_flag);
00062   int index_read_last_map(unsigned char *buf, const unsigned char *key,
00063                           drizzled::key_part_map keypart_map);
00064   int index_read_idx_map(unsigned char * buf, uint32_t index,
00065                          const unsigned char * key,
00066                          drizzled::key_part_map keypart_map,
00067                          enum drizzled::ha_rkey_function find_flag);
00068   int index_next(unsigned char * buf);
00069   int index_prev(unsigned char * buf);
00070   int index_first(unsigned char * buf);
00071   int index_last(unsigned char * buf);
00072   int doStartTableScan(bool scan);
00073   int rnd_next(unsigned char *buf);
00074   int rnd_pos(unsigned char * buf, unsigned char *pos);
00075   void position(const unsigned char *record);
00076   int info(uint);
00077   int extra(enum drizzled::ha_extra_function operation);
00078   int reset();
00079   int delete_all_rows(void);
00080   int disable_indexes(uint32_t mode);
00081   int enable_indexes(uint32_t mode);
00082   int indexes_are_disabled(void);
00083   drizzled::ha_rows records_in_range(uint32_t inx,
00084                                      drizzled::key_range *min_key,
00085                                      drizzled::key_range *max_key);
00086   void drop_table(const char *name);
00087 
00088   int cmp_ref(const unsigned char *ref1, const unsigned char *ref2);
00089   int reset_auto_increment(uint64_t value)
00090   {
00091     file->getShare()->auto_increment= value;
00092     return 0;
00093   }
00094 private:
00095   void update_key_stats();
00096 };
00097